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
Rovhania
Secretary
 
Posts: 33
Founded: Jun 14, 2026
Inoffensive Centrist Democracy

Postby Rovhania » Sat Sep 05, 2026 7:38 pm

Is there an endpoint for Adoption stats? Is that something we can get if not? Preferably under nation, for individual nation lookup, could just be the number and name of the resolutions adopted, and the ones that aren't.
Rovhania
WA Ambassador: Kers Volgan
WAR Staffer | The Outback
Lt. Governor — Culture, WA Relations, Integration

I like Phil.
— Quebecshire

I like Phil, I’m so glad he (I think) escaped
— Croblade

government should be run by good phils
— Differences-in-Differences

phil: an ongoing example of positivity in NSGP
— Kalavakus

User avatar
Llan
Envoy
 
Posts: 295
Founded: Nov 06, 2025
Inoffensive Centrist Democracy

Postby Llan » Sat Sep 05, 2026 7:40 pm

How do I use the non telegram API?
Former Governor of Bananalandia Supreme.
Windows 7 ultimate is the best.

If you can read this, you don’t need glasses

User avatar
Valentine Z
Post Marshal
 
Posts: 15109
Founded: Nov 08, 2015
Democratic Socialists

Postby Valentine Z » Fri Sep 18, 2026 11:02 am

By chance, is there an API call that will allow you to have data points of the stats since 2016? Like historical data points.

Though of course, this is a VERY tall order, I am aware of that. With the NS stats trend starting off around Feb 28 2016, that will be 3856 data points (and counting) per stat, per nation.
♪ If you are reading my sig, I want you to have the best day so far ! You are worth it, do not let anyone get you down ! ♪
Glory to De Geweldige Sierlijke Katachtige Utopia en Zijne Autonome Machten ov Valentine Z !
(✿◠‿◠) ☆ \(^_^)/ ☆

♡ Issues Thread ♡ Photography Stuff ♡ Project: Save F7. ♡ Stats Analysis ♡

♡ The Sixty! ♡ Valentian Stories! ♡ Gwen's Adventures! ♡

• Never trouble trouble until trouble troubles you.
• World Map is a cat playing with Australia.

User avatar
Merethin
WA Secretariat
 
Posts: 1286
Founded: Dec 18, 2023
Liberal Democratic Socialists

Postby Merethin » Fri Sep 18, 2026 11:33 am

Valentine Z wrote:By chance, is there an API call that will allow you to have data points of the stats since 2016? Like historical data points.

Though of course, this is a VERY tall order, I am aware of that. With the NS stats trend starting off around Feb 28 2016, that will be 3856 data points (and counting) per stat, per nation.


https://www.nationstates.net/cgi-bin/api.cgi?nation=valentine_z&q=census&mode=history&scale=ID, optionally add from={} and to={} with UNIX timestamps. Seems like scale=all is also possible but it (understandably) takes quite a long time to fetch.

From the docs: https://www.nationstates.net/pages/api. ... i-standard
◆ The Realm Past the Horizon of Merethin ◆
Fleetmaster of the Galactic Armada of Starlight & Horizon
@iris.dreamer · she/her
Libcord Update Command

Former Minister of Foreign Affairs (x2) of Starlight & Horizon (6th and 7th Cabinet)
Former Aetherion (x2) of Starlight & Horizon (4th and 5th Cabinet)
Former Deputy Minister of Foreign Affairs of Starlight & Horizon (3rd Cabinet)

Rising Star Award (2025 Collection Awards)
Eluvatar Award (2025 Defender Awards)
Up and Coming Defender (2025 Gameplay Awards)
Power20 Silver (October 2026)
LGA#833 (co), LGA#843, LGA#844, LGA#852 (co), GA#7 (co), GA#10 (co), GA#16 (co), Issue #1873

User avatar
Valentine Z
Post Marshal
 
Posts: 15109
Founded: Nov 08, 2015
Democratic Socialists

Postby Valentine Z » Sat Sep 19, 2026 2:52 am

Merethin wrote:
Valentine Z wrote:By chance, is there an API call that will allow you to have data points of the stats since 2016? Like historical data points.

Though of course, this is a VERY tall order, I am aware of that. With the NS stats trend starting off around Feb 28 2016, that will be 3856 data points (and counting) per stat, per nation.


https://www.nationstates.net/cgi-bin/api.cgi?nation=valentine_z&q=census&mode=history&scale=ID, optionally add from={} and to={} with UNIX timestamps. Seems like scale=all is also possible but it (understandably) takes quite a long time to fetch.

From the docs: https://www.nationstates.net/pages/api. ... i-standard

Cheers, thank you! <3

2.5 minutes PER nation, oh dear. Ohh... that will take 520+ days for all nations. Though to be fair, this one I don't think I will need it for everyone, unless I am doing archival work. I can likely just use mine and do some magic.
Last edited by Valentine Z on Sat Sep 19, 2026 2:52 am, edited 1 time in total.
♪ If you are reading my sig, I want you to have the best day so far ! You are worth it, do not let anyone get you down ! ♪
Glory to De Geweldige Sierlijke Katachtige Utopia en Zijne Autonome Machten ov Valentine Z !
(✿◠‿◠) ☆ \(^_^)/ ☆

♡ Issues Thread ♡ Photography Stuff ♡ Project: Save F7. ♡ Stats Analysis ♡

♡ The Sixty! ♡ Valentian Stories! ♡ Gwen's Adventures! ♡

• Never trouble trouble until trouble troubles you.
• World Map is a cat playing with Australia.

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

Postby [violet] » Wed Sep 30, 2026 9:09 pm

Agadar wrote:I also see that the mostliked, mostlikes, and mostposts shards have been removed from the documentation, but they can still be accessed. Are they pending to be removed, or is the documentation simply not up to date?

They were added ten years ago as "experimental and undocumented" features and promptly forgotten about.

Investigating now, I see they are barely used and horrifyingly inefficient ("mostposts" can take over 20 minutes per request), so I'll remove them.

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

Postby [violet] » Thu Oct 01, 2026 1:37 pm

Live Happenings SSE API: Please Use It

I've updated the NS API doc, including adding this line:

If your bot repeatedly polls other APIs for happenings, please migrate to the Live Happenings SSE API.


The Live Happenings SSE API is now officially out of beta and the recommended source for bots that want to monitor happenings in real time. The most common form of these are Discord bots and scripts that check for new foundings and region moves. Previously, the only way to do this was to repeatedly send the same query to the NS API and watch for changes; now you can get the Live Happenings SSE API to send you events as they happen.

Currently just 7 bots account for more than three-quarters of all such rapid-polling happenings traffic, so it would be great to shift them over to the much more efficient SSE. At some point in the future, I'll make this mandatory, i.e. bots will not be permitted to rapidly poll the other APIs for happenings.

There is a migration guide in the doc.

User avatar
Dhornaper
Diplomat
 
Posts: 593
Founded: Jul 10, 2023
Father Knows Best State

Postby Dhornaper » Thu Oct 01, 2026 1:55 pm

[violet] wrote:Live Happenings SSE API: Please Use It

I've updated the NS API doc, including adding this line:

If your bot repeatedly polls other APIs for happenings, please migrate to the Live Happenings SSE API.


The Live Happenings SSE API is now officially out of beta and the recommended source for bots that want to monitor happenings in real time. The most common form of these are Discord bots and scripts that check for new foundings and region moves. Previously, the only way to do this was to repeatedly send the same query to the NS API and watch for changes; now you can get the Live Happenings SSE API to send you events as they happen.

Currently just 7 bots account for more than three-quarters of all such rapid-polling happenings traffic, so it would be great to shift them over to the much more efficient SSE. At some point in the future, I'll make this mandatory, i.e. bots will not be permitted to rapidly poll the other APIs for happenings.

There is a migration guide in the doc.


Heh. I will get to work on migrating Shahzada. May take a while given how expansive the bot is and the many functions it serves.

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

Postby Trotterdam » Thu Oct 01, 2026 11:57 pm

[violet] wrote:Currently just 7 bots account for more than three-quarters of all such rapid-polling happenings traffic, so it would be great to shift them over to the much more efficient SSE. At some point in the future, I'll make this mandatory, i.e. bots will not be permitted to rapidly poll the other APIs for happenings.
Uh, does this include me?

I've never used SSE before and am not looking forward to learning an entirely new architecture.

User avatar
Aidenfieeld
Bureaucrat
 
Posts: 47
Founded: Aug 09, 2017
Scandinavian Liberal Paradise

Postby Aidenfieeld » Sat Oct 03, 2026 4:40 pm

[violet] wrote:
Agadar wrote:I also see that the mostliked, mostlikes, and mostposts shards have been removed from the documentation, but they can still be accessed. Are they pending to be removed, or is the documentation simply not up to date?

They were added ten years ago as "experimental and undocumented" features and promptly forgotten about.

Investigating now, I see they are barely used and horrifyingly inefficient ("mostposts" can take over 20 minutes per request), so I'll remove them.

I understand if there is concern about these shards slowing everything down, but their removal is rather unfortunate. The region I'm from (TSP) has a well-established RMB awards program that is only made possible by making API pulls using the mostposts, mostliked, and mostlikes shards. :(
AIDENFIEELD

-(Tied) Longest-Tenured Coral Guard Member of The South Pacific.
-Deputy Director of the Office of World Assembly Legislation in TSP.
-Fan of progressive/psychedelic rock music.
-Maple syrup and ice cream enthusiast.
-Libertarian-leftist, socialist, environmentalist, believer in universal human rights.

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

Postby [violet] » Sat Oct 03, 2026 5:32 pm

Trotterdam wrote:
[violet] wrote:Currently just 7 bots account for more than three-quarters of all such rapid-polling happenings traffic, so it would be great to shift them over to the much more efficient SSE.
Uh, does this include me?

No -- Gloomspider is a very active bot, but it doesn't rapidly poll the same Happenings shard over and over.

The seven bots I mentioned request the same Happenings shard(s) every few seconds, and so are better suited to the Live Happenings SSE API: Dhornaper's discord bot, East Durthang's Telegramer/Stats Collector, the Echo discord bot used by Lazarus, Altys's discord bot, The Western Union of Communitas, Unibot's Rainmaker, and Wintermoot's Wintreath.

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

Postby [violet] » Sat Oct 03, 2026 5:34 pm

Aidenfieeld wrote:The region I'm from (TSP) has a well-established RMB awards program that is only made possible by making API pulls using the mostposts, mostliked, and mostlikes shards. :(

That's good to know... I'll look into a faster version, and if that's possible, document it.

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

Postby [violet] » Sat Oct 03, 2026 5:38 pm

Please note:
[violet] wrote:The Live Happenings SSE API isn't meant to be a general replacement for everything else. It's just for bots that want to monitor NS Happenings and react to them.
...
Essentially:
  • If your bot rapidly requests the same Happenings from NS over and over just to see if anything changed, it should use the Live Happenings SSE API instead. An example would be a discord bot that wants to notify people in a channel that something just happened on NS.
  • If your bot doesn't do anything until someone asks it to look something up, it should probably use the regular APIs. But if it's very active, it should consider a cache.

User avatar
Aidenfieeld
Bureaucrat
 
Posts: 47
Founded: Aug 09, 2017
Scandinavian Liberal Paradise

Postby Aidenfieeld » Sat Oct 03, 2026 5:39 pm

[violet] wrote:
Aidenfieeld wrote:The region I'm from (TSP) has a well-established RMB awards program that is only made possible by making API pulls using the mostposts, mostliked, and mostlikes shards. :(

That's good to know... I'll look into a faster version, and if that's possible, document it.

I sincerely appreciate that!
AIDENFIEELD

-(Tied) Longest-Tenured Coral Guard Member of The South Pacific.
-Deputy Director of the Office of World Assembly Legislation in TSP.
-Fan of progressive/psychedelic rock music.
-Maple syrup and ice cream enthusiast.
-Libertarian-leftist, socialist, environmentalist, believer in universal human rights.

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

Postby [violet] » Tue Oct 06, 2026 9:42 pm

Live Happenings SSE API: Just FYI after today's daily update run finishes I'm making the replay buffer more reliable. This means you can rely on it to supply all events even if the server itself dies for up to an hour (while NS Happenings keep getting generated) -- so no need to plug missing holes in the data.

User avatar
New Rogernomics
Powerbroker
 
Posts: 9604
Founded: Aug 22, 2006
Civil Rights Lovefest

Postby New Rogernomics » Thu Oct 08, 2026 5:26 pm

If there was some SSE event specifically for giving resolution text that repeats a few times a day [for resolutions still at vote], then that might be really useful.
Last edited by New Rogernomics on Thu Oct 08, 2026 5:31 pm, edited 1 time in total.
Elarién
Head of State (Delegate) of Lazarus
  • Former First Citizen (PM) of Lazarus
  • Former Minister of Foreign Affairs of Lazarus
  • Former Lazarus Delegate (Humane Republic of Lazarus, 2015)
  • Minister of Culture & Media (Humane Republic of Lazarus)
  • Interior Commissioner of Lazarus (Pre-People's Republic of Lazarus)
  • ADN:DSA Rep for Eastern Roman Empire
  • Honoratus Servant of the Holy Land (Eastern Roman Empire)

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

Postby [violet] » Fri Oct 09, 2026 10:30 pm

Say more? An SSE server generally wouldn't send repeat events because that undermines the concept. It's meant to broadcast changes.

User avatar
New Rogernomics
Powerbroker
 
Posts: 9604
Founded: Aug 22, 2006
Civil Rights Lovefest

Postby New Rogernomics » Sat Oct 10, 2026 12:13 am

[violet] wrote:Say more? An SSE server generally wouldn't send repeat events because that undermines the concept. It's meant to broadcast changes.
If it can't repeat, then potentially even having it added once via an SSE event would be ideal. Right now, I'm doing it by having it monitor SSE events for a vote on a new resolution, then it is running the API request then in response to that and getting the text. Gradually working to improve my SSE monitoring so that is only off by a few votes and doesn't need to make a request at all.

In a bot it would give something like this:
Image

And since I was getting it anyway, I figured I could put it in a dispatch too:
Image
Last edited by New Rogernomics on Sat Oct 10, 2026 12:49 am, edited 3 times in total.
Elarién
Head of State (Delegate) of Lazarus
  • Former First Citizen (PM) of Lazarus
  • Former Minister of Foreign Affairs of Lazarus
  • Former Lazarus Delegate (Humane Republic of Lazarus, 2015)
  • Minister of Culture & Media (Humane Republic of Lazarus)
  • Interior Commissioner of Lazarus (Pre-People's Republic of Lazarus)
  • ADN:DSA Rep for Eastern Roman Empire
  • Honoratus Servant of the Holy Land (Eastern Roman Empire)

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

Postby [violet] » Sat Oct 10, 2026 10:25 pm

New Rogernomics wrote:Right now, I'm doing it by having it monitor SSE events for a vote on a new resolution, then it is running the API request then in response to that and getting the text.

Yes, I think that's the right process.

User avatar
Merethin
WA Secretariat
 
Posts: 1286
Founded: Dec 18, 2023
Liberal Democratic Socialists

Postby Merethin » Sun Oct 11, 2026 3:22 am

New Rogernomics wrote:If it can't repeat, then potentially even having it added once via an SSE event would be ideal.

There is an SSE event for when a resolution goes to vote, if that's what you mean:
Code: Select all
The (General Assembly|Security Council) proposal "(.+)" \(by @@([0-9a-z_-]+)@@((?:,?( and)? @@([0-9a-z_-]+)@@)*)?\) entered the resolution voting floor


I think that the idea of sending the resolution text along with it isn't a bad one; we already got the rmbMessage field on RMB posts so it could be cool to see that concept extended to more SSE events.
◆ The Realm Past the Horizon of Merethin ◆
Fleetmaster of the Galactic Armada of Starlight & Horizon
@iris.dreamer · she/her
Libcord Update Command

Former Minister of Foreign Affairs (x2) of Starlight & Horizon (6th and 7th Cabinet)
Former Aetherion (x2) of Starlight & Horizon (4th and 5th Cabinet)
Former Deputy Minister of Foreign Affairs of Starlight & Horizon (3rd Cabinet)

Rising Star Award (2025 Collection Awards)
Eluvatar Award (2025 Defender Awards)
Up and Coming Defender (2025 Gameplay Awards)
Power20 Silver (October 2026)
LGA#833 (co), LGA#843, LGA#844, LGA#852 (co), GA#7 (co), GA#10 (co), GA#16 (co), Issue #1873

User avatar
UPC
WA Deputy Secretary-General
 
Posts: 150
Founded: Jul 18, 2022
Democratic Socialists

Postby UPC » Sun Oct 11, 2026 8:43 am

[violet] wrote:
Aidenfieeld wrote:The region I'm from (TSP) has a well-established RMB awards program that is only made possible by making API pulls using the mostposts, mostliked, and mostlikes shards. :(

That's good to know... I'll look into a faster version, and if that's possible, document it.

I get that this was a poorly implemented feature, but I wish the team had done a little more outreach to users before abruptly disabling the endpoint. Like TSP, Euro used this endpoint for RMB awards, and I wrote a tool for TRR that used it as well way back in the day. I'm sure that these are not the only three regions that were regularly using these endpoints, and I suspect that they were interpreted as "barely used" because these awards were produced at relatively infrequent (e.g., monthly) periods. I was able to figure out that the endpoint was retired by opening it in my browser, but my region's integration staff was very confused when their tool randomly stopped working!

Is the canon alternative to these endpoints for now just to poll the regional messages shard?
The Lost Weekend of UPC
Delegate of Europeia
World Assembly Deputy Secretary-General

(he/they)
Visit Europeia | Join Our Discord | Apply For Citizenship

User avatar
Toerana
Chargé d'Affaires
 
Posts: 470
Founded: Nov 27, 2018
Civil Rights Lovefest

Postby Toerana » Sun Oct 11, 2026 9:29 am

What UPC said. We haven't actively run the program for a few months (and even then it was only every couple of weeks when we did) but we used the mostposts/likes/etc endpoints, and was how we've run our awards program for years (both "manual" and script based versions).


Not thrilled that they've been removed.

Edit: I also used the mostposts shard in our integration system to help determine activity. Guess this explains why things have been going wrong with it recently :^)
Last edited by Toerana on Sun Oct 11, 2026 9:32 am, edited 3 times in total.

User avatar
The Western Union of Communitas
Lobbyist
 
Posts: 12
Founded: Mar 12, 2025
Ex-Nation

Postby The Western Union of Communitas » Sun Oct 11, 2026 1:50 pm

[violet] wrote:
Trotterdam wrote:Uh, does this include me?

No -- Gloomspider is a very active bot, but it doesn't rapidly poll the same Happenings shard over and over.

The seven bots I mentioned request the same Happenings shard(s) every few seconds, and so are better suited to the Live Happenings SSE API: Dhornaper's discord bot, East Durthang's Telegramer/Stats Collector, the Echo discord bot used by Lazarus, Altys's discord bot, The Western Union of Communitas, Unibot's Rainmaker, and Wintermoot's Wintreath.


I guess I should note that I have seen this and will fix as soon as I can :)
Last edited by The Western Union of Communitas on Sun Oct 11, 2026 1:51 pm, edited 1 time in total.
Please contact my main Nisat for any further inquiries :)

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

Postby [violet] » Sun Oct 11, 2026 4:32 pm

It's good to hear from people who were using mostposts/mostliked/mostlikes. I'm still looking at restoring this, but the site can't provide an endpoint that takes 40 seconds of database crunching to produce an answer, and can be queried 50 times per minute per IP address. This is the kind of thing an AI scraper bot swarm happens upon and suddenly the site is down.

Toerana wrote:we used the mostposts/likes/etc endpoints

UPC wrote:Euro used this endpoint for RMB awards, and I wrote a tool for TRR that used it as well way back in the day.

More specifics would be helpful here -- which endpoint or endpoints are required? There were three distinct queries and I may not be able to restore all of them.

User avatar
New Rogernomics
Powerbroker
 
Posts: 9604
Founded: Aug 22, 2006
Civil Rights Lovefest

Postby New Rogernomics » Sun Oct 11, 2026 4:42 pm

Merethin wrote:
New Rogernomics wrote:If it can't repeat, then potentially even having it added once via an SSE event would be ideal.

There is an SSE event for when a resolution goes to vote, if that's what you mean:
Code: Select all
The (General Assembly|Security Council) proposal "(.+)" \(by @@([0-9a-z_-]+)@@((?:,?( and)? @@([0-9a-z_-]+)@@)*)?\) entered the resolution voting floor


I think that the idea of sending the resolution text along with it isn't a bad one; we already got the rmbMessage field on RMB posts so it could be cool to see that concept extended to more SSE events.
That's what I already monitor, yep. If my bot restarts/starts it will do an API request to refresh the vote tallies while SSE monitoring is starting up.
Elarién
Head of State (Delegate) of Lazarus
  • Former First Citizen (PM) of Lazarus
  • Former Minister of Foreign Affairs of Lazarus
  • Former Lazarus Delegate (Humane Republic of Lazarus, 2015)
  • Minister of Culture & Media (Humane Republic of Lazarus)
  • Interior Commissioner of Lazarus (Pre-People's Republic of Lazarus)
  • ADN:DSA Rep for Eastern Roman Empire
  • Honoratus Servant of the Holy Land (Eastern Roman Empire)

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Jonas Land

Advertisement

Remove ads