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
The Most Glorious Hack
Retired Moderator
 
Posts: 2427
Founded: Mar 11, 2003
Anarchy

Postby The Most Glorious Hack » Thu May 06, 2010 12:20 am

[violet] wrote:Possibly fixed for update in 22 hours from now, but possibly not because I'm not really sure what's going on.

Remind me again how you got this job? :p
Now the stars they are all angled wrong,
And the sun and the moon refuse to burn.
But I remember a message,
In a demon's hand:
"Dread the passage of Jesus, for he does not return."

-Nick Cave and the Bad Seeds, "Time Jesum Transeuntum Et Non Riverentum"



User avatar
New Spartzerina
Envoy
 
Posts: 226
Founded: Nov 22, 2009
Ex-Nation

Postby New Spartzerina » Thu May 06, 2010 2:18 am

The Most Glorious Hack wrote:
[violet] wrote:Possibly fixed for update in 22 hours from now, but possibly not because I'm not really sure what's going on.

Remind me again how you got this job? :p

[violet] is actually Max Barry? :p
New main nation! Spartzerium

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

Postby [violet] » Thu May 06, 2010 4:22 pm

The Most Glorious Hack wrote:
[violet] wrote:Possibly fixed for update in 22 hours from now, but possibly not because I'm not really sure what's going on.

Remind me again how you got this job? :p

It was my winning personality. Now shut the hell up.

Should be fixed now. Was a dodgy setting in Apache's mod_deflate.

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

Postby [violet] » Thu May 06, 2010 5:17 pm

Also updated API help text.

Lemme know if there are more third-party sites you'd like added to the Examples!

User avatar
The Mindset
Envoy
 
Posts: 267
Founded: Antiquity
Ex-Nation

Postby The Mindset » Fri May 07, 2010 10:32 am

Just to let you know that I may be pulling the allnations feed about once per week for my Nationstates Galaxy application (I don't need the nation details, I just want to check that a specific nation exists) so I dunno if that'd be sufficient reason to refrain from removing it. Alternatively, a new API call designed specifically to check if a nation exists, without any associated overhead of stats etc. (instead of having to download all nations, 99% of which I don't need) would be useful.

User avatar
Mayor For Life
Spokesperson
 
Posts: 126
Founded: Oct 06, 2008
Ex-Nation

Postby Mayor For Life » Fri May 07, 2010 2:04 pm

W00t! Elegant resolution of the API server load quandry. William of Ockham would certainly approve.
:clap:

The data mining has already begun at the New South Hell School of NationStates Ideology.
:D

As is the predictable head scratching, bickering over unfounded hypotheses, and players staring at the data like a canary looking in a mirror.
:rofl:


Mayor for Life
Founder of Ulthar

User avatar
The Mindset
Envoy
 
Posts: 267
Founded: Antiquity
Ex-Nation

Postby The Mindset » Fri May 07, 2010 3:13 pm

I'd like to note that the allnations feed seems to be broken, it stops at nation 10616 (in the mid-C's, alphabetically). It was working earlier today.

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

Postby [violet] » Fri May 07, 2010 4:25 pm

The Mindset wrote:Just to let you know that I may be pulling the allnations feed about once per week for my Nationstates Galaxy application (I don't need the nation details, I just want to check that a specific nation exists) so I dunno if that'd be sufficient reason to refrain from removing it. Alternatively, a new API call designed specifically to check if a nation exists, without any associated overhead of stats etc. (instead of having to download all nations, 99% of which I don't need) would be useful.

There's not much difference from our point of view between a real-time call to check if a nation exists and actually giving you all the stats on that nation.

If you only need to be doing this once a week, could you just grab nations.xml.gz Daily Dump and pull the nation names from there? Should be the same thing, just a larger download than you really need.

I probably need to convert the Name Lists to static files if we're going to keep them, due to the bug you mentioned above, but since I'm lazy if I can just drop them I will.

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

Postby [violet] » Fri May 07, 2010 4:26 pm

Mayor For Life wrote:W00t! Elegant resolution of the API server load quandry. William of Ockham would certainly approve.
:clap:

The data mining has already begun at the New South Hell School of NationStates Ideology.
:D

As is the predictable head scratching, bickering over unfounded hypotheses, and players staring at the data like a canary looking in a mirror.
:rofl:

Ahaha, great stuff as always!

User avatar
The Mindset
Envoy
 
Posts: 267
Founded: Antiquity
Ex-Nation

Postby The Mindset » Fri May 07, 2010 4:52 pm

[violet] wrote:
The Mindset wrote:Just to let you know that I may be pulling the allnations feed about once per week for my Nationstates Galaxy application (I don't need the nation details, I just want to check that a specific nation exists) so I dunno if that'd be sufficient reason to refrain from removing it. Alternatively, a new API call designed specifically to check if a nation exists, without any associated overhead of stats etc. (instead of having to download all nations, 99% of which I don't need) would be useful.

There's not much difference from our point of view between a real-time call to check if a nation exists and actually giving you all the stats on that nation.

If you only need to be doing this once a week, could you just grab nations.xml.gz Daily Dump and pull the nation names from there? Should be the same thing, just a larger download than you really need.

I probably need to convert the Name Lists to static files if we're going to keep them, due to the bug you mentioned above, but since I'm lazy if I can just drop them I will.

Fair enough, whatever's best on your end!

User avatar
The Mindset
Envoy
 
Posts: 267
Founded: Antiquity
Ex-Nation

Postby The Mindset » Sat May 08, 2010 9:32 am

The Mindset wrote:
[violet] wrote:
The Mindset wrote:Just to let you know that I may be pulling the allnations feed about once per week for my Nationstates Galaxy application (I don't need the nation details, I just want to check that a specific nation exists) so I dunno if that'd be sufficient reason to refrain from removing it. Alternatively, a new API call designed specifically to check if a nation exists, without any associated overhead of stats etc. (instead of having to download all nations, 99% of which I don't need) would be useful.

There's not much difference from our point of view between a real-time call to check if a nation exists and actually giving you all the stats on that nation.

If you only need to be doing this once a week, could you just grab nations.xml.gz Daily Dump and pull the nation names from there? Should be the same thing, just a larger download than you really need.

I probably need to convert the Name Lists to static files if we're going to keep them, due to the bug you mentioned above, but since I'm lazy if I can just drop them I will.

Fair enough, whatever's best on your end!

Actually, for what I need (nation names only) the nations.xml.gz dump has insane overhead - downloading and parsing out the useless bits pushes PHP's memory limits right to the brink and breaks completely very often. Perhaps a gz of allnations?

User avatar
The Mindset
Envoy
 
Posts: 267
Founded: Antiquity
Ex-Nation

Postby The Mindset » Mon May 10, 2010 8:06 am

I got it working with acceptable overhead for a weekly download. However, while googling for something related to Nationstates, I noticed that Google has indexed nations.xml.gz. You might want to bar the crawler access via robots.txt in case it trawls regularly.

User avatar
Jumping Jupiters
Envoy
 
Posts: 333
Founded: Apr 17, 2010
Ex-Nation

Postby Jumping Jupiters » Tue May 11, 2010 12:33 am

[violet] wrote:Hmm, odd. The file is not double-zipped, but it winds up that way on your computer when you download it via HTTP.


CanI ask a question, the bots that roam around on polls, what does that do for the site's benifit
How to live a great life:
Lacky: I suggest becoming a professional drunk, its a lot like the military.
Consaria:Become a terrorist for a cause you care about.
North Wiedna: Breasts?

User avatar
North Mack
Ambassador
 
Posts: 1213
Founded: Apr 27, 2005
Ex-Nation

Postby North Mack » Tue May 11, 2010 6:40 am

Jumping Jupiters wrote:
[violet] wrote:Hmm, odd. The file is not double-zipped, but it winds up that way on your computer when you download it via HTTP.


CanI ask a question, the bots that roam around on polls, what does that do for the site's benifit


Wow I am astounded both by the off topic-ness of that question, plus the sheer mind boggling non-sequitur of quoting that particular sentence (which has nothing to do with bots)

BUT what they do is index the site so we can do all those fancy things like search on google for a Nationstates thread. Otherwise google / yahoo / msn wouldn't know we were here at all.
T H E S T E L L A R R E P U B L I C O F N O R T H M A C K
Forged in Fire, Reforged in Blood
[ DeviantArt | NS FT Discord | The Local Cluster | FT Advice and Assistance Thread | The State of the Galaxy ]

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

Postby NewTexas » Thu Jun 10, 2010 4:56 pm

Can we pin this or something similar to this? We think developers might find it useful or at least informational.

We realize the site has been having some problems lately (read something about Apache probs). We are also wondering if you want to know about general wonkiness (ie: 421 Unused Errors on the feeds). There were a lot today!

:blink:

Edit: spelling error
Last edited by NewTexas on Thu Jun 10, 2010 4:58 pm, edited 1 time in total.
Big Tex
Governor of Texas

Author: NSDossier

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

Postby [violet] » Thu Jun 10, 2010 6:10 pm

NewTexas wrote:general wonkiness (ie: 421 Unused Errors

421 errors don't signify wonkiness. The API returns 421 ("Too Many Requests From Your IP Address") if you've been temporarily banned for exceeding the rate limit.

NewTexas wrote:Can we pin this or something similar to this? We think developers might find it useful or at least informational.

I'd like to put essential info on the actual API page, and that contains a link to the Technical forum. Linking to this particular thread might not be that helpful because it contains some discussion that's now obsolete.

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

Postby NewTexas » Fri Jun 11, 2010 4:46 am

[violet] wrote:
NewTexas wrote:general wonkiness (ie: 421 Unused Errors

421 errors don't signify wonkiness. The API returns 421 ("Too Many Requests From Your IP Address") if you've been temporarily banned for exceeding the rate limit.


:palm: D'oh, that is what that means! Ok, that explains a lot. Thank you.
Big Tex
Governor of Texas

Author: NSDossier

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

Postby [violet] » Fri Jun 11, 2010 4:59 pm

Heh, you're welcome. :)

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

Postby [violet] » Tue Mar 22, 2011 4:01 pm

Update! API versions!

Please note the API now lets you request a particular version number, so I can upgrade it in the future without breaking everyone's scripts. There is a hopefully comprehensive explanation at http://www.nationstates.net/cgi-bin/api.cgi

I am planning to change the API format soon, so now is an excellent time to build that version parameter into your scripts!

User avatar
Standica
Secretary
 
Posts: 39
Founded: Sep 05, 2009
Ex-Nation

Postby Standica » Tue Mar 22, 2011 4:23 pm

Excellent update. Thanks :)

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

Postby Ballotonia » Wed Mar 23, 2011 11:55 am

[violet] wrote:Update! API versions!

Please note the API now lets you request a particular version number, so I can upgrade it in the future without breaking everyone's scripts. There is a hopefully comprehensive explanation at http://www.nationstates.net/cgi-bin/api.cgi

I am planning to change the API format soon, so now is an excellent time to build that version parameter into your scripts!


For me, this link flip-flops between a 404 error, it trying to save a .cgi file on my computer, and this error:
Code: Select all
<!DOCTYPE html
   PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Oh-oh...</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Error!</h1><p>Sorry, NationStates has encountered an error. This problem has been logged and will be looked at shortly. If it occurs repeatedly, though, you can help us track it down by telling us what you did to reach this message. Please e-mail <a href="mailto:admin@nationstates.net">admin@nationstates.net</a>, giving this error message, the time and date it occurred, and what you were attempting to do. </p><p>Alternately, you can post this as a bug report in the <a href="http://forum.nationstates.net/viewforum.php?f=15">NationStates Technical Forum</a>. Thanks.</p><h3>Details:
</h3><pre>slurp_filename('/home/nation/public_html/cgi-bin/api.cgi') / opening: (2) No such file or directory at /usr/lib/perl5/ModPerl/RegistryCooker.pm line 541 at /home/nation/public_html/cgi-bin/JGConfig.pm line 13
   JGConfig::__ANON__('APR::Error=HASH(0x7f5f541ac950)') called at /usr/lib/perl5/ModPerl/RegistryCooker.pm line 541
   eval {...} called at /usr/lib/perl5/ModPerl/RegistryCooker.pm line 541
   ModPerl::RegistryCooker::read_script('ModPerl::RegistryBB=HASH(0x7f5f542210d0)') called at /usr/lib/perl5/ModPerl/RegistryCooker.pm line 371
   ModPerl::RegistryCooker::convert_script_to_compiled_handler('ModPerl::RegistryBB=HASH(0x7f5f542210d0)') called at /usr/lib/perl5/ModPerl/RegistryCooker.pm line 163
   ModPerl::RegistryCooker::default_handler('ModPerl::RegistryBB=HASH(0x7f5f542210d0)') called at /usr/lib/perl5/ModPerl/RegistryBB.pm line 31
   ModPerl::RegistryBB::handler('ModPerl::RegistryBB', 'Apache2::RequestRec=SCALAR(0x7f5f541a8e58)') called at -e line 0
   eval {...} called at -e line 0
</pre>
</body>
</html>‹������MQËnÂ0¼û+¶œ)¦œ£¨*P
‡ôÐã&YK~P{C•¿¯m"Ú“÷1;³ã-6ÇuõuÚÂ[uØÃéóe¿[ÃìQÊݶz•rSmnÕb)åöcVŠ¢g£Ë¢'lcŠ5•«åŽï…¼e¢¹[Ô®ÓÀS™šñÅ¥¬z‚@þJÈ6n°LžZ@ *…5÷΃ó¨Ð8{VÝà‘•³ÕÂ,Öš€4Î\41‰Ñ
<}xQÈK;iÂ@dþÓÆÖ(«Gbççâ–?Û,™ÂÂgAeÏΛ4lÀ3   +C9˜VmšÁGs‘ðhGî•í ®Fu=CW‚ÖÙ4„ Ç\
!š¿3Ý?8O“ðä¼vC2 ¤™8j¼¢Òé3„²ÿýÝ@Úu¥ÌLjWH׿f‰FÃø��


The file contains the same message, but with different binary garbage at the end.

Ballotonia
Last edited by Ballotonia on Wed Mar 23, 2011 11:57 am, edited 1 time in total.
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
Wopruthien
Chargé d'Affaires
 
Posts: 475
Founded: Dec 05, 2007
Democratic Socialists

Postby Wopruthien » Wed Mar 23, 2011 1:15 pm

Ninja'd by Ballotonia.

I get a similar message.
Former Arch Chancellor of the The Founderless Regions Alliance
General of the Alliance
Founder of Mordor

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

Postby [violet] » Wed Mar 23, 2011 3:01 pm

I had to take down the API temporarily due to our network issues. Back up now.

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

Postby [violet] » Tue Apr 05, 2011 4:36 pm

[violet] wrote:Update! API versions!

Please note the API now lets you request a particular version number, so I can upgrade it in the future without breaking everyone's scripts. There is a hopefully comprehensive explanation at http://www.nationstates.net/cgi-bin/api.cgi

I am planning to change the API format soon, so now is an excellent time to build that version parameter into your scripts!

As per the API documentation, the Daily Data Dumps will be getting a version number very soon!

That is, instead of looking like this:
Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>

<REGIONS>
<REGION>
<NAME>The East Pacific</NAME>
...
</REGIONS>

... they will look like this:
Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>

<REGIONS api_version="1">
<REGION>
<NAME>The East Pacific</NAME>
...
</REGIONS>


If this is going to bust your script/site, please take action now.

Also, if you haven't already built in an API version number to your Nation & Region API requests, you should do that ASAP, as they will be moving to version 2 soon.

Please post any questions! I'm happy to help with the change.

User avatar
Could-Not-Care-Less
Political Columnist
 
Posts: 3
Founded: Apr 07, 2011
Ex-Nation

Postby Could-Not-Care-Less » Fri Apr 08, 2011 7:44 pm

Out of curiosity, are there any plans on implementing API methods to allow modifying key aspects of a nation (i.e., dealing with issues, replying to telegrams, etc.)?

Cheers.

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Indian Lands

Advertisement

Remove ads