NATION

PASSWORD

NationStates API (nationdata/regiondata)

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.

Advertisement

Remove ads

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Tue Apr 29, 2014 8:53 pm

[violet] wrote:Fixed bug causing percentage signs to display when requesting a nation API with no shards and explicitly specifying a version number of 5 or higher, and a separate bug causing incorrect formatting in API version 5 when looking up nations with a public sector of 100% or 0%.


Thanks. Hopefully I caught all the places in my tooling where these changes occur. Will have to skim the error logs tomorrow I guess...
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
The Shadow Assassin
Civil Servant
 
Posts: 8
Founded: Jan 10, 2014
Ex-Nation

Postby The Shadow Assassin » Sun May 04, 2014 1:49 am

Question, is it legal for a script to send telegrams no more than once every 30 seconds, but more than once every 180 seconds, if the main purpose of the telegram is to welcome new nations and show them how things work, but on the side also advertise a region?

So it will be something like:

"Welcome to NationStates.

This is how game issues work: . . . . . . .
There's something called the world assembly; this is it's function: . . . . . . .
There is something called Raiding and Defending. Here's a summary and guide for it: . . . . . . .
Some regions also do role-playing. Here's a summary and guide for that: . . . . . . .
This how the NationStates forum works and here are it's main rules: . . . . . . .

By the way, you are welcome to join us in region [XYZ] and we will be happy help you explore more aspects of NationStates"


Does a telegram styled as such, so that guiding new players into NS is the first and main thing, counts as a general telegram and can be sent once every second 30? Or is any slight advertisement to a region makes the telegram recruitment and it must be sent no more than once per 180 seconds?

Thanks.
Last edited by The Shadow Assassin on Sun May 04, 2014 1:50 am, edited 2 times in total.

User avatar
Sedgistan
Site Director
 
Posts: 35477
Founded: Oct 20, 2006
Anarchy

Postby Sedgistan » Sun May 04, 2014 9:48 am

That's a recruiting TG. It needs to follow the regular limits - i.e. 1 per 180 seconds.

User avatar
Jeckland
Minister
 
Posts: 2198
Founded: Nov 28, 2013
Ex-Nation

Postby Jeckland » Mon May 05, 2014 10:23 am

Sedgistan wrote:That's a recruiting TG. It needs to follow the regular limits - i.e. 1 per 180 seconds.

You're only allowed 1 TG per 180 seconds?

is that something new? Cos if it isn't, I admit I'm a serial offender here.
Winners: N/A
Runners Up: WBC 30 & 31, Memorial Cup
Semi Final: CE 26, WBC 35, WLC 20

User avatar
Ballotonia
Senior Admin
 
Posts: 5494
Founded: Antiquity
Democratic Socialists

Postby Ballotonia » Mon May 05, 2014 11:08 am

Jeckland wrote:
Sedgistan wrote:That's a recruiting TG. It needs to follow the regular limits - i.e. 1 per 180 seconds.

You're only allowed 1 TG per 180 seconds?

is that something new? Cos if it isn't, I admit I'm a serial offender here.


That's the scripted speed limit. When someone lets a computer program send telegrams. The speed limit for manually sending telegrams is whatever speed the site lets you send them.

Ballotonia
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
Reeveton
Lobbyist
 
Posts: 16
Founded: Sep 25, 2012
Ex-Nation

API

Postby Reeveton » Mon May 12, 2014 8:16 pm

I recently received an API code, and want to use it for recruitment purposes, but am unsure of how to proceed. Help anyone?

User avatar
Jeckland
Minister
 
Posts: 2198
Founded: Nov 28, 2013
Ex-Nation

Postby Jeckland » Tue May 13, 2014 12:56 pm

Ballotonia wrote:
Jeckland wrote:You're only allowed 1 TG per 180 seconds?

is that something new? Cos if it isn't, I admit I'm a serial offender here.


That's the scripted speed limit. When someone lets a computer program send telegrams. The speed limit for manually sending telegrams is whatever speed the site lets you send them.

Ballotonia

Oh good. I'm not a criminal. Yay.
Winners: N/A
Runners Up: WBC 30 & 31, Memorial Cup
Semi Final: CE 26, WBC 35, WLC 20

User avatar
Tlik
Ambassador
 
Posts: 1253
Founded: Jan 31, 2009
Ex-Nation

Postby Tlik » Tue Jun 17, 2014 9:58 am

Would it be possible to have a boneyard API? I don't think there's currently a way to get at the information on the boneyard page without scraping the page itself, which is obviously subject to the slower rate limits.

User avatar
Ballotonia
Senior Admin
 
Posts: 5494
Founded: Antiquity
Democratic Socialists

Postby Ballotonia » Tue Jun 17, 2014 10:29 am

Tlik wrote:Would it be possible to have a boneyard API? I don't think there's currently a way to get at the information on the boneyard page without scraping the page itself, which is obviously subject to the slower rate limits.


What information are you looking for?

Dead nations aren't actually in the game, and since their files are pulled from the archive I actually don't want to make that access high-speed.

Ballotonia
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Tue Jun 17, 2014 10:31 am

Ballotonia wrote:
Tlik wrote:Would it be possible to have a boneyard API? I don't think there's currently a way to get at the information on the boneyard page without scraping the page itself, which is obviously subject to the slower rate limits.


What information are you looking for?

Dead nations aren't actually in the game, and since their files are pulled from the archive I actually don't want to make that access high-speed.

Ballotonia


A list of all nation names ever used, and CTE timestamp would be cool.
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
Ballotonia
Senior Admin
 
Posts: 5494
Founded: Antiquity
Democratic Socialists

Postby Ballotonia » Tue Jun 17, 2014 10:35 am

Shadow Afforess wrote:A list of all nation names ever used, and CTE timestamp would be cool.


The Boneyard doesn't actually provide that...

Ballotonia
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
Wuufu
Civil Servant
 
Posts: 7
Founded: Jun 09, 2013
Liberal Democratic Socialists

Postby Wuufu » Tue Jun 17, 2014 11:00 am

I would also be interested in getting a boneyard API. From my perspective, I would like a similar API to that of the nation API to be able to pull specific information on a nation from the boneyard, similar to the data that gets displayed when you view that nation in the boneyard (example).

So this would be things like nation name(s), what date they were founded, what date they CTE'd, last known population, etc for all nations with that particular matching name. I'm not so interested in the full list of nations rather than being able to pull out the API the same information that the boneyard seems to already possess, without having to scrape the boneyard page to get it.
Last edited by Wuufu on Tue Jun 17, 2014 11:01 am, edited 1 time in total.

User avatar
Tlik
Ambassador
 
Posts: 1253
Founded: Jan 31, 2009
Ex-Nation

Postby Tlik » Wed Jun 18, 2014 4:19 am

Ballotonia wrote:
Tlik wrote:Would it be possible to have a boneyard API? I don't think there's currently a way to get at the information on the boneyard page without scraping the page itself, which is obviously subject to the slower rate limits.


What information are you looking for?

Dead nations aren't actually in the game, and since their files are pulled from the archive I actually don't want to make that access high-speed.

Ballotonia

Basically the information that I can currently get from the page, for information's sake. I mean, if it's particularly more difficult or taxing on the servers to get it, it doesn't matter too much, but it would be nice to have that information in a more accessible format.

User avatar
The Black Angel Of Death
Secretary
 
Posts: 29
Founded: Feb 07, 2014
Ex-Nation

Postby The Black Angel Of Death » Thu Jun 19, 2014 1:27 pm

Hi I would like how to change the recruitment telegram for my region using the API.

User avatar
Moon Eclipse
Lobbyist
 
Posts: 24
Founded: Jun 19, 2014
Ex-Nation

Postby Moon Eclipse » Fri Jun 20, 2014 7:33 pm

Warning: simplexml_load_file(): http://www.nationstates.net/cgi-bin/api ... er=law:398: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xED 0x6E 0x20 0x61 in /home/u46966662/public_html/dumpydumpdump.php on line 61


My script was working so beautifully and nice just a few days ago! :(

Any advice on what happened in the last few days?

According to stackoverflow (and the error message :P) this means the data is not properly formatted. Anyone else having this problem? The utf8_encode() workaround doesn't work either.

:(

User avatar
Ballotonia
Senior Admin
 
Posts: 5494
Founded: Antiquity
Democratic Socialists

Postby Ballotonia » Sat Jun 21, 2014 12:13 am

The content of that API call is:
Code: Select all
<WORLD><HAPPENINGS></HAPPENINGS></WORLD>


... which looks OK to me.

Ballotonia
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
Andacantra
Diplomat
 
Posts: 570
Founded: Jul 01, 2010
Ex-Nation

Re: NationStates API (nationdata/regiondata)

Postby Andacantra » Sat Jun 21, 2014 12:23 am

I'll just drop in here to say that a mistake I often make is forgetting to put handling in for when the result of the api call is no information - that could be what caused that error.
Abbey
Chief Kitty of the Cat Burglars
Bi-gameplayers: Raiding and defending because both are fun and ok
Nationstates Issues **SPOILER ALERT**

User avatar
Moon Eclipse
Lobbyist
 
Posts: 24
Founded: Jun 19, 2014
Ex-Nation

Postby Moon Eclipse » Sat Jun 21, 2014 5:00 pm

Well, it works now. I think my code was just a little too hacky, fixed the problem on my end and it is all swell. :)

User avatar
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Mon Jun 23, 2014 9:47 am

[violet] wrote:New API Version: 5

Changes:
  1. Outputs as UTF-8. This will also affect all Daily Dumps from now on.
  2. Values under <PUBLICSECTOR>, <GOVT>, and <DEATHS> are displayed in the format "%.1f" (e.g. "21.1"), rather than "%d%%" (e.g. "21%"). Notice that's two differences: an extra decimal place, and no more percentage sign.

Examples: v4, v5.

API documentation

Note that going forward I will only be maintaining the three most recent API versions. If you depend on API version 1 or 2, it may stop working without notice.

Some concerns that have come up for me:

1. Not quite everything is UTF-8 (Indeed, asking for the currency separately still gets you windows-1252 characters, even though getting the default shards results in UTF-8 in the currency field).
Code: Select all
$ curl -i 'http://www.nationstates.net/cgi-bin/api.cgi?q=currency&nation=jolteonia'
HTTP/1.1 200 OK
Date: Mon, 23 Jun 2014 16:20:48 GMT
Server: Apache
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/xml; charset=ISO-8859-1

<NATION id="jolteonia"><CURRENCY>Pok�dollar</CURRENCY></NATION>

2. Thankfully (?) the Content-Type header still says charset=ISO-8859-1 (meaning windows-1252).
3. ... It still says ISO-8859-1 for outputs which are actually UTF-8. (And not valid windows-1252). Edit: This can cause problems, see spoilered image:
Image
Details (in utf-8 terminal):
Code: Select all
$ curl -i 'http://www.nationstates.net/cgi-bin/api.cgi?nation=jolteonia'
HTTP/1.1 200 OK
Date: Mon, 23 Jun 2014 16:21:34 GMT
Server: Apache
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/xml; charset=ISO-8859-1

<NATION>
<NAME>Jolteonia</NAME>
<TYPE>Principality</TYPE>
<FULLNAME>The Principality of Jolteonia</FULLNAME>
<MOTTO>言えるかな?</MOTTO>
<CATEGORY>Liberal Democratic Socialists</CATEGORY>
<UNSTATUS>Non-member</UNSTATUS>
<FREEDOM>
 <CIVILRIGHTS>Excellent</CIVILRIGHTS>
 <ECONOMY>Frightening</ECONOMY>
 <POLITICALFREEDOM>World Benchmark</POLITICALFREEDOM>
</FREEDOM>
<REGION>Balder</REGION>
<POPULATION>7187</POPULATION>
<TAX>100</TAX>
<ANIMAL>Jolteon</ANIMAL>
<CURRENCY>Pokédollar</CURRENCY>
<FLAG>http://www.nationstates.net/images/flags/uploads/jolteonia__455639.png</FLAG>
<MAJORINDUSTRY>Book Publishing</MAJORINDUSTRY>
<GOVTPRIORITY>Education</GOVTPRIORITY>
<GOVT>
 <ENVIRONMENT>18.9</ENVIRONMENT>
 <SOCIALEQUALITY>18.8</SOCIALEQUALITY>
 <EDUCATION>32.7</EDUCATION>
 <LAWANDORDER>0.0</LAWANDORDER>
 <ADMINISTRATION>3.7</ADMINISTRATION>
 <WELFARE>8.4</WELFARE>
 <SPIRITUALITY>0.0</SPIRITUALITY>
 <DEFENCE>0.0</DEFENCE>
 <PUBLICTRANSPORT>3.5</PUBLICTRANSPORT>
 <HEALTHCARE>5.6</HEALTHCARE>
 <COMMERCE>8.4</COMMERCE>
</GOVT>
<FOUNDED>3 years 123 days ago</FOUNDED>
<FIRSTLOGIN>1298284145</FIRSTLOGIN>
<LASTLOGIN>1403434735</LASTLOGIN>
<LASTACTIVITY>1 day 5 hours ago</LASTACTIVITY>
<INFLUENCE>Minnow</INFLUENCE>
<FREEDOMSCORES>
 <CIVILRIGHTS>72</CIVILRIGHTS>
 <ECONOMY>100</ECONOMY>
 <POLITICALFREEDOM>82</POLITICALFREEDOM>
</FREEDOMSCORES>
<PUBLICSECTOR>62.4</PUBLICSECTOR>
<DEATHS>
 <CAUSE type="Lost in Wilderness">32.4</CAUSE>
 <CAUSE type="Animal Attack">3.1</CAUSE>
 <CAUSE type="Old Age">64.4</CAUSE>
</DEATHS>
<LEADER>Jolteon</LEADER>
<CAPITAL>Viridian Forest</CAPITAL>
<RELIGION>a major religion</RELIGION>
</NATION>

4. This is probably fine but the regions API (and xml dump) XML-encodes non-ascii characters instead of giving them out as UTF-8, which is slightly inconsistent (but generally fine).

I've been able to fiddle with my projects to live with this, but the quoted post is at least slightly misleading.
Last edited by Eluvatar on Mon Jun 23, 2014 10:39 am, edited 2 times in total.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
[violet]
Executive Director
 
Posts: 16207
Founded: Antiquity

Postby [violet] » Mon Jun 23, 2014 7:43 pm

Thanks for the above; I will check it out.

User avatar
Ghondra
Senator
 
Posts: 4354
Founded: Feb 07, 2014
Ex-Nation

Postby Ghondra » Sat Jul 05, 2014 3:15 pm

What the hell is a secret key? Could somebody tell me?
⚧Copy and paste this in your sig if you passed biology and know gender and sex aren't the same thing ⚧
I'M A MEMBER OF THOUGHT CAFE
WE'RE THE AWESOMEST, COME CHECK US OUT

CURRENT STATUS: Splendid Isolation
IS A: Democratic Socialist, Liberal, ENTP/ENFP
Agrees on:
Gay Marriage, Civil Rights, Military Interventionism, Capitalism with Limits, Theory of Evolution, Equality for all, Free Education, and Universal Healthcare, Legalisation of Marijuana
Disagree on:
Militant Atheism, Wars of Aggression, Communism, Welfare to Parasites, Nazism, Fascism, Militarism.
Economic Left/Right: -3.88
Social Libertarian/Authoritarian: -1.13

Exelia wrote:It's all good till you have to wear a badge.

Listen to Jord, its good for your health

User avatar
Ballotonia
Senior Admin
 
Posts: 5494
Founded: Antiquity
Democratic Socialists

Postby Ballotonia » Sat Jul 05, 2014 11:38 pm

Ghondra wrote:What the hell is a secret key? Could somebody tell me?


For NS++ questions, ask in the NS++ thread: viewtopic.php?p=20795519#p20795519
(NB: I'm linking to the specific post where this is addressed)

Ballotonia
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
Leutria
Ambassador
 
Posts: 1724
Founded: Oct 29, 2012
Left-wing Utopia

Postby Leutria » Sun Jul 06, 2014 8:14 am

Ghondra wrote:What the hell is a secret key? Could somebody tell me?

You get a secret key when you send a telegram to tag:api (in order to create an API template).

Ballotonia wrote:
Ghondra wrote:What the hell is a secret key? Could somebody tell me?


For NS++ questions, ask in the NS++ thread: https://forum.nationstates.net/viewtopi ... #p20795519
(NB: I'm linking to the specific post where this is addressed)

Ballotonia
Is that really a NS++ specific question? Have I got something wrong?

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Tue Jul 08, 2014 11:11 am

Possible improvement: Region API for RMB posts should include post id with each entry. Discussion ->

viewtopic.php?f=15&t=303608&p=20845258#p20845258
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Tue Jul 08, 2014 11:56 am

Shadow Afforess wrote:Possible improvement: Region API for RMB posts should include post id with each entry. Discussion ->

viewtopic.php?f=15&t=303608&p=20845258#p20845258

I would like to suggest that happenings also get their event IDs in the nation, region, and WA APIs, if possible. It would help scripts ensure they don't confuse two simultaneous events for the same event, and would help sequence events that happen the same second.
:bow:
To Serve and Protect: UDL

Eluvatar - Taijitu member

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Dosa Man, Invernessia, Northern Cobrastan, Randomnian State, The Two Jerseys, Tungstan

Advertisement

Remove ads