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
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Fri Apr 08, 2011 11:43 pm

No, there aren't. It's read-only.

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

Postby Could-Not-Care-Less » Sat Apr 09, 2011 11:52 am

So, no chance on getting NS into my Android? :-)

User avatar
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Sun Apr 10, 2011 6:44 pm

Not sure what you mean... you should be able to use the site fine on Android, either via the usual URL or http://m.nationstates.net.

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

Postby Could-Not-Care-Less » Thu Apr 14, 2011 2:40 pm

Sure, it works. However, I meant something more mobile-ish: an App, with either automatic checks on activity/issues, or using a push-to-device approach so one could get updates as they happen.

Although some of this might already be possible with the current API, some update methods would make the creation of such app a lot more viable. For instance, deciding on issues as they are pushed to the device. :-)

User avatar
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Sun Oct 16, 2011 5:45 pm

New, currently-undocumented API function:

http://www.nationstates.net/cgi-bin/api ... wnations=1

This lists the world's 50 newest nations, from newest to oldest. Anyone using this (or intending to), please let me know if it's useful.

User avatar
Unibot II
Senator
 
Posts: 3852
Founded: Jan 10, 2011
Ex-Nation

Postby Unibot II » Sun Oct 16, 2011 6:37 pm

[violet] wrote:New, currently-undocumented API function:

http://www.nationstates.net/cgi-bin/api ... wnations=1

This lists the world's 50 newest nations, from newest to oldest. Anyone using this (or intending to), please let me know if it's useful.


Should be dahm useful to make it easier for someone to create an recruitment script. Equality on recruitment seems preferable. Nice addition! ^_^
Vocenae wrote:Unibot, you have won NS.
General Halcones wrote:Look up to Unibot as an example.
Member of Gholgoth | The Capitalis de Societate of The United Defenders League (UDL) | Org. Join Date: 25/05/2008
Unibotian Factbook // An Analysis of NationStates Generations // The Gameplay Alignment Test // NS Weather // How do I join the UDL?
World Assembly Card Gallery // The Unibotian Life Expectancy Index // Proudly Authored 9 GA Res., 14 SC Res. // Commended by SC#78;
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Duty is Eternal, Justice is Imminent: UDL

User avatar
Mahaj
Senator
 
Posts: 4110
Founded: Dec 08, 2009
Ex-Nation

Postby Mahaj » Sun Oct 16, 2011 6:52 pm

Any chance you could make a link to the nations in there? No? Well this is great anyway :)
Aal Izz Well: UDL
<Koth> I'm still going by the assumption that Mahaj is Unibot's kid brother or something
Kandarin(Naivetry): You're going to have a great NS career ahead of you if you want it, Mahaj. :)
<@Eluvatar> Why is SkyDip such a purist raiderist
<+frattastan> Because his region was never raided.
<+maxbarry> EarthAway: I guess I might dabble in raiding just to experience it better, but I would not like to raid regions of natives, so I'd probably be more interested in defense and liberations

User avatar
Ballotonia
Site Admin
 
Posts: 5452
Founded: Antiquity
New York Times Democracy

Postby Ballotonia » Sun Oct 16, 2011 11:17 pm

Mahaj wrote:Any chance you could make a link to the nations in there? No? Well this is great anyway :)


XML files don't have links in them at all. What you're asking for is a webpage as part of the game :p

How about a page with the last X entrants into the WA? I can see that being useful.

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

User avatar
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Mon Oct 17, 2011 2:04 pm

Yep, I will probably throw that up. Just wanted to get a feel for how this would/wouldn't affect invader politics, etc.

I aim to provide a much better interface for recruiters, but it has to wait on the TG overhaul, since it's connected with mass TGs.

Edit: Sorry, by "that" I meant an HTML page with the newest nations on it.

An API or web page for newest WA nations wouldn't be hard to add, either; if there will be significant invader/defender implications from that, please start a thread. (I'm guessing no, since well-organized people have little trouble gathering that info already, right?)
Last edited by [violet] on Mon Oct 17, 2011 2:07 pm, edited 1 time in total.

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

Postby NewTexas » Mon Oct 17, 2011 4:58 pm

While it appears that work is being done on the API...

NewTexas and New South Hell would like to respectfully ask if you can revisit adding Embassies to the Region XML Feeds: viewtopic.php?p=5253313#p5253313

We been very patient for 6 months. :)

:ugeek:
Big Tex
Governor of Texas

Author: NSDossier

User avatar
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Mon Oct 17, 2011 8:09 pm

Wow, I forgot all about that. That's been ready to go for months. You should really pester me more often.

So: we are now on API VERSION 2. What this means for script-writers is documented on the API page.

Changes from API v1 to v2:
  • On nation pages, nations are tagged as "<NATION>", not "<NATIONINFO>".
  • On region pages, regions are tagged as "<REGION>", not "<REGIONINFO>".
  • Region pages have an "<EMBASSIES>" tag. Embassies are bracketed by the "<EMBASSY>" tag which can optionally be of a "pending" or "closing" type.
Last edited by [violet] on Mon Oct 17, 2011 8:09 pm, edited 1 time in total.

User avatar
Unibot II
Senator
 
Posts: 3852
Founded: Jan 10, 2011
Ex-Nation

Postby Unibot II » Mon Oct 17, 2011 8:11 pm

[violet] wrote:An API or web page for newest WA nations wouldn't be hard to add, either; if there will be significant invader/defender implications from that, please start a thread. (I'm guessing no, since well-organized people have little trouble gathering that info already, right?)


As far as I know there are rumours about TITO having said script already and UDL could cook one up in a couple of hours if we wanted already, between the 3+ coders we have in the group. Since it would only show WA nations joining, this would mean it would change less frequently then the World Assembly happenings, which mean the rate of access could be slowed down more so than current scripts without much fear of missing stuff..

EDIT: Embassies awesome.. cookies to anyone who creates a diagram of regions over 30 nations pop, connected by their embassies. :P
Vocenae wrote:Unibot, you have won NS.
General Halcones wrote:Look up to Unibot as an example.
Member of Gholgoth | The Capitalis de Societate of The United Defenders League (UDL) | Org. Join Date: 25/05/2008
Unibotian Factbook // An Analysis of NationStates Generations // The Gameplay Alignment Test // NS Weather // How do I join the UDL?
World Assembly Card Gallery // The Unibotian Life Expectancy Index // Proudly Authored 9 GA Res., 14 SC Res. // Commended by SC#78;
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Duty is Eternal, Justice is Imminent: UDL

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

Postby NewTexas » Mon Oct 17, 2011 9:13 pm

Thank you, we think...

Didn't read this part before asking:

Note: The Daily Data Dumps are always compiled in the current API version—there is no way to retrieve a Data Dump in an older API version format, sorry.


:o

We may be out of order for a day or so until we adapt.

Uni, you better go to the store Dude, there will be some 19.053 billion NewTexans looking for those cookies soon...

:ugeek:
Big Tex
Governor of Texas

Author: NSDossier

User avatar
Unibot II
Senator
 
Posts: 3852
Founded: Jan 10, 2011
Ex-Nation

Postby Unibot II » Mon Oct 17, 2011 9:15 pm

NewTexas wrote:Uni, you better go to the store Dude, there will be some 19.053 billion NewTexans looking for those cookies soon...

:ugeek:


My private stash for bribes. :P
Vocenae wrote:Unibot, you have won NS.
General Halcones wrote:Look up to Unibot as an example.
Member of Gholgoth | The Capitalis de Societate of The United Defenders League (UDL) | Org. Join Date: 25/05/2008
Unibotian Factbook // An Analysis of NationStates Generations // The Gameplay Alignment Test // NS Weather // How do I join the UDL?
World Assembly Card Gallery // The Unibotian Life Expectancy Index // Proudly Authored 9 GA Res., 14 SC Res. // Commended by SC#78;
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Duty is Eternal, Justice is Imminent: UDL

User avatar
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Wed Nov 09, 2011 9:48 pm

I'm testing a new way of accessing the API: requesting "shards" of data. This lets you only look up the info you're interested in.

You just append "&q=" to the nation name plus a string of data items you want separated by "+" signs. Illustration by way of examples:
This lets me add neat new stuff to the API without worrying about slowing down everyone who doesn't need it.

Feedback please!

User avatar
New South Hell
Spokesperson
 
Posts: 161
Founded: Feb 15, 2008
Ex-Nation

Postby New South Hell » Thu Nov 10, 2011 4:35 am

Makes me happy. :clap: As soon as this is official, I'll be changing my code to ask for just what I want.

A few quick comments. It appears in general the &q token is the same as the XML entity name. But, by experiment, &q=deaths doesn't work, you have to use &q=death. And I couldn't find the magic code (if there is one) for either the government budget information as a whole or for a single component (I tried &q=govt, &q=budget, &q=spending and &q=welfare). And your example for me showed admirable, which I didn't actually ask for (though of course I have no objection to its being there), but did not show the government attributes (e.g., "omnipresent, pro-business"), which I did want. It might be possible to get those already, but if so, I don't have a guess at the keyword.

Of course, once this is documented, the keywords can be anything, but right now we have to guess. :)

User avatar
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Thu Nov 10, 2011 5:27 am

Fixed those keywords ('deaths' and 'govt').

The "government attributes" one is non-trivial, because they are not generated on their own like that. I can give you the entire sentence, though (e.g. "It is difficult to tell where the omnipresent, corrupt, moralistic government stops and the rest of society begins").

Keywords as of right now:
Code: Select all
name
type
fullname
motto
category
wa
endorsements
gavote
scvote
freedom
region
population
tax
animal
animaltrait
currency
flag
majorindustry
crime
sensibilities
govtpriority
govt
notable
admirable
founded
firstlogin
lastlogin
lastactivity
influence
freedomscores
publicsector
deaths
leader
capital
religion

User avatar
New South Hell
Spokesperson
 
Posts: 161
Founded: Feb 15, 2008
Ex-Nation

Postby New South Hell » Thu Nov 10, 2011 6:03 am

The sentence would be fine. :bow: It can be a very complicated sentence, so I understand the difficulty. (So complicated I think a verb or two sometimes gets lost when a "small group of individuals" is involved.)

Thanks for all this (and for all the bits yet to come)!

User avatar
Cerberion
Diplomat
 
Posts: 993
Founded: Apr 22, 2010
Corporate Police State

Postby Cerberion » Thu Nov 10, 2011 12:47 pm

Like this change a lot. Should speed up some of my scripts by a ton.

User avatar
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Thu Nov 10, 2011 6:28 pm

I've added some more shard stuff, and shifted the documentation to its own page:

http://www.nationstates.net/pages/api.html

User avatar
Riemstagrad
Diplomat
 
Posts: 978
Founded: Antiquity
Anarchy

Postby Riemstagrad » Fri Nov 11, 2011 3:43 am

looks good!

one question though: will the extra data like (wcensus, rcensus, notable etc...) be included in the daily data-dump? i think these are more interesting for a daily dump then the never-changing 'firstlogin' and 'founded' and the (for daily-dump) not accurate 'lastlogin' and 'lastactivity'

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

Postby NewTexas » Fri Nov 11, 2011 5:57 am

[violet] we would just like to say this is a great idea! :bow:

We can imagine all kinds of tools we could create with it.

BTW, can this thread be pinned or stickied to the top of this forum? Sometimes it is hard to find. Thank you.

:geek:
Big Tex
Governor of Texas

Author: NSDossier

User avatar
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Fri Nov 11, 2011 5:17 pm

Riemstagrad wrote:will the extra data like (wcensus, rcensus, notable etc...) be included in the daily data-dump? i think these are more interesting for a daily dump then the never-changing 'firstlogin' and 'founded' and the (for daily-dump) not accurate 'lastlogin' and 'lastactivity'

Hmm, it depends. In the interests of keeping the daily update as fast as possible, it's good to keep the dumps free of slow-to-generate info. Some things, like 'lastlogin', are essentially free to include, because we're just including a pre-calculated value. Things that need to be calculated on the fly, though, are better kept out of the dumps unless we're pretty confident that they'll be useful.

So: not sure yet. It depends on what people need.

User avatar
Tears
Political Columnist
 
Posts: 2
Founded: Nov 02, 2011
Ex-Nation

Bug!

Postby Tears » Fri Nov 11, 2011 5:21 pm

[violet] wrote:Fixed those keywords ('deaths' and 'govt').

The "government attributes" one is non-trivial, because they are not generated on their own like that. I can give you the entire sentence, though (e.g. "It is difficult to tell where the omnipresent, corrupt, moralistic government stops and the rest of society begins").

Keywords as of right now:
Code: Select all
name
type
fullname
motto
category
wa
endorsements
gavote
scvote
freedom
region
population
tax
animal
animaltrait
currency
flag
majorindustry
crime
sensibilities
govtpriority
govt
notable
admirable
founded
firstlogin
lastlogin
lastactivity
influence
freedomscores
publicsector
deaths
leader
capital
religion


I found a bug!

I made a simple program to get all the major industries, populations, and economy ratings of the nations in a region. It worked a couple of times so then I decided to see what would happen if I ran it on the North Pacific. On one particular http://www.nationstates.net/cgi-bin/api.cgi?nation=${nation}&q=majorindustry+population+freedomscores , I got:

<!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>Can't locate object method &quot;query&quot; via package &quot;No nation name supplied!&quot; (perhaps you forgot to load &quot;No nation name supplied!&quot;?) at /home/nation/public_html/cgi-bin/JClass.pm line 614.
at /home/nation/public_html/cgi-bin/JGConfig.pm line 13
JGConfig::__ANON__('Can\'t locate object method &quot;query&quot; via package &quot;No nation na...') called at /home/nation/public_html/cgi-bin/JClass.pm line 614
JClass::query_real_name('No nation name supplied!', undef) called at /home/nation/public_html/cgi-bin/JClass.pm line 400
JClass::load('Region', undef) called at /home/nation/public_html/cgi-bin/Dynamic.pm line 444
Dynamic::load_regions('Nation=HASH(0x7fcb631f6fd8)', 'HASH(0x7fcb63210360)') called at /home/nation/public_html/cgi-bin/Dynamic.pm line 217
Dynamic::generate_page('Nation=HASH(0x7fcb631f6fd8)', 'nationsharddata', 'HASH(0x7fcb63210360)') called at /home/nation/public_html/cgi-bin/api.cgi line 138
ModPerl::ROOT::ModPerl::RegistryBB::home_nation_public_html_cgi_2dbin_api_2ecgi::handler('Apache2::RequestRec=SCALAR(0x7fcb632ba758)') called at /usr/lib/perl5/ModPerl/RegistryCooker.pm line 204
eval {...} called at /usr/lib/perl5/ModPerl/RegistryCooker.pm line 204
ModPerl::RegistryCooker::run('ModPerl::RegistryBB=HASH(0x7fcb629b4da0)') called at /usr/lib/perl5/ModPerl/RegistryCooker.pm line 170
ModPerl::RegistryCooker::default_handler('ModPerl::RegistryBB=HASH(0x7fcb629b4da0)') called at /usr/lib/perl5/ModPerl/RegistryBB.pm line 31
ModPerl::RegistryBB::handler('ModPerl::RegistryBB', 'Apache2::RequestRec=SCALAR(0x7fcb632ba758)') called at -e line 0
eval {...} called at -e line 0
</pre>
</body>
</html>
Last edited by Tears on Fri Nov 11, 2011 5:21 pm, edited 1 time in total.

User avatar
[violet]
Site Admin
 
Posts: 15655
Founded: Antiquity

Postby [violet] » Wed Nov 16, 2011 5:18 pm

Tears wrote:I found a bug!

I made a simple program to get all the major industries, populations, and economy ratings of the nations in a region. It worked a couple of times so then I decided to see what would happen if I ran it on the North Pacific. On one particular http://www.nationstates.net/cgi-bin/api.cgi?nation=${nation}&q=majorindustry+population+freedomscores , I got:

Which particular nation was that?

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Alice White, Artevenia, Head Chembaron, Meadowfields

Advertisement

Remove ads