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
20XX
Lobbyist
 
Posts: 14
Founded: May 03, 2020
Iron Fist Consumerists

Postby 20XX » Fri Jan 13, 2023 12:16 pm

United Calanworie wrote:I'm not sure. We could potentially see automated "what region were you in?" scanner tools, but those can be done manually already.


Assuming that nation spent major update in a region, it can already be done automatically assuming one has a catalog of data dumps.
Last edited by 20XX on Fri Jan 13, 2023 12:20 pm, edited 1 time in total.
Vleerian Vytherov

User avatar
Darcania
Envoy
 
Posts: 205
Founded: Dec 29, 2014
Civil Rights Lovefest

Postby Darcania » Sat Jan 14, 2023 10:47 am

20XX wrote:
United Calanworie wrote:I'm not sure. We could potentially see automated "what region were you in?" scanner tools, but those can be done manually already.


Assuming that nation spent major update in a region, it can already be done automatically assuming one has a catalog of data dumps.


Which everyone does thanks to the archives page: https://www.nationstates.net/page=archive

User avatar
The Yeetusa
Spokesperson
 
Posts: 177
Founded: Oct 17, 2019
Iron Fist Consumerists

Postby The Yeetusa » Wed Feb 08, 2023 12:40 pm

Will a N-Day api endpoint (like tracking an individual nation's nukes, shields, etc) ever be considered? It would be useful for coordination and tracking participants.

User avatar
The Southwest Islands
Lobbyist
 
Posts: 13
Founded: Feb 24, 2023
Ex-Nation

Postby The Southwest Islands » Fri Feb 24, 2023 10:43 am

Quick question, but I screwed up on one of the policy questions when I was first creating my nation. So how do I change my policies after I already created my nation?
Last edited by The Southwest Islands on Fri Feb 24, 2023 10:43 am, edited 1 time in total.
David "DJ" Hayes I

Emperor-King of The Southwest Islands, Governor of Guam, Supreme Judge

A Class 0.4267 Civilization according to this index.

User avatar
United Calanworie
Technical Moderator
 
Posts: 3841
Founded: Dec 12, 2018
Democratic Socialists

Postby United Calanworie » Fri Feb 24, 2023 10:49 am

The Southwest Islands wrote:Quick question, but I screwed up on one of the policy questions when I was first creating my nation. So how do I change my policies after I already created my nation?

This thread is for discussion of the NationStates API, not general questions about your nation.
Trans rights are human rights.
||||||||||||||||||||
Discord: Aav#7546 @queerlyfe
She/Her/Hers
My telegrams are not for Moderation enquiries, those belong in a GHR. Feel free to reach out if you want to just chat.

User avatar
Thorn1000
Envoy
 
Posts: 232
Founded: Apr 02, 2015
Corporate Police State

Postby Thorn1000 » Mon Mar 20, 2023 10:22 am

Hey there, while we are sieging England, I wanted to run a cross section of the nations on the ban list to WA status or influence so we could remove non-WA nations or low inf/cte nations from the ban list and I found out that there was not a shard to grab all banned nations from a region. I was wondering if there was a chance we could eventually get a regional shard for ban list? I get that a ton of unsavory names get banned and we might not want to encourage that, but it is already enough of a headache that BC ROs cannot see the ban list in a useable manner as is and the ability to poll the AP for that information would be useful to have for cleaning up full lists during sieges.

Edit: spelling is hard and clarified slightly
Last edited by Thorn1000 on Mon Mar 20, 2023 10:31 am, edited 1 time in total.
walrus wrote:Life is a zero-sum game. The lower I make the happiness of children, the higher my happiness rises

All opinions that I express are solely mine. I do not speak for anyone but me yadayadayada
One of 5 people to have hit more than 200 regions in 1 update

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

Postby Eluvatar » Mon Mar 20, 2023 5:00 pm

That does seem like a pretty reasonable ask. I won't have time for it anytime soon, but maybe one of our new developers will.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Roavin
Admin
 
Posts: 1778
Founded: Apr 07, 2016
Democratic Socialists

Postby Roavin » Mon Apr 03, 2023 3:58 pm

I bring to you today three new things in the API, in ascending order of hype:

First, as requested by Thorn here, regions now have a banlist shard. Here's TWP's banlist, for example.

Second, as requested by 9003 here, I've added last_major_update and last_minor_update shards to regions, and also LASTMAJORUPDATE and LASTMINORUPDATE fields in the region dump. R/Ders everywhere shall rejoice. Note, the values returned will be 0 until after next minor update, after which the values will be accurate.

Third, and the biggest one, this is based initially on a request by Darcania. The API now returns many more headers helpful for keeping rate limits, but even better, the API no longer locks you out for 15 minutes for exceeding the rate limit. Instead, it only locks out for the rest of the time window, unless you really stress the API in which case it might lock you out longer.

All of this is documented in the API documentation. Enjoy!
Last edited by Roavin on Mon Apr 03, 2023 4:00 pm, edited 1 time in total.
Helpful Resources: One Stop Rules Shop | API documentation | NS Coders Discord
About me: Longest serving Prime Minister in TSP | Former First Warden of TGW | aka Curious Observations

Feel free to TG me, but not about moderation matters.

User avatar
20XX
Lobbyist
 
Posts: 14
Founded: May 03, 2020
Iron Fist Consumerists

Postby 20XX » Wed Apr 05, 2023 12:18 pm

Roavin wrote:Third, and the biggest one, this is based initially on a request by Darcania. The API now returns many more headers helpful for keeping rate limits, but even better, the API no longer locks you out for 15 minutes for exceeding the rate limit. Instead, it only locks out for the rest of the time window, unless you really stress the API in which case it might lock you out longer.


Would it be possible to get similar headers for the Telegram API in future?
Vleerian Vytherov

User avatar
Darcania
Envoy
 
Posts: 205
Founded: Dec 29, 2014
Civil Rights Lovefest

Postby Darcania » Wed Apr 05, 2023 5:46 pm

20XX wrote:Would it be possible to get similar headers for the Telegram API in future?

I've requested as such in the thread Roavin linked, see his answer here: viewtopic.php?p=40481591#p40481591

User avatar
Weed
Diplomat
 
Posts: 898
Founded: Oct 23, 2011
Capitalizt

Postby Weed » Mon Apr 10, 2023 12:18 am

Can the links in the "available shards" sections of the documentation be updated? Specifically noticed the last major/minor update shards aren't there on the region list of available shards. It still only shows last major update.
I prefer not to be called that
Ex-Defender
Former WASC Author
----V----
Weed
LIVE FREE

User avatar
The Ice States
GA Secretariat
 
Posts: 2900
Founded: Jun 23, 2022
Compulsory Consumerist State

Postby The Ice States » Mon Apr 10, 2023 1:01 am

The Ice States wrote:Could there be a region shard added to the API to view authorised recruiters for a region?

I apologise for bumping this again; but could I have a response on this please?
Last edited by The Ice States on Mon Apr 10, 2023 1:02 am, edited 1 time in total.
Factbooks · 46x World Assembly Author · Festering Snakepit Wiki · WACampaign · GA Stat Effects Data

Posts in the WA forums are Ooc and unofficial, absent indication otherwise.
Please check out my roleplay thread The Battle of Glass Tears!
WA 101 Guides to GA authorship, campaigning, and more.

User avatar
Roavin
Admin
 
Posts: 1778
Founded: Apr 07, 2016
Democratic Socialists

Postby Roavin » Fri Apr 14, 2023 7:46 pm

Weed wrote:Can the links in the "available shards" sections of the documentation be updated? Specifically noticed the last major/minor update shards aren't there on the region list of available shards. It still only shows last major update.


Looks correct to me? Try Shift+F5 to force a reload, maybe you're viewing a cached version.

The Ice States wrote:
The Ice States wrote:Could there be a region shard added to the API to view authorised recruiters for a region?

I apologise for bumping this again; but could I have a response on this please?


I've added it to the TODO list.
Helpful Resources: One Stop Rules Shop | API documentation | NS Coders Discord
About me: Longest serving Prime Minister in TSP | Former First Warden of TGW | aka Curious Observations

Feel free to TG me, but not about moderation matters.

User avatar
The Ice States
GA Secretariat
 
Posts: 2900
Founded: Jun 23, 2022
Compulsory Consumerist State

Postby The Ice States » Mon Apr 17, 2023 7:28 pm

Roavin wrote:
The Ice States wrote:I apologise for bumping this again; but could I have a response on this please?


I've added it to the TODO list.

Thank you!
Factbooks · 46x World Assembly Author · Festering Snakepit Wiki · WACampaign · GA Stat Effects Data

Posts in the WA forums are Ooc and unofficial, absent indication otherwise.
Please check out my roleplay thread The Battle of Glass Tears!
WA 101 Guides to GA authorship, campaigning, and more.

User avatar
Esfalsa
Spokesperson
 
Posts: 132
Founded: Aug 07, 2015
Civil Rights Lovefest

Postby Esfalsa » Tue Apr 18, 2023 12:40 am

I realize that it would have been helpful for me to test these things before frontiers went live, but some things I've noticed for the regions API (probably a non-exhaustive list):

  • The `founderauth` shard doesn't seem to work anymore (it just returns an empty <REGION> tag), which makes sense, but it's still listed in the documentation.
  • The `frontier` shard seems to work, but isn't listed in the documentation.
  • The `governor` shard seems to return the `founder` shard instead (in contrast to other shards that don't exist in the sense that no data is returned).
  • EDIT: My bad, the `governor` shard seems to return the governor nation in a <FOUNDER> tag.
  • There's no `governorauth`shard, which seems like it would be analogous to the previous `founderauth` shard.
  • It seems like the character 'S' in regional officer authorities indicates Successor authority, but that isn't listed in the documentation.
  • The API current version is still at 11, which if memory serves means it hasn't been bumped. Figured I'd mention it because I'm not sure if that's intended or not?
Last edited by Esfalsa on Tue Apr 18, 2023 12:46 am, edited 2 times in total.

User avatar
Bowzin
Envoy
 
Posts: 301
Founded: Aug 13, 2018
Libertarian Police State

Postby Bowzin » Tue Apr 18, 2023 12:47 am

Esfalsa wrote:
  • There's no `governorauth`shard, which seems like it would be analogous to the previous `founderauth` shard.


Wouldn't governor authorities always be everything in every stronghold, and nothing in every frontier? You can't modify the authorities anymore, just rename the position.
Bowzin Vytherov-Skollvaldr
| On a Redemption Arc. |
We dropped a new resume dispatch!

User avatar
Esfalsa
Spokesperson
 
Posts: 132
Founded: Aug 07, 2015
Civil Rights Lovefest

Postby Esfalsa » Tue Apr 18, 2023 1:09 am

I... right. Oops >_>

User avatar
Merni
Ambassador
 
Posts: 1800
Founded: May 03, 2016
Democratic Socialists

Postby Merni » Wed Apr 19, 2023 9:37 am

It seems there is no API field for the Governor's title. Could we have one, preferably included in the Daily Dumps so that detag-finding tools could find them?
2024: the year of democracy. Vote!
The Labyrinth | Donate your free time, help make free ebooks | Admins: Please let us block WACC TGs!
RIP Residency 3.5.16-18.11.21, killed by simplistic calculation
Political Compass: Economic -9.5 (Left) / Social -3.85 (Liberal)
Wrote issue 1523, GA resolutions 532 and 659
meth
When the people are being beaten with a stick, they are not much happier if it is called 'the People’s Stick.' — Mikhail Bakunin (to Karl Marx)
You're supposed to be employing the arts of diplomacy, not the ruddy great thumping sledgehammers of diplomacy. — Ardchoille
The West won the world not by the superiority of its ideas or values or religion [...] but rather by its superiority in applying organised violence. — Samuel P. Huntington (even he said that!)

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

Postby Eluvatar » Wed Apr 26, 2023 8:40 am

There are two new shards for the region API: wanations and numwanations
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Refuge Isle
Technical Moderator
 
Posts: 1904
Founded: Dec 14, 2018
Left-wing Utopia

Postby Refuge Isle » Wed Apr 26, 2023 11:13 am

Eluvatar wrote:There are two new shards for the region API: wanations and numwanations

Thanks, now functions that pull or use this information will be less intensive.

User avatar
Klaus Devestatorie
Minister
 
Posts: 2938
Founded: Aug 28, 2008
Capitalizt

Postby Klaus Devestatorie » Fri Apr 28, 2023 11:54 pm

Hi, I'm old, yet completely new to fetching data via the API, and I'm messing around with fetching census data using public API shards, and I don't think I understand the documentation.

For one, when I attempt to fetch census data of nations in my puppet region (i.e. https://www.nationstates.net/cgi-bin/ap ... ks;scale=1), I find this only returns the 20 nations highest on the scale. I'm looking for a way to get all of the nations in the region, not just the top 20. I also can't find the right syntax to fetch additional data from other census categories in the same query- everything I've tried just seems to default it back to getting the data for today's census alone. Am I missing something obvious, or am I not supposed to be able to get all of that data in one query?

User avatar
Spode Humbled Minions
Envoy
 
Posts: 252
Founded: May 13, 2016
New York Times Democracy

Postby Spode Humbled Minions » Sat Apr 29, 2023 12:52 am

Klaus Devestatorie wrote:Hi, I'm old, yet completely new to fetching data via the API, and I'm messing around with fetching census data using public API shards, and I don't think I understand the documentation.

For one, when I attempt to fetch census data of nations in my puppet region (i.e. https://www.nationstates.net/cgi-bin/ap ... ks;scale=1), I find this only returns the 20 nations highest on the scale. I'm looking for a way to get all of the nations in the region, not just the top 20. I also can't find the right syntax to fetch additional data from other census categories in the same query- everything I've tried just seems to default it back to getting the data for today's census alone. Am I missing something obvious, or am I not supposed to be able to get all of that data in one query?

I think the answer here is that the NS API doesn’t want you to use the censusrank shard to be able to pull all the data from a region’s nations. Per the documentation:
Some people use a combination of API calls and dump files. This is a good idea if you want to compare a nation to others in its region. Since regions can contain thousands of nations, it's not practical to request data on all a nation's neighbors at once via the API. Instead, try building region-wide stats (e.g. total region population) using the most recent daily dump, and only drawing on the API for up-to-the-second information on the nation in question.

At least how I read this, it basically says “don’t grab pizza rankings from the API use the daily dump instead of making 500 API calls >:c”
—— tangent begins
There’s an undocumented nation stat comparing page somewhere, and it also caps out before 20 (I want to say it was around 13 last I checked), and the pages for viewing the rankings on regions are limited to 10. My theory (see: completely unfounded speculation) is that there is (or was) some policy of trying to keep the API as similar in terms of the amount of information you could glean from it as just browsing - maybe for like… fairness between scripters and non-scripters, or maybe for technical reasons? No clue.
—— tangent ends

Anyhow, I’ve heard a lot about the daily dump having a bunch of information that you can download all at once, but I’ve never used it. It seems to be the documentation’s recommendation for what you want to do though.
Last edited by Spode Humbled Minions on Sat Apr 29, 2023 12:54 am, edited 1 time in total.
"Sadly we do not have seven plagues to soften your hardened heart"
“Your existing state of mind is at caress to apocalypse.”

User avatar
Trotterdam
Postmaster-General
 
Posts: 10546
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Sat Apr 29, 2023 1:09 am

I suggest downloading the daily dump once and cheking if the information you're interested in is in there. If it isn't, then don't bother downloading it again. If it is, then download it once a day and work with that.

I don't think census score data is in the daily dumps, though. So if you want that, then you'll have to collect it piecewise over multiple API calls, respecting the ratelimit. Yes, this might take a while for the really large regions, but even at a thousand nations you can do it in less than an hour, and census scores don't normally change that rapidly. On the other hand, you can collect all census scores of a single nation at the same time, so if there's multiple scores you're interested in, it's best to combine your requests.

User avatar
Klaus Devestatorie
Minister
 
Posts: 2938
Founded: Aug 28, 2008
Capitalizt

Postby Klaus Devestatorie » Sat Apr 29, 2023 1:42 am

I'm not trying to make 500 API calls, though. I'm just trying to make one API call that has all the data I want, with no intention of making this call more than once a day. There doesn't appear to be an option to let me select any group of 20 nations other than the 20 highest rated nations for that census, so I can't request by region in successive calls. I would either have to do this by making a call to request a list of all nations in the region and then make individual calls for each nation (exactly what it's requesting I don't do), or I'd need to do a very extensive amount of HTML scraping, and I don't have the slightest idea how to keep to the relevant rate limits for either option when fetching the data via Excel or Google Sheets.

User avatar
Klaus Devestatorie
Minister
 
Posts: 2938
Founded: Aug 28, 2008
Capitalizt

Postby Klaus Devestatorie » Sat Apr 29, 2023 2:00 am

And after finally finding a program willing to open the nations.xml file without giving up part way through loading, I can confirm that the data dump doesn't have what I want. The only other option I can see is the one Topid and Souls came up with in 2016, which is find a tolerable way to just make 49 API requests every 30 seconds by hand, but that's also not ideal. I'll test it and see how I go.
Last edited by Klaus Devestatorie on Sat Apr 29, 2023 2:22 am, edited 1 time in total.

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: I am just a fish, Mavenu, Thebernesen

Advertisement

Remove ads