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 blAAtschApen
Retired Moderator
 
Posts: 51193
Founded: Antiquity
Forumer Mod

Postby The blAAtschApen » Thu Feb 04, 2016 8:47 am

Caelapes wrote:I'm assuming it has to do with this:
[violet] wrote:Please note I have just banned some scripts from the API that were violating the Terms of Use, primarily by sending no UserAgent. I have also banned one UserAgent because the script has been exhibiting problems and the author as identified in the UserAgent didn't respond to email.

Affected scripts will receive a 403 status code from the API and an explanatory message. You can re-establish access by setting a valid unique UserAgent.

If that's the case, you'll need to set a useragent: https://joshtronic.com/2013/06/04/speci ... _contents/


This is correct.

I've just tested this. My script gets a 403 without, and a 200 (and the relevant data) when it has a user agent.

So set user agents :p
Former mod, now a rocker mocker. Thank you Ringo
Heaven is other people
Behind the invisible hand of the market hides the iron fist of the state.
Whenever you find yourself on the side of the majority, it is time to pause and reflect - Mark Twain
Silent is an anagram of listen.
Proud adopter of a lamb called violet: http://imgur.com/a/pxnSf
Male. Please address me as 'he'.
This is the 8th line. If your sig is longer than mine, it is too long.

User avatar
Eluvatar
Site Admin
 
Posts: 2165
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Thu Feb 04, 2016 9:05 am

It's only in the API terms of use...
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
The United Dominion
Spokesperson
 
Posts: 162
Founded: Oct 17, 2011
Inoffensive Centrist Democracy

Postby The United Dominion » Thu Feb 04, 2016 9:37 am

The Blaatschapen wrote:
Caelapes wrote:I'm assuming it has to do with this:

If that's the case, you'll need to set a useragent: https://joshtronic.com/2013/06/04/speci ... _contents/


This is correct.

I've just tested this. My script gets a 403 without, and a 200 (and the relevant data) when it has a user agent.

So set user agents :p


Yeah, I have no idea how I missed [violet]'s post on the subject. Added user-agent to a test call, works great. Now to update script.

Thanks, guys.
:: The Local Cluster :: Join Today! ::
:: "The Best Region for NSFT"™ ::
:: NSFT Community Discord Server ::

User avatar
Ambroscus Koth
Ambassador
 
Posts: 1842
Founded: May 06, 2012
Ex-Nation

Postby Ambroscus Koth » Thu Feb 04, 2016 9:42 am

Eluvatar wrote:It's only in the API terms of use...

Reading is for fendas >_>

I'll test this out again when I get home, thanks guys!
Last edited by Ambroscus Koth on Thu Feb 04, 2016 9:42 am, edited 1 time in total.
☀ Pharaoh Emeritus of Osiris (x2) ☀
Lieutenant of The Black Hawks | Sovereign General of the DEN
♥ Drunk married to Aurum Rider | Author of SC#172

Miniluv: Stability is Stagnation!

User avatar
Greater Tern
Envoy
 
Posts: 322
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Tue Feb 09, 2016 7:32 pm

I'm getting the following error for this API request: https://www.nationstates.net/cgi-bin/ap ... q=officers

This page contains the following errors:
error on line 24 at column 34: xmlParseEntityRef: no name
Below is a rendering of the page up to the first error.
bruination Cartographer A 1444981592 errinundera 5 frieden-und_freudenland Publicist AC 1451461971 errinundera 4 gil_zardon Foreign Minister EP 1445892658 errinundera 6 mozworld

That request corresponds to this page in the actual site.

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

Postby [violet] » Tue Feb 09, 2016 10:17 pm

^ Fixed, thanks for the report.

User avatar
Drachmaland
Chargé d'Affaires
 
Posts: 439
Founded: Dec 14, 2014
Civil Rights Lovefest

Postby Drachmaland » Wed Feb 10, 2016 3:53 pm

Is there any planned communication for API users of any new shards that will be introduced as part of the revamped census rankings?

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

Postby [violet] » Wed Feb 10, 2016 4:06 pm

Drachmaland wrote:Is there any planned communication for API users of any new shards that will be introduced as part of the revamped census rankings?

How do you mean? If you have questions, please fire away. It's hard for me to guess what API users want as everyone uses the API differently.

User avatar
Drachmaland
Chargé d'Affaires
 
Posts: 439
Founded: Dec 14, 2014
Civil Rights Lovefest

Postby Drachmaland » Wed Feb 10, 2016 4:10 pm

[violet] wrote:
Drachmaland wrote:Is there any planned communication for API users of any new shards that will be introduced as part of the revamped census rankings?

How do you mean? If you have questions, please fire away. It's hard for me to guess what API users want as everyone uses the API differently.

If there'll be new categories (and scales), then will also be new shards, no?
Also, the ranking starting being dynamic, how will the wcensus & rcensus be influenced?
And will there be shards for the regional trophies, as well?

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

Postby [violet] » Wed Feb 10, 2016 5:21 pm

New scales will be accessible via the existing "censusscore-N" nation shard, and "wcensus" and "rcensus" will continue to function as they do now, i.e. they'll return a nation's rank on whichever is that day's chosen World Census scale.

So everything should continue to work as it does now. As for new shards to access new data, such as world/region ranks on specified scales and regional trophies, these probably won't be there at feature launch, since I'm already expecting initial load issues, and I don't want to add bots on top of that. But I aim to add them in the near future.

If there's particular data or a particular format you'd like, let me know! As usual, stuff will get added to the API based on how much demand there seems to be for it.

User avatar
Greater Tern
Envoy
 
Posts: 322
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Thu Feb 11, 2016 6:41 pm

Got another API error, with the regional poll this time: https://www.nationstates.net/cgi-bin/ap ... ces&q=poll

This page contains the following errors:
error on line 3 at column 70: EntityRef: expecting ';'
Below is a rendering of the page up to the first error.
(RP) Should Zocra's province, Aravella, receive emergency funding from the region?


Page in question: http://www.nationstates.net/region=united_alliances

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

Postby [violet] » Thu Feb 11, 2016 7:55 pm

Should be fixed now, thanks again.

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

Postby [violet] » Sun Feb 14, 2016 5:31 pm

Of possible interest to script authors:

viewtopic.php?f=15&t=368514

User avatar
Trotterdam
Negotiator
 
Posts: 6948
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Mon Feb 15, 2016 9:21 pm

Drachmaland wrote:
Trotterdam wrote:Something I've been wanting for a while:

q=notables and q=admirables shards, which display all tags a nation currently qualifies for that could be returned by q=notable and q=admirable, rather than a randomized selection (much like q=banners does for q=banner).
I wholeheartedly second that.
It's been a month and two pages. Could we have a response on this? It's not vital, but it doesn't sound difficult to do.

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

Postby [violet] » Mon Feb 15, 2016 9:28 pm

Most of the time, when something doesn't get a response from me, it's because it's neither trivial nor impossible, and so whether it gets done depends on how much people seem to want it versus how much time I have. It's neither definitely yes nor definitely no.

It's a "not right now but feel free to make another case for it later" from me at the moment.

User avatar
Leppikania
Minister
 
Posts: 2278
Founded: Apr 13, 2015
Left-wing Utopia

Postby Leppikania » Thu Feb 18, 2016 5:20 pm

Typo in the API telegrams:
This is an API Template. To wire a copy to someone, make make an API request using the following information:

TGID: xxxxxxxx

Secret Key: xxxxxxxxxxxx

Do not share your Secret Key with anyone.

Note: You don't need to check the "recruitment" or "campaign" box every time you send a copy: the category is set by the template.

Also, don't know how, but a bunch of nations in my latest recruitment TG (14653596) appear in "queued" twice.
Last edited by Leppikania on Fri Feb 19, 2016 7:54 am, edited 1 time in total.
INTP, -4.25 Economic Left/Right, -4.1 Social Libertarian/Authoritarian, tastes like chicken.
I do use NS stats, thank you very much.
Funny Quotes
Pie charts for industries
Request an Embassy

User avatar
Greater Tern
Envoy
 
Posts: 322
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Fri Mar 04, 2016 5:14 pm

Are there any plans to make the nation/region census rankings, trophies and history available through the API?

While I'm at it, would it be possible to get the following data from the API as well:

- These parts of the nation description:
The Union Commonwealth of Greater Tern is a colossal, cultured nation, ruled by Praetor Sal Bernkastel with a fair hand, and remarkable for its national health service, unlimited-speed roads, and keen interest in outer space. The compassionate, democratic, cheerful, devout population of 7.481 billion Ternans hold their civil and political rights very dear, although the wealthy and those in business tend to be viewed with suspicion.


- RMB posting permissions, likes and suppression status for each post

Thanks for all of your hard work! :clap:

User avatar
Trotterdam
Negotiator
 
Posts: 6948
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Fri Mar 04, 2016 7:24 pm

Greater Tern wrote:Are there any plans to make the nation/region census rankings, trophies and history available through the API?
I recall [violet] mentioning that she was planning on adding them eventually but wanted to wait so the server wouldn't get flooded with new scripts the moment the new census system went live.

Greater Tern wrote:colossal, cultured
This is available via q=admirable. (It's a randomized selection, though, so you may not receive the same result even in two immediately successive API requests. And "colossal" doesn't seem to show up, I'm guessing because it depends on age reather than "real" issue stats.)

Greater Tern wrote:a fair hand
I can't seem to find this one. Sure, it'd be a good addition!

Greater Tern wrote:hold their civil and political rights very dear, although the wealthy and those in business tend to be viewed with suspicion.
I don't believe this one is directly accessible from the API. However, there are only 27 possibilities taken from a fixed list, so you could request q=category and use a lookup table, if you really need this info. I have a full list of the possibilities, if you want it.

Disclaimer: I may have missed something.

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

Postby [violet] » Fri Mar 04, 2016 7:25 pm

Greater Tern wrote:Are there any plans to make the nation/region census rankings, trophies and history available through the API?

Yep, hopefully before too long.

RMB status & likes can be added. By posting permissions, do you mean embassy posting?

User avatar
Greater Tern
Envoy
 
Posts: 322
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Fri Mar 04, 2016 7:46 pm

Trotterdam wrote:
Greater Tern wrote:colossal, cultured
This is available via q=admirable. (It's a randomized selection, though, so you may not receive the same result even in two immediately successive API requests. And "colossal" doesn't seem to show up, I'm guessing because it depends on age reather than "real" issue stats.)

Damn, I missed that. Thanks!

Trotterdam wrote:
Greater Tern wrote:hold their civil and political rights very dear, although the wealthy and those in business tend to be viewed with suspicion.
I don't believe this one is directly accessible from the API. However, there are only 27 possibilities taken from a fixed list, so you could request q=category and use a lookup table, if you really need this info. I have a full list of the possibilities, if you want it.

I realize this part matches up with a nation's WA category, but I'm concerned that a lookup table could become outdated in the future.

Does this article in NSWiki have the latest WA category descriptions?

[violet] wrote:Yep, hopefully before too long.

RMB status & likes can be added. By posting permissions, do you mean embassy posting?


Thanks [violet]! And yeah, for posting permissions, I'm talking about getting the value for this part of the regional admin controls:

Image

I'm not sure how NS checks posting permissions for non-region nations internally, but my preferred format would be a list of non-region nations with RMB posting permissions. If that's not possible, the value of that setting would be fine too -- I can just do additional queries to check if a nation fits that criteria.

User avatar
Eluvatar
Site Admin
 
Posts: 2165
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Fri Mar 04, 2016 8:35 pm

Greater Tern wrote:I'm not sure how NS checks posting permissions for non-region nations internally, but my preferred format would be a list of non-region nations with RMB posting permissions. If that's not possible, the value of that setting would be fine too -- I can just do additional queries to check if a nation fits that criteria.


A list of, say, all nations in The North Pacific could get a bit weighty.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Greater Tern
Envoy
 
Posts: 322
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Fri Mar 04, 2016 10:07 pm

Eluvatar wrote:A list of, say, all nations in The North Pacific could get a bit weighty.

It doesn't have to be everyone with RMB posting permissions (I'm assuming anyone residing in a region can post in the RMB), just the ones outside the region who do have posting rights. I admit I'm not familiar with how it's actually handled though.

User avatar
Trotterdam
Negotiator
 
Posts: 6948
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Fri Mar 04, 2016 10:37 pm

Greater Tern wrote:Does this article in NSWiki have the latest WA category descriptions?
Looks that way.

I don't think those particular descriptions have ever changed in all of NS history, except maybe fixing a punctuation mistake somewhere.

I don't have the patience to check everything that closely.

User avatar
Leppikania
Minister
 
Posts: 2278
Founded: Apr 13, 2015
Left-wing Utopia

Postby Leppikania » Mon Mar 14, 2016 5:46 am

Can there be an API call added to get the delivery reports on an API telegram?
INTP, -4.25 Economic Left/Right, -4.1 Social Libertarian/Authoritarian, tastes like chicken.
I do use NS stats, thank you very much.
Funny Quotes
Pie charts for industries
Request an Embassy

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

Postby [violet] » Wed Mar 16, 2016 6:46 pm

Now in testing: API shards for accessing World Census scores and ranks. Please give it a try and let me know how it suits your needs.

The data can be accessed via the census shard in both the Nation API and Region API. For example:

https://www.nationstates.net/cgi-bin/ap ... a&q=census

By default, this produces output based on the current day's ranking, e.g.:
Code: Select all
<SCALE id="26">
<SCORE>3964.45</SCORE>
<RANK>104230</RANK>
<RRANK>9</RRANK>
</SCALE>

"RANK" is world rank and "RRANK" is region rank.

You can specify a different scale, and look up multiple scales at once, with the scale keyword. For example:

http://www.nationstates.net/cgi-bin/api ... p;scale=22
http://www.nationstates.net/cgi-bin/api ... le=1+51+77
http://www.nationstates.net/cgi-bin/api ... ;scale=all

You can also control the output via the mode keyword. You can supply multiple modes, e.g.:

http://www.nationstates.net/cgi-bin/api ... ;mode=rank
http://www.nationstates.net/cgi-bin/api ... score+rank
http://www.nationstates.net/cgi-bin/api ... ank+prrank
Here prank gives you the world rank in percentage format, and prrank gives you the region rank in percentage format.

There is also a history mode. This can't be used in conjunction with other modes. But you can specify which scales you want data on, and optionally supply from and to dates (in epoch format), e.g.:

http://www.nationstates.net/cgi-bin/api ... de=history
http://www.nationstates.net/cgi-bin/api ... de=history
http://www.nationstates.net/cgi-bin/api ... 1458115200

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Corrupt Dictator Doges, Mojoland, Pontianus

Advertisement

Remove ads