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
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Sat Oct 25, 2014 11:00 pm

Babylatia wrote:When I use the https://www.nationstates.net/cgi-bin/api.cgi?nation=Babylatia with PHP, I get an error with the '&' in 'Law & Order' because it is not '&'.

Showing us the code would help.

As far as I can see, it is '&' in what NS returns.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Aurum Rider
Envoy
 
Posts: 297
Founded: Dec 23, 2013
Corporate Police State

Postby Aurum Rider » Sun Oct 26, 2014 7:58 am

It has likely that this has been asked before, but I couldn't find it.
As I understand it, through the NSAPI you can only call one entry of census data using censusscore-n (I.E in one call you can ask for insurance, but need another call entirely for rudeness). In addition to this, could a "censusdump" shard for nations be added that dumps all of the nation's census data tagged by the industry ID?
The reason for this being, that if I want to show a chart with all of a nation's census data to give an overall look at how the nation is doing, I have to make 71 API calls, which will launch me right over the rate limit.

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

Postby Eluvatar » Sun Oct 26, 2014 10:55 am

Aurum Rider wrote:It has likely that this has been asked before, but I couldn't find it.
As I understand it, through the NSAPI you can only call one entry of census data using censusscore-n (I.E in one call you can ask for insurance, but need another call entirely for rudeness). In addition to this, could a "censusdump" shard for nations be added that dumps all of the nation's census data tagged by the industry ID?
The reason for this being, that if I want to show a chart with all of a nation's census data to give an overall look at how the nation is doing, I have to make 71 API calls, which will launch me right over the rate limit.

Incorrect, you can combine shards, i.e.

http://www.nationstates.net/cgi-bin/api ... susscore-4
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Ermarian
Minister
 
Posts: 2783
Founded: Jan 11, 2004
Democratic Socialists

Postby Ermarian » Tue Nov 04, 2014 5:03 am

Could you do the same for multiple nations? When I am comparing several nations or keeping tabs on my puppets, it's inconvenient to have to make a dozen requests and throttle them, rather than combine them into a single request. I suspect it would also save a lot of overhead on the server side.

The XML schema might cause some issues, since <NATION> is seemingly a root element. Serving data on multiple nations would require some <NATIONS> super-element, I guess.
The Endless Empire of Ermarian | Jolt Archives | Encyclopedia Ermariana | ( -6.38 | -8.56 ) | Luna is best pony.
"Without deeper reflection one knows from daily life that one exists for other people - first of all for those upon whose smiles and well-being our own happiness is wholly dependent, and then for the many, unknown to us, to whose destinies we are bound by the ties of sympathy." -Einstein
"Is there a topic for discussion here, or did you just want to be wrong in public?" -Ifreann

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

Postby Eluvatar » Sat Nov 08, 2014 3:47 pm

Ermarian wrote:Could you do the same for multiple nations? When I am comparing several nations or keeping tabs on my puppets, it's inconvenient to have to make a dozen requests and throttle them, rather than combine them into a single request. I suspect it would also save a lot of overhead on the server side.

The XML schema might cause some issues, since <NATION> is seemingly a root element. Serving data on multiple nations would require some <NATIONS> super-element, I guess.

This has been asked about before. [violet] was interested in implementing multi-nation requests for certain shards, but was focusing on (I believe) the new TG system at the time. [violet] asked to be reminded if it didn't get done. I too would find such a feature interesting.

I've found that in certain circumstances, the Compare page is faster (rules-compliance wise) if you care about just one census. I would of course advise using template-overall=none to reduce the load on the server to just the compare page and nothing else (like recent forum topics).
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
HMS Unicorn
Spokesperson
 
Posts: 199
Founded: Jun 29, 2005
Ex-Nation

Postby HMS Unicorn » Tue Nov 11, 2014 7:29 am

I would also be interested in this feature. As Elu mentioned, frequently I end up using the Compare page as a rule-compliant substitute for a multiple-nation API call.

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

Postby Eluvatar » Wed Nov 12, 2014 4:41 pm

One might remember from earlier comments in this topic that there exist google docs that use the NS API, some (but not all) of which I wrote the code for.

I remembered today that I never did figure out a way to get them to set a User-Agent in googlescript, so I looked into that again. Apparently it's not possible yet, and they will always set the User-Agent "Mozilla/5.0 (compatible; GoogleDocs; script; +http://docs.google.com)".

Is there any alternative way of identifying the particular google document (script) making the request which can be applied instead? (i.e. documentid=0AjUCYljFPq3CdEtwc19aNTZJMWs ... @gmail.com or similar)

NB: They don't generally use the API that much: at most a hundred to two hundred requests when someone clicks a button, but usually far far less.
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby [violet] » Wed Nov 12, 2014 4:56 pm

Eluvatar wrote:This has been asked about before. [violet] was interested in implementing multi-nation requests for certain shards, but was focusing on (I believe) the new TG system at the time. [violet] asked to be reminded if it didn't get done. I too would find such a feature interesting.

Can you outline some usage cases for me?

In general, loading a nation is the slowest part of what we do, so it makes sense in terms of ratelimits to have one API call limited to one nation load. Otherwise, the ratelimits aren't really helping us. But there could be some cases where it's doable.

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

Postby [violet] » Wed Nov 12, 2014 4:57 pm

Eluvatar wrote:Is there any alternative way of identifying the particular google document (script) making the request which can be applied instead?

If you can't set the UserAgent, putting something informative in the URL's query string is definitely better than nothing.

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

Postby Eluvatar » Wed Nov 12, 2014 5:08 pm

[violet] wrote:
Eluvatar wrote:This has been asked about before. [violet] was interested in implementing multi-nation requests for certain shards, but was focusing on (I believe) the new TG system at the time. [violet] asked to be reminded if it didn't get done. I too would find such a feature interesting.

Can you outline some usage cases for me?

In general, loading a nation is the slowest part of what we do, so it makes sense in terms of ratelimits to have one API call limited to one nation load. Otherwise, the ratelimits aren't really helping us. But there could be some cases where it's doable.


The way I tend to use the API in new code I write right now, it would only be helpful in that I could get information faster.

In the past though I would have been interested in a way to get, say, the endorsement and influence information for the nations paid attention to by the TNP Security Council Alerts System in one simultaneous request, as opposed to 28 odd sequential requests. (Note: before the great influence flattening in feeders and sinkers, the top 25 nations by influence was a significantly different list from the top 25s by endorsements given or received, so the alerts system paid attention to significantly more nations, sometimes more than 50. Not anymore.)

I should be clear that while I think this would be nifty, this isn't a request I would 'vote for' if I had limited votes. I, personally, would be more interested in event IDs being added to the national and regional happenings, tags being added to the regions.xml dumps, or telegram meta-templates or other ways of sharing templates between nations.
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby Eluvatar » Wed Nov 12, 2014 5:17 pm

[violet] wrote:
Eluvatar wrote:Is there any alternative way of identifying the particular google document (script) making the request which can be applied instead?

If you can't set the UserAgent, putting something informative in the URL's query string is definitely better than nothing.

I'm updating all the active gdocs I have edit privileges in to add the below to all API request URLs: :)
Code: Select all
"&gdoc="+SpreadsheetApp.getActiveSpreadsheet().getId()+"&useremail="+Session.getUser().getUserLoginId()
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Sseroffa
Attaché
 
Posts: 92
Founded: Jan 30, 2010
Ex-Nation

Postby Sseroffa » Fri Nov 21, 2014 5:10 pm

I can't tell if this is by design, or a bug, so I thought I should note it. The new nation shards for factbooks and dispatches do not work for dead nations. This is despite the fact you can see these dispatches from the exfactbook page.

User avatar
Sseroffa
Attaché
 
Posts: 92
Founded: Jan 30, 2010
Ex-Nation

Postby Sseroffa » Fri Nov 21, 2014 5:11 pm

Also another notable absence. There is no way to fetch which dispatches are pinned to a region's WFE.

User avatar
Frisbeeteria
Senior Game Moderator
 
Posts: 27796
Founded: Dec 16, 2003
Capitalizt

Postby Frisbeeteria » Fri Nov 21, 2014 8:49 pm

Sseroffa wrote:I can't tell if this is by design, or a bug, so I thought I should note it. The new nation shards for factbooks and dispatches do not work for dead nations. This is despite the fact you can see these dispatches from the exfactbook page.

I suspect it's the way they're stored by design. Until very recently, even mods couldn't see exfactbooks except via the page=exfactbooks links. I'm sure it could be fixed, but I'm not sure of the value for the time involved.

User avatar
Sseroffa
Attaché
 
Posts: 92
Founded: Jan 30, 2010
Ex-Nation

Postby Sseroffa » Fri Nov 21, 2014 11:17 pm

Frisbeeteria wrote:
Sseroffa wrote:I can't tell if this is by design, or a bug, so I thought I should note it. The new nation shards for factbooks and dispatches do not work for dead nations. This is despite the fact you can see these dispatches from the exfactbook page.

I suspect it's the way they're stored by design. Until very recently, even mods couldn't see exfactbooks except via the page=exfactbooks links. I'm sure it could be fixed, but I'm not sure of the value for the time involved.

Statistically speaking, it will not take long before most factbooks are exfactbooks. Most nations just do not stay around long.

User avatar
Frisbeeteria
Senior Game Moderator
 
Posts: 27796
Founded: Dec 16, 2003
Capitalizt

Postby Frisbeeteria » Sat Nov 22, 2014 12:37 am

Sseroffa wrote:Statistically speaking, it will not take long before most factbooks are exfactbooks

Understood and agreed, but what is the value of an ex-factbook to anyone other than the creator? I understand that some people are driven to back up everything that's ever been posted, but apart from that mystifying drive, I can't see a value in referencing the factbooks ever again. There's a manual method if there's a genuine need, but I'm missing the reason for an API-driven request.

Sseroffa wrote:There is no way to fetch which dispatches are pinned to a region's WFE.

That one I can see as potentially having value. A pinned dispatch belonging to a CTE nation perhaps needs to be actively linked. Is that your only concern?

User avatar
Sseroffa
Attaché
 
Posts: 92
Founded: Jan 30, 2010
Ex-Nation

Postby Sseroffa » Sat Nov 22, 2014 10:40 am

I don't have any particular concerns, I don't play NS anymore. I thought the admins might care about being aware of two potential oversights. I don't really have any additional comments to make.

User avatar
Nuemark
Political Columnist
 
Posts: 3
Founded: Dec 26, 2011
Ex-Nation

Postby Nuemark » Sun Nov 23, 2014 4:33 am

[violet] wrote:
Rich and Corporations wrote:I second this.

Poll data is now available via Region and World shards!

World shard example


In the example above the "q=poll;pollid=6538"
If a poll is deleted from the WFE can it be retrieved if the ID is known?
Last edited by Nuemark on Sun Nov 23, 2014 4:38 am, edited 1 time in total.

User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Postby Nephmir » Thu Nov 27, 2014 6:03 pm

I'd like to import a list of regions by order of update time into excel. How would I go about doing this with the daily dumps? I can't seem to open the file, but I can save it.
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

User avatar
Ever-Wandering Souls
Negotiator
 
Posts: 7267
Founded: Jan 01, 2014
Father Knows Best State

Postby Ever-Wandering Souls » Thu Nov 27, 2014 6:16 pm

The daily dump should be in order of last update, IIRC, but it's just downloaded in a file format that's not supported by much. Personal, I convert it to a .zip and open in excel, but I'm sure there's other solutions. You're probably best off just asking google how to deal with the ... .gz, right? ....filetype.
Proud Raider; General of The Black Hawks, Ret.
TG me anytime; I'm always happy to talk about anything!

The Alicorns (Equestria) wrote:Let them stay, no need to badmouth them...From our view a bunch of nations just came in, seized the delegate position, and changed a few superficial things...we play NationStates differently...there's really no reason for us to be butthurt.
http://www.nationstates.net/page=rmb/postid=8944227
http://www.nationstates.net/page=rmb/postid=8951258

Misley wrote:
Hobbesistan wrote:Don't think I understand the question.
The color or what?..

Jesus, Hobbes, it's 2015. You can't just call someone "the color".

Reploid Productions wrote:Raiders are endlessly creative

How Do I Telegram API?

Omnis delenda est.

User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Postby Nephmir » Fri Nov 28, 2014 2:22 pm

'tis alright, I just used excel to analyze the RSS feeds and created the list from the embassy shard for... a region with a lot of founderless region embassies... instead. A few hundred regions will suffice, saves the filtering out the good ones from the bad ones.

Appreciate the response, though.
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Postby Nephmir » Sat Dec 06, 2014 8:25 am

I've been retrieving data from the API using an XML Filter. However I've noticed that there's no data for the number of endorsements on a nation other than the delegate. Is this intentional?
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

User avatar
Sseroffa
Attaché
 
Posts: 92
Founded: Jan 30, 2010
Ex-Nation

Postby Sseroffa » Sat Dec 06, 2014 8:46 pm

Nephmir wrote:I've been retrieving data from the API using an XML Filter. However I've noticed that there's no data for the number of endorsements on a nation other than the delegate. Is this intentional?

You can already get this information. Grab the list of endorsements a nations has (it's one of the nation shards) , and then just count the number of nation names listed. Pretty simple.

Ever-Wandering Souls wrote:The daily dump should be in order of last update, IIRC, but it's just downloaded in a file format that's not supported by much. Personal, I convert it to a .zip and open in excel, but I'm sure there's other solutions. You're probably best off just asking google how to deal with the ... .gz, right? ....filetype.


.gz is a gzipped-compressed file, which is fairly common, and 7z and other archive tools can handle it with no problems. Gzip compression was designed specifically to compress text and does so extremely well.
Last edited by Sseroffa on Sat Dec 06, 2014 8:48 pm, edited 2 times in total.

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

Postby Ballotonia » Sun Dec 07, 2014 2:06 am

Nephmir wrote:I've been retrieving data from the API using an XML Filter. However I've noticed that there's no data for the number of endorsements on a nation other than the delegate. Is this intentional?


Such a number isn't provided by the API. It provides a list of endorsers. So, this sounds to me like a problem with your XML filter.

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

User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Postby Nephmir » Sun Dec 07, 2014 6:06 am

Sseroffa wrote:
Nephmir wrote:I've been retrieving data from the API using an XML Filter. However I've noticed that there's no data for the number of endorsements on a nation other than the delegate. Is this intentional?

You can already get this information. Grab the list of endorsements a nations has (it's one of the nation shards) , and then just count the number of nation names listed. Pretty simple.

Ever-Wandering Souls wrote:The daily dump should be in order of last update, IIRC, but it's just downloaded in a file format that's not supported by much. Personal, I convert it to a .zip and open in excel, but I'm sure there's other solutions. You're probably best off just asking google how to deal with the ... .gz, right? ....filetype.


.gz is a gzipped-compressed file, which is fairly common, and 7z and other archive tools can handle it with no problems. Gzip compression was designed specifically to compress text and does so extremely well.

Oh yes, I see. It involves an extra step in the filter to first retrieve the names of the endorsers, and then I suppose I have to get it to give me the value of the endorsers as a number. I could probably do that in excel.

Thanks.
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: -Abrahamia-, Danternoust, Einaro, Geopolity, Grandocantorica, Mue, New Yi Empire, Shirahime, The United Kindom under Socialist Rule, Three Galaxies, Unionization of European Countries

Advertisement

Remove ads