Page 93 of 97

PostPosted: Fri Jan 13, 2023 12:16 pm
by 20XX
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.

PostPosted: Sat Jan 14, 2023 10:47 am
by Darcania
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

PostPosted: Wed Feb 08, 2023 12:40 pm
by The Yeetusa
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.

PostPosted: Fri Feb 24, 2023 10:43 am
by The Southwest Islands
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?

PostPosted: Fri Feb 24, 2023 10:49 am
by United Calanworie
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.

PostPosted: Mon Mar 20, 2023 10:22 am
by Thorn1000
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

PostPosted: Mon Mar 20, 2023 5:00 pm
by Eluvatar
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.

PostPosted: Mon Apr 03, 2023 3:58 pm
by Roavin
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!

PostPosted: Wed Apr 05, 2023 12:18 pm
by 20XX
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?

PostPosted: Wed Apr 05, 2023 5:46 pm
by Darcania
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

PostPosted: Mon Apr 10, 2023 12:18 am
by Weed
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.

PostPosted: Mon Apr 10, 2023 1:01 am
by The Ice States
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?

PostPosted: Fri Apr 14, 2023 7:46 pm
by Roavin
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.

PostPosted: Mon Apr 17, 2023 7:28 pm
by The Ice States
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!

PostPosted: Tue Apr 18, 2023 12:40 am
by Esfalsa
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?

PostPosted: Tue Apr 18, 2023 12:47 am
by Bowzin
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.

PostPosted: Tue Apr 18, 2023 1:09 am
by Esfalsa
I... right. Oops >_>

PostPosted: Wed Apr 19, 2023 9:37 am
by Merni
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?

PostPosted: Wed Apr 26, 2023 8:40 am
by Eluvatar
There are two new shards for the region API: wanations and numwanations

PostPosted: Wed Apr 26, 2023 11:13 am
by Refuge Isle
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.

PostPosted: Fri Apr 28, 2023 11:54 pm
by Klaus Devestatorie
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?

PostPosted: Sat Apr 29, 2023 12:52 am
by Spode Humbled Minions
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.

PostPosted: Sat Apr 29, 2023 1:09 am
by Trotterdam
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.

PostPosted: Sat Apr 29, 2023 1:42 am
by Klaus Devestatorie
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.

PostPosted: Sat Apr 29, 2023 2:00 am
by Klaus Devestatorie
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.