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
Comfed
Minister
 
Posts: 2258
Founded: Apr 09, 2020
Psychotic Dictatorship

Postby Comfed » Fri Jun 17, 2022 3:11 pm

SherpDaWerp wrote:
Comfed wrote:What fun? There is already a website with all the issues results, and if you don't want spoilers for your issues... don't look for them?

..a website that is provided thanks to the efforts of player(s) (not staff: Trotterdam and those who've provided effect lines for him to track), and isn't guaranteed to be accurate (the way a NS API call would be). Trotterdam's tool is much closer to the spoiler thread in design than an API endpoint would be.

There's a world of difference between players maintaining potentially-accurate spoiler resources and NS just giving us the information whenever we ask.

I mean, if you don't want the spoilers, you can just not ask...

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

Postby [violet] » Wed Jun 29, 2022 9:20 pm

United Calanworie wrote:Can we please get the SPDR score of each nation added to the daily dumps? It would avoid having to make dozens or hundreds of calls in order to check influence for all nations in a region.

Do you want each nation's Influence score in its current region only or in all regions?

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

Postby United Calanworie » Wed Jun 29, 2022 9:31 pm

[violet] wrote:
United Calanworie wrote:Can we please get the SPDR score of each nation added to the daily dumps? It would avoid having to make dozens or hundreds of calls in order to check influence for all nations in a region.

Do you want each nation's Influence score in its current region only or in all regions?

If it's possible to do without too much trouble, current region only would be best. If it's impractical to do that, all regions is fine.
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
Roavin
Admin
 
Posts: 1778
Founded: Apr 07, 2016
Democratic Socialists

Postby Roavin » Thu Jun 30, 2022 12:35 am

Oh having it in from all regions would absolutely be preferable, even though that might inflate the dump size quite a bit for active R/D puppets.
Last edited by Roavin on Thu Jun 30, 2022 12:46 am, 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
United Calanworie
Technical Moderator
 
Posts: 3846
Founded: Dec 12, 2018
Democratic Socialists

Postby United Calanworie » Fri Jul 08, 2022 10:40 pm

Something out of the normal for me posting here in that I'm not going to push about daily dumps containing influence :P but I'd like to ask if it would be possible to have a dispatch edited event pushed via the happenings API. I had envisioned potentially building a search tool for dispatches using ElasticSearch as a backend, but keeping content up-to-date to be searched would be ideal, and unfortunately there is no good way to ensure that content is up to date other than fetching every single dispatch at the fastest rate possible... which with some back of the napkin math means that it would take anywhere from a week to two weeks (depending on how many IDs have actual dispatches associated with them now and don't just link to "sorry, but this dispatch no longer exists.") and somewhere in the ballpark of 1,008,000 to 1,730,740 API calls (as of this writing, it could be a few hundred more at the time of reading) in order to update all the dispatches.

Which is not ideal for either my program or the site being subjected to full-throttle API calls >_>

So if we could have a happenings event in the API as of current and/or an event added to the potential SSE API that would make life a fair bit easier for this project.

Also I guess there should possibly be a question of "is building the index going to be too much of a heavy load on the site and would you prefer that the queries be spanned across multiple weeks instead of running at 50/30 and/or should I abandon this idea before I break the site with calls" which is... probably a good question to ask when considering sending somewhere in the neighborhood of 1.7m API calls.
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
[violet]
Executive Director
 
Posts: 16207
Founded: Antiquity

Postby [violet] » Mon Jul 11, 2022 10:56 pm

Those API calls are likely to be quite lightweight, as they're just a simple db lookup, but the API ratelimit is really meant as a burst number, not a constant level of traffic for days or weeks, so it does scare me a bit.

It may be quicker and easier for me to set up an ElastiSearch backend here (or Sphinx, which is what we use elsewhere) than to deal with a couple million API calls plus add a new API service (ideally on a brand new SSE event server). But then again I'm not really able to add extra projects to the todo list right now, either. So I guess my answer for now is that those API calls, if you make them, should ideally run quite a bit slower than the maximum rate.

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

Postby Trotterdam » Tue Jul 12, 2022 6:41 pm

https://www.nationstates.net/cgi-bin/api.cgi?q=banner;banner=t11 returns malformed XML:
Code: Select all
<WORLD>
<BANNERS>
<BANNER id="t11">
<NAME>Oversight</NAME>
<VALIDITY>Fund Law & Order in a low-tech nation</VALIDITY>
</BANNER></BANNERS>
</WORLD>
This should be escaped as "&amp;" instead of "&".

(I don't believe it's currently relevant, but "<" would also need to be escaped if it appears anywhere.)

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

Postby United Calanworie » Tue Jul 12, 2022 8:31 pm

[violet] wrote:Those API calls are likely to be quite lightweight, as they're just a simple db lookup, but the API ratelimit is really meant as a burst number, not a constant level of traffic for days or weeks, so it does scare me a bit.

It may be quicker and easier for me to set up an ElastiSearch backend here (or Sphinx, which is what we use elsewhere) than to deal with a couple million API calls plus add a new API service (ideally on a brand new SSE event server). But then again I'm not really able to add extra projects to the todo list right now, either. So I guess my answer for now is that those API calls, if you make them, should ideally run quite a bit slower than the maximum rate.

That's about what I figured. Is there any easy way (for you) to produce a dump file of the dispatches? I know size would probably be a pretty big concern considering that each dispatch could potentially be around 97kb in size and there are a lot of them. If that isn't possible, I guess I will have to reconsider how I build this index because I would like to make most of the information at least relatively up to date and not have dispatches that have been edited for the last month not be re-updated.

Thanks for the prompt answer though.
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
[violet]
Executive Director
 
Posts: 16207
Founded: Antiquity

Postby [violet] » Wed Jul 13, 2022 9:07 pm


Fixed, thanks.

User avatar
SherpDaWerp
Technical Moderator
 
Posts: 1897
Founded: Mar 02, 2016
Benevolent Dictatorship

Postby SherpDaWerp » Fri Jul 22, 2022 8:23 pm

At an indeterminate point in the future™, I might compile some data on issues author region residency. For the CTE'd ones, I'd like to know their CTE date so I only have to find specific dates of dumps instead of however many thousand dumps exist in total. Problem with that is, the boneyard is only accessible from the HTML site.

Is there any chance of adding a boneyard search endpoint that returns (at least) population, founding date, and last activity, for a specific nation? I'm not opposed to adding more information if it's easy (i.e. the lookup returns number of dispatches and card link already), but those three fields are all I need.

For ancient CTE'd nations, an array of data would be fine (i.e. same as dumps or whatever else), and maybe even an extra parameter "newest" could let people ask for only the most-recent boneyard entry for a nation.
Became an editor on 18/01/23 techie on 29/01/24

Rampant statistical speculation from before then is entirely unofficial

User avatar
SherpDaWerp
Technical Moderator
 
Posts: 1897
Founded: Mar 02, 2016
Benevolent Dictatorship

Postby SherpDaWerp » Mon Jul 25, 2022 5:34 pm

SherpDaWerp wrote:At an indeterminate point in the future™, I might compile some data on issues author region residency. For the CTE'd ones, I'd like to know their CTE date so I only have to find specific dates of dumps instead of however many thousand dumps exist in total. Problem with that is, the boneyard is only accessible from the HTML site.

Is there any chance of adding a boneyard search endpoint that returns (at least) population, founding date, and last activity, for a specific nation? I'm not opposed to adding more information if it's easy (i.e. the lookup returns number of dispatches and card link already), but those three fields are all I need.

For ancient CTE'd nations, an array of data would be fine (i.e. same as dumps or whatever else), and maybe even an extra parameter "newest" could let people ask for only the most-recent boneyard entry for a nation.

The thought occurs to me that this endpoint would be easily "abused" to create a refound bot, which isn't my intention. Even without an explicit "name availability" timestamp in the data, you could extrapolate based on population or founding date.

I guess the only way to get around that would be to only list the last activity date, which I guess I'm still OK with - it's better than nothing, and it would still let me work out the last-known-location of issues authors without downloading every dump.
Became an editor on 18/01/23 techie on 29/01/24

Rampant statistical speculation from before then is entirely unofficial

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

Postby United Calanworie » Tue Aug 02, 2022 12:08 pm

United Calanworie wrote:
[violet] wrote:Do you want each nation's Influence score in its current region only or in all regions?

If it's possible to do without too much trouble, current region only would be best. If it's impractical to do that, all regions is fine.

One-month *bump* on this query. Something that I thought of would be influence returning as a list, like this for example:
<influence>
<region id="a region">124.0</region>
<region id="testregionia">2.0</region>
</influence>

This is obviously a change from my prior response of "current region only," but after thinking about it a bit more while I wrote this post, it seems more logical to provide all the data instead of a small subset.
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
Balasai
Secretary
 
Posts: 32
Founded: Feb 10, 2021
Ex-Nation

need data about api

Postby Balasai » Sat Aug 20, 2022 9:03 pm

does data change like population leader name takes change in the api instantly or it update at time of data dump only

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

Postby Roavin » Sun Aug 21, 2022 1:00 am

Balasai wrote:does data change like population leader name takes change in the api instantly or it update at time of data dump only


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

Postby Eluvatar » Thu Aug 25, 2022 9:40 am

United Calanworie wrote:
United Calanworie wrote:If it's possible to do without too much trouble, current region only would be best. If it's impractical to do that, all regions is fine.

One-month *bump* on this query. Something that I thought of would be influence returning as a list, like this for example:
<influence>
<region id="a region">124.0</region>
<region id="testregionia">2.0</region>
</influence>

This is obviously a change from my prior response of "current region only," but after thinking about it a bit more while I wrote this post, it seems more logical to provide all the data instead of a small subset.

This would be data we've never previously made public. What possible downsides would there be to making it public?
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby United Calanworie » Thu Aug 25, 2022 9:52 am

Eluvatar wrote:
United Calanworie wrote:One-month *bump* on this query. Something that I thought of would be influence returning as a list, like this for example:
<influence>
<region id="a region">124.0</region>
<region id="testregionia">2.0</region>
</influence>

This is obviously a change from my prior response of "current region only," but after thinking about it a bit more while I wrote this post, it seems more logical to provide all the data instead of a small subset.

This would be data we've never previously made public. What possible downsides would there be to making it public?

I'm not sure. We could potentially see automated "what region were you in?" scanner tools, but those can be done manually already. It's just a question of how much work somebody is willing to put in. R/D would definitely get a lot more *precise* with influence calculations, too, when all the information would be available in a daily dump, but as a counter-argument, that information is already (lump-sum) provided by the API, this would just be removing the API calls from the equation.
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
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Thu Aug 25, 2022 9:55 am

Right, I'm specifically asking what undesirable outcomes there could be from revealing the specific amounts associated with specific regions. Yes it's possible to reconstruct a lot of that information from past daily dumps, but that is a much greater investment of effort.
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby United Calanworie » Thu Aug 25, 2022 10:08 am

We could potentially see sleeper operations being blown with a minimum of effort for the suspicious parties, even potentially automatically. I'm sure there might be other implications as well, but I'm not particularly well-versed in how influence is used beyond for R/D operations.
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
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Thu Aug 25, 2022 10:34 am

Yes this would be valuable for identifying what regions a recently-revived nation had been part of in the past. I'll leave this open here for a few days*, see if anyone comes out of the woodwork who thinks that would be a serious problem for them.

*At least a few days.
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby Trotterdam » Thu Aug 25, 2022 12:36 pm

Eluvatar wrote:Yes this would be valuable for identifying what regions a recently-revived nation had been part of in the past.
Does influence still decay while nations lie in the boneyard?

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

Postby Eluvatar » Thu Aug 25, 2022 12:44 pm

Trotterdam wrote:
Eluvatar wrote:Yes this would be valuable for identifying what regions a recently-revived nation had been part of in the past.
Does influence still decay while nations lie in the boneyard?

You may find this announcement relevant.
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby [violet] » Mon Sep 05, 2022 6:42 pm

New Region Shard: 'bannerurl', which is like 'banner' but requires less figuring out how to construct an image URL.

User avatar
Panagouge
Diplomat
 
Posts: 631
Founded: Aug 03, 2018
Civil Rights Lovefest

Postby Panagouge » Mon Sep 05, 2022 7:07 pm

[violet] wrote:New Region Shard: 'bannerurl', which is like 'banner' but requires less figuring out how to construct an image URL.

Where exactly is this feature?
I exist, and so do you.

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

Postby [violet] » Mon Sep 05, 2022 7:11 pm

Right here. Also documented in the usual place.

For handy comparison, here are the three banner-related region shards.

User avatar
Ferranghia
Lobbyist
 
Posts: 11
Founded: Dec 10, 2015
Corrupt Dictatorship

Exp. notation in api XML

Postby Ferranghia » Mon Sep 12, 2022 11:20 am

Hi,

I've had a script running for the past three years which makes monthly reports on economic sectors and posts it as a dispatch on my nation.

All's been good until some weeks ago when for some reason the report was not posted. Fast forward to today (because I had no time to check) and, looking at the exception and census data, it seems there's a value that's being printed in the census XML in scientific notation, which the XML parser doesn't recognise.

The incriminating portion of the census is this

Code: Select all
<SCALE id="76">
<SCORE>4.271943e+15</SCORE>
<RANK>3442</RANK>
<RRANK>46</RRANK>
</SCALE>


Is this going to be fixed server side eventually, or should I start parsing the score manually?

Many thanks
Last edited by Ferranghia on Mon Sep 12, 2022 11:20 am, edited 1 time in total.
Admiral of Ferranghia and master of the puppet government of the_dorvan_protectorate_of_ferranghia
Slowly building the Nationstates API C# Library

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Cassiopeus, The Ambis

Advertisement

Remove ads