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
Afforess
Ambassador
 
Posts: 1105
Founded: Jun 22, 2009
Ex-Nation

Postby Afforess » Wed Oct 23, 2013 10:10 am

Zemnaya Svoboda wrote:Switching to JSON would break all existing code. It would be a better format, however.

Yeah, but you could keep both API's alive.In fairness to NS, I am pretty sure JSON was formalized after NS was started, so XML was the only choice. But it would be awesome to add JSON now.
Minister of the Interior, Capitalist Paradise

The reasonable man adapts himself to the world: the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man.

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

Postby Tlik » Wed Oct 23, 2013 2:07 pm

The Black Hat Guy wrote:
Tlik wrote:An additional JSON format alongside the XML format, say by adding a "format=json" key-value parameter to url, might be a good compromise.


I can't tell you how useful this would be. I'm horrible at parsing xml.

I had that problem, and then I started using regexes.

Now I've got two problems!

Look at me, I'm funny, I know programmer jokes, I must be cool, come on guys, like me 'cos of my cool programmer jokes!

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

Postby [violet] » Wed Oct 23, 2013 3:07 pm

Afforess wrote:In fairness to NS, I am pretty sure JSON was formalized after NS was started, so XML was the only choice. But it would be awesome to add JSON now.

True & true. It's one of those I-should-do-that-when-I-get-time features.

User avatar
The Black Hat Guy
Diplomat
 
Posts: 952
Founded: Feb 12, 2013
Ex-Nation

Postby The Black Hat Guy » Sun Oct 27, 2013 9:05 am

Will the decision about zombies show up in the legislation or happenings shard of the API?

If not, could we get a shard for the current zombie status of a nation for the apocalypse? Pretty please?
Last edited by The Black Hat Guy on Sun Oct 27, 2013 10:02 am, edited 3 times in total.

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

Postby [violet] » Mon Oct 28, 2013 6:15 pm

The Black Hat Guy wrote:Will the decision about zombies show up in the legislation or happenings shard of the API?

If not, could we get a shard for the current zombie status of a nation for the apocalypse? Pretty please?

Good idea! This will be available via the Nations API in a shard named "zombie". It will describe the nation's current action and the number of survivors, infected, and dead.

User avatar
The Black Hat Guy
Diplomat
 
Posts: 952
Founded: Feb 12, 2013
Ex-Nation

Postby The Black Hat Guy » Mon Oct 28, 2013 6:56 pm

[violet] wrote:
The Black Hat Guy wrote:Will the decision about zombies show up in the legislation or happenings shard of the API?

If not, could we get a shard for the current zombie status of a nation for the apocalypse? Pretty please?

Good idea! This will be available via the Nations API in a shard named "zombie". It will describe the nation's current action and the number of survivors, infected, and dead.


Thank you!

User avatar
Starrie
Attaché
 
Posts: 94
Founded: Jan 04, 2012
Ex-Nation

Postby Starrie » Sun Nov 03, 2013 11:05 am

some nations, namely http://www.nationstates.net/nation=panauislands, have a motto containing the substitute character, 

this character shows up in the daily dump and breaks most (if not all) xml parsers so i'm having a hard time accessing the data. i might filter out the character first, but that seems like a clumsy solution.

would it be possible to filter out this character (or invalid ones) before generating the daily dump?

thanks!
Last edited by Starrie on Sun Nov 03, 2013 11:05 am, edited 1 time in total.

User avatar
Northrop-Grumman
Ambassador
 
Posts: 1748
Founded: Dec 28, 2003
Benevolent Dictatorship

Postby Northrop-Grumman » Sun Nov 10, 2013 6:20 am

Starrie wrote:some nations, namely http://www.nationstates.net/nation=panauislands, have a motto containing the substitute character, 

this character shows up in the daily dump and breaks most (if not all) xml parsers so i'm having a hard time accessing the data. i might filter out the character first, but that seems like a clumsy solution.

would it be possible to filter out this character (or invalid ones) before generating the daily dump?

thanks!
I would be so grateful for something like this. I'm not sure it's my computer slowly degrading or the nations.xml file becoming increasingly larger (probably the former), but I can't go and edit these things out like I used to; opening up the xml file tends to freeze my computer.
Last edited by Northrop-Grumman on Sun Nov 10, 2013 6:38 am, edited 1 time in total.

User avatar
NewTexas
Spokesperson
 
Posts: 181
Founded: Antiquity
Civil Rights Lovefest

Postby NewTexas » Mon Nov 11, 2013 5:50 pm

There is another one with an invalid entity in the dump:

http://www.nationstates.net/cgi-bin/api ... eitstiefel

"�" is not a valid entity

We are with Northrop-Grumman & Starrie on asking if this can be fixed.

:ugeek:
Big Tex
Governor of Texas

Author: NSDossier

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

Postby Shadow Afforess » Mon Nov 11, 2013 8:02 pm

Thank god I am using Java...the built in SAX parser can be set to even ignore fatal XML encoding errors...

Anyone considered bootstrapping my NS-DUMPS project for avoiding this issue? It converts daily dumps into a SQL database, which you can then use to do whatever which. It can parse even invalid daily dumps.
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
[violet]
Executive Director
 
Posts: 16205
Founded: Antiquity

Postby [violet] » Wed Nov 13, 2013 10:46 pm

I've created a new API version (currently in testing) that outputs UTF-8, which should prevent these kinds of problems in the future. Please check out:

http://www.nationstates.net/cgi-bin/api ... tiefel/v=5
http://www.nationstates.net/cgi-bin/api ... slands/v=5

Now if the Daily Dumps adopt this, is that going to work for everyone, or will it just create new problems? Currently dumps are in ISO-8859-1, with lots of characters escaped as HTML entities.

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

Postby Shadow Afforess » Wed Nov 13, 2013 11:01 pm

[violet] wrote:Now if the Daily Dumps adopt this, is that going to work for everyone, or will it just create new problems? Currently dumps are in ISO-8859-1, with lots of characters escaped as HTML entities.


Can you generate a test daily dump with that encoding so I can test my parsers?
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
[violet]
Executive Director
 
Posts: 16205
Founded: Antiquity

Postby [violet] » Wed Nov 13, 2013 11:28 pm

Shadow Afforess wrote:Can you generate a test daily dump with that encoding so I can test my parsers?

Right now I can show you a little one: http://www.nationstates.net/pages/natio ... est.xml.gz

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

Postby Shadow Afforess » Wed Nov 13, 2013 11:32 pm

[violet] wrote:
Shadow Afforess wrote:Can you generate a test daily dump with that encoding so I can test my parsers?

Right now I can show you a little one: http://www.nationstates.net/pages/natio ... est.xml.gz


Seems to parse ok for me. I counted 2 nations in it.
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
Starrie
Attaché
 
Posts: 94
Founded: Jan 04, 2012
Ex-Nation

Postby Starrie » Fri Nov 15, 2013 10:23 pm

also parses perfectly for me. wonderful.
Last edited by Starrie on Fri Nov 15, 2013 10:27 pm, edited 1 time in total.

User avatar
Northrop-Grumman
Ambassador
 
Posts: 1748
Founded: Dec 28, 2003
Benevolent Dictatorship

Postby Northrop-Grumman » Sat Nov 16, 2013 6:42 am

It works well for me, too.

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

Postby Eluvatar » Sat Nov 16, 2013 12:01 pm

Could region history be added to the region API please?

The foremost reason I'm asking is that it would allow me a fool-proof way to distinguish incarnations of a region (without HTML scraping). (A region can after all be refounded with the same founder...) Exposing this information in the API, however, would also allow for a variety of uses of the information.
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby [violet] » Tue Nov 19, 2013 11:15 pm

Eluvatar wrote:Could region history be added to the region API please?

Done, as "history" shard for regions API.

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

Postby Shadow Afforess » Tue Nov 19, 2013 11:24 pm

[violet] wrote:Done, as "history" shard for regions API.

Speaking of API additions, Can whether the delegate of a region is an executive or not be added to the shards or daily dumps please? There is currently no way to determine this short from html scraping... :(
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 » Wed Nov 20, 2013 7:13 am

[violet] wrote:
Eluvatar wrote:Could region history be added to the region API please?

Done, as "history" shard for regions API.

:bow:

Thank you!

The following 4 nations listed in http://www.nationstates.net/cgi-bin/api ... /q=members are not WA nations:
  1. nucranova [page]
  2. cogiseke [page]
  3. kharkovsk [page]
  4. xacava [page]

(No WA members were missing from the WA members list :) )
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby Ballotonia » Wed Nov 20, 2013 11:45 am

Eluvatar wrote:
The following 4 nations listed in http://www.nationstates.net/cgi-bin/api ... /q=members are not WA nations:
  1. nucranova [page]
  2. cogiseke [page]
  3. kharkovsk [page]
  4. xacava [page]

(No WA members were missing from the WA members list :) )


Fixed, and thank you!

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 » Mon Dec 02, 2013 4:50 pm

Question: Does sending a telegram via the telegram API count as 1 request against the 50-requests-per-30-seconds rate limit? I know the telegram API has it's own rate limits, but I am trying to track down why I am exceeding the rate limit so often...

Edit: If that is not the cause, I would love help from an admin in tracking down why I hit the 15 minute cooldown so often (several times a day with NS++). I log each request and I am not making enough requests according to my logs to reach the rate limit. Clearly I am missing something.

Edit2: Ok I tested by just spam refreshing the example telegram API link in the NationStates API page and it definitely triggers the 50 request rate limit. So each telegram counts as 1 API request as well. :/
Last edited by Shadow Afforess on Mon Dec 02, 2013 8:57 pm, edited 4 times in total.
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 » Mon Dec 02, 2013 8:58 pm

Why wouldn't it?



I was slightly alarmed to see this event in the world happenings:

Code: Select all
<EVENT id="8144507">
<TIMESTAMP>1385571744</TIMESTAMP>
<TEXT><![CDATA[Regional bans expired.]]></TEXT>
</EVENT>


In context of course, it's the expiration of regional bans in Warzone Australia:

Code: Select all
<EVENT id="8144508">
<TIMESTAMP>1385571745</TIMESTAMP>
<TEXT><![CDATA[@@rileyapolis@@ seized the position of %%warzone_australia%% WA Delegate from @@wintercloak@@.]]></TEXT>
</EVENT>

<EVENT id="8144507">
<TIMESTAMP>1385571744</TIMESTAMP>
<TEXT><![CDATA[Regional bans expired.]]></TEXT>
</EVENT>


Nevertheless, could the text please be changed to the below, or similar, for the sake of clarity?

Code: Select all
<EVENT id="8144507">
<TIMESTAMP>1385571744</TIMESTAMP>
<TEXT><![CDATA[%%warzone_australia%% bans expired.]]></TEXT>
</EVENT>
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby Shadow Afforess » Mon Dec 02, 2013 9:18 pm

Eluvatar wrote:Why wouldn't it?

Because the Telegram API has a separate rate limit entirely. It seems redundant to also restrict it to the standard rate limit when the telegram API has it's own, unique limit...
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
[violet]
Executive Director
 
Posts: 16205
Founded: Antiquity

Postby [violet] » Tue Dec 03, 2013 9:14 pm

Eluvatar wrote:Nevertheless, could the text please be changed

Done, for messages logged from now on.

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Kamare, Kilogramonia, North American Imperial State, North-Bardonia, Orcland, Ramlethal, Republic of Libriano, Solaryia, Sudae, Veneke, Wadelhelpia

Advertisement

Remove ads