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
Caelapes
Ambassador
 
Posts: 1543
Founded: Apr 30, 2007
Ex-Nation

Postby Caelapes » Sat Feb 17, 2018 7:55 pm

When answering an issue through the private API, the RANKINGS returned for the Black Market and Economic Output census seem to be in billions - for example, if the nation’s Black Market is 11,220,000,000 currency units, the issue reports it as a SCORE of 11.22. These are the only census rankings I have noticed this behavior with.

Is this intentional? If so, why, and can we have a list of all census rankings that will return a different score when answering issues than by accessing the same census ID through the public census data shard?
Last edited by Caelapes on Sat Feb 17, 2018 8:03 pm, edited 1 time in total.
    
The Rose Commune of Caelapes
Ego vero custos fratris mei sum.
aka Misley

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

Postby [violet] » Sun Feb 18, 2018 5:13 pm

Caelapes wrote:When answering an issue through the private API, the RANKINGS returned for the Black Market and Economic Output census seem to be in billions - for example, if the nation’s Black Market is 11,220,000,000 currency units, the issue reports it as a SCORE of 11.22.

Fixed.

User avatar
Caelapes
Ambassador
 
Posts: 1543
Founded: Apr 30, 2007
Ex-Nation

Postby Caelapes » Tue Feb 20, 2018 3:01 pm

Eluvatar wrote:What's the problem with option 3, exactly?

"...begins noted windba— “in order..."

Trotterdam wrote:There's at least <sup> and <sub>, too.

Good to know.

[violet] wrote:
Caelapes wrote:When answering an issue through the private API, the RANKINGS returned for the Black Market and Economic Output census seem to be in billions - for example, if the nation’s Black Market is 11,220,000,000 currency units, the issue reports it as a SCORE of 11.22.

Fixed.

Thanks!
    
The Rose Commune of Caelapes
Ego vero custos fratris mei sum.
aka Misley

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

Postby Trotterdam » Tue Feb 20, 2018 4:56 pm

Caelapes wrote:
Eluvatar wrote:What's the problem with option 3, exactly?
"...begins noted windba— “in order..."
Like I said, there's supposed to be an em dash there. Open the XML file in a hex editor in order to see exactly what's going on.

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

Postby Trotterdam » Tue Feb 27, 2018 9:57 pm

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).
[violet] wrote: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.
I'd like to bring this request up again, since while I was previously interested in this mainly out of curiosity for the occasional manual request, I am now working on a script that would actually benefit from having this information.

Also, the recent server downtime reminded me: which HTTP status code should I be expecting if an API call failed due to the server being down? (In-browser users get the whole fancy error message page, even when looking at the API, but that's not useful for scripts.) Yeah, I didn't think to check this while it was actually happening, and now it's too late. (Must be a very rare case of a player being upset that the server is not down...)

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

Postby Trotterdam » Wed Feb 28, 2018 11:18 am

Trotterdam wrote:
Caelapes wrote:"...begins noted windba— “in order..."
Like I said, there's supposed to be an em dash there. Open the XML file in a hex editor in order to see exactly what's going on.
As an expansion on this: having just examined the source on an issue with dashes myself, I can confirm that the game uses &#150; for what should properly be &#8211; (or &ndash;), and so probably also elsewhere uses &#151; for what should properly be &#8212; (or &mdash;). While many browsers are likely to catch the mistake, on the basis of "enough people were making it that we'd better just display what they meant", a fully standards-compliant XML parser wouldn't.

(Since HTML/XML character references are used, rather than UTF-8, a hex editor wasn't needed. Offhand, I'm not sure if XML parsers actually recognize the same named references like &mdash; that HTML does, but &#8212; should always be safe.)

As a corollary, I recommend going through your en-dashes and em-dashes and making sure you're using them consistently, since I'm pretty sure other issues would have used em-dashes in the grammatical context where I found this one using en-dashes.

User avatar
Agadar
Powerbroker
 
Posts: 7784
Founded: Dec 06, 2009
Psychotic Dictatorship

Postby Agadar » Sat Mar 03, 2018 12:01 pm

Agadar wrote:Will it ever be possible to create or update dispatches via the API?

EDIT: On a similar note, it does not seem possible to retrieve a dispatch directly via its ID, forcing me to make a work-around for getting a dispatch's contents when I retrieve its ID via regional happenings. Any chance something like that will be added?


I'll assume from the lack of replies that the answer to both these questions is 'no'.

Another question: it is correct that there is no such thing as a happening for the closure of embassies? The closest thing I can find is the 'ordering' of a closure of embassies, but there is no happening type for the actual closure of embassies. This is unlike the regional history, which does contain closures. Is this design intended, or is it a bug?
Proud resident of The Western Isles, the #1 role-playing region!
Developer of Telegrammer, NS API Java Wrapper, and more!

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

Postby Trotterdam » Sat Mar 03, 2018 12:28 pm

Agadar wrote:Another question: it is correct that there is no such thing as a happening for the closure of embassies? The closest thing I can find is the 'ordering' of a closure of embassies, but there is no happening type for the actual closure of embassies. This is unlike the regional history, which does contain closures. Is this design intended, or is it a bug?
For some reason, it appears to be under filter=admin rather than filter=embassy. This is probably undesirable behavior, but it's technically just an undocumented feature.

(EDIT: The same is true of "construction of embassies aborted" happenings. This is similar to closures in that it's something happening immediately rather than being queued to happen in a week, but it's different in that it's almost always the result of a direct user action rather than a queued event resolving.)

I remember there once being a similar issue, with nations who are kicked out of the WA rather than voluntarily resigning being under filter=admin rather than filter=member. When I checked again recently, it seemed to be included under both categories.
Last edited by Trotterdam on Sat Mar 03, 2018 12:31 pm, edited 2 times in total.

User avatar
Agadar
Powerbroker
 
Posts: 7784
Founded: Dec 06, 2009
Psychotic Dictatorship

Postby Agadar » Sat Mar 03, 2018 1:50 pm

Trotterdam wrote:
Agadar wrote:Another question: it is correct that there is no such thing as a happening for the closure of embassies? The closest thing I can find is the 'ordering' of a closure of embassies, but there is no happening type for the actual closure of embassies. This is unlike the regional history, which does contain closures. Is this design intended, or is it a bug?
For some reason, it appears to be under filter=admin rather than filter=embassy. This is probably undesirable behavior, but it's technically just an undocumented feature.

(EDIT: The same is true of "construction of embassies aborted" happenings. This is similar to closures in that it's something happening immediately rather than being queued to happen in a week, but it's different in that it's almost always the result of a direct user action rather than a queued event resolving.)

I remember there once being a similar issue, with nations who are kicked out of the WA rather than voluntarily resigning being under filter=admin rather than filter=member. When I checked again recently, it seemed to be included under both categories.


You're right about the 'cancelled embassy' happenings being under the admin filter and not the embassy filter, however the 'construction aborted' happenings do seem to be under the embassy filter. Either way, it indeed seems like undesired behavior.
Proud resident of The Western Isles, the #1 role-playing region!
Developer of Telegrammer, NS API Java Wrapper, and more!

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

Postby Trotterdam » Sat Mar 03, 2018 2:23 pm

Agadar wrote:You're right about the 'cancelled embassy' happenings being under the admin filter and not the embassy filter, however the 'construction aborted' happenings do seem to be under the embassy filter. Either way, it indeed seems like undesired behavior.
http://www.nationstates.net/cgi-bin/api.cgi?q=happenings&filter=embassy&view=region.the_embassy includes happenings that look like these:
@@imperial_kraeshia@@ proposed constructing embassies between %%the_imperium_of_the_multiverse%% and %%the_embassy%%.
@@orobithe@@ ordered the closure of embassies between %%war_cresent%% and %%the_embassy%%.


http://www.nationstates.net/cgi-bin/api.cgi?q=happenings&filter=admin&view=region.the_embassy includes happenings that look like these:
Embassy cancelled between %%the_hellenic_kingdom%% and %%the_embassy%%.
Construction of embassies aborted between %%world_trade_centre%% and %%the_embassy%%.

User avatar
Agadar
Powerbroker
 
Posts: 7784
Founded: Dec 06, 2009
Psychotic Dictatorship

Postby Agadar » Sat Mar 03, 2018 2:49 pm

Trotterdam wrote:
Agadar wrote:You're right about the 'cancelled embassy' happenings being under the admin filter and not the embassy filter, however the 'construction aborted' happenings do seem to be under the embassy filter. Either way, it indeed seems like undesired behavior.
http://www.nationstates.net/cgi-bin/api.cgi?q=happenings&filter=embassy&view=region.the_embassy includes happenings that look like these:
@@imperial_kraeshia@@ proposed constructing embassies between %%the_imperium_of_the_multiverse%% and %%the_embassy%%.
@@orobithe@@ ordered the closure of embassies between %%war_cresent%% and %%the_embassy%%.


http://www.nationstates.net/cgi-bin/api.cgi?q=happenings&filter=admin&view=region.the_embassy includes happenings that look like these:
Embassy cancelled between %%the_hellenic_kingdom%% and %%the_embassy%%.
Construction of embassies aborted between %%world_trade_centre%% and %%the_embassy%%.


That's messy. I'm currently implementing code to filter between different (embassy) happening types, and this certainly complicates things even further.

EDIT: Similarly messy, there are 'ejected' and 'banned' happening under the 'eject' filter, and there are also 'banned' happenings under the 'admin' filter, but with a different format, and no 'ejected' happenings.
Last edited by Agadar on Sat Mar 03, 2018 3:57 pm, edited 2 times in total.
Proud resident of The Western Isles, the #1 role-playing region!
Developer of Telegrammer, NS API Java Wrapper, and more!

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

Postby [violet] » Tue Mar 06, 2018 8:02 pm

Trotterdam wrote:As an expansion on this: having just examined the source on an issue with dashes myself, I can confirm that the game uses &#150; for what should properly be &#8211; (or &ndash;), and so probably also elsewhere uses &#151; for what should properly be &#8212; (or &mdash;).

Hmm! Thanks for that. I've corrected them. Not sure how they got escaped that way.

I'm pretty sure they were all em dashes originally.

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

Postby Trotterdam » Wed Mar 07, 2018 11:24 pm

You know, I noticed something odd in the API:
http://www.nationstates.net/cgi-bin/api.cgi?q=censusdesc&scale=255
<WORLD>
<CENSUSDESC id="255">
<NDESC>The World Census tracked the movements of military-grade geo-airlifting helicopters to determine which regions have the most nations.</NDESC>
<RDESC>The World Census tracked the movements of military-grade geo-airlifting helicopters to determine which regions have the most regions.</RDESC>
</CENSUSDESC>
</WORLD>
Looks like the NDESC contains what's supposed to be the RDESC (and is used as such when browsing the census normally), and the RDESC just doesn't make sense.

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

Postby Trotterdam » Sun Mar 18, 2018 8:43 pm

Two things, both of which, might be intentional, but warrant examination.

http://www.nationstates.net/cgi-bin/api.cgi?q=censusscale&scale=75
<CENSUSSCALE id="75">Edu-tellignce\u00AE Test Score</CENSUSSCALE>
1. Is the missing "e" between "g" and "n" intentional irony or a typo?
2. Transmitting the character as "\u00AE" is rather inconvenient and seems likely to be a mistake, compared to either sending the actual UTF-8 bytes or using "&#xAE;" which can be automatically recognized by any XML parser. Is there anywhere else I might expect this behavior?
Last edited by Trotterdam on Sun Mar 18, 2018 8:44 pm, edited 1 time in total.

User avatar
Flanderlion
Minister
 
Posts: 2226
Founded: Nov 25, 2013
Psychotic Dictatorship

Postby Flanderlion » Thu Mar 29, 2018 10:49 pm

Eluvatar wrote:
Aurum Raider wrote:The only thing we can't get from the API that I might want is a region shard telling me when the region is going to update, but going out on a limb, I'd assume that isn't going to happen :p


Why not?

Would we be able to get a Last Minor and Last Major shard in addition to the Last Update shard?
As always, I'm representing myself.
Information
Wishlist

User avatar
Personal Freedom
Postmaster-General
 
Posts: 11257
Founded: Oct 08, 2012
Civil Rights Lovefest

Postby Personal Freedom » Sun Apr 01, 2018 12:08 pm

How do I recover my telegram api number?
Last edited by Personal Freedom on Sun Apr 01, 2018 12:08 pm, edited 1 time in total.
Economic Left/Right: -10.0 (previously -6.45)
Social Libertarian/Authoritarian: -7.18 (previously -4.72 )
'Twas brillig, and the slithy toves;
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.

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

Postby Eluvatar » Sun Apr 01, 2018 7:23 pm

If I understand your meaning, here.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Borogravia Moldavi
Political Columnist
 
Posts: 5
Founded: Antiquity
Ex-Nation

Postby Borogravia Moldavi » Mon Apr 02, 2018 9:14 am

[violet] wrote:
Leppikania wrote:The "nations" shard is broken:
System Error (eval) at Mon Apr 11 19:07:38 2016.
This won't go away.

Aha! I saw the error in the server logs and fixed it already. Boo yah!


Getting this when I try to look at my deck:
Your Deck

System Error (eval) at Mon Apr 2 09:14:05 2018.

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

Postby Eluvatar » Mon Apr 02, 2018 2:45 pm

You had a bugged nation among your cards. It has been unceremoniously plopped into the Rejected Realms. You eject nations even without meaning to, clearly.

Your deck looks fine now.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
HMS Unicorn
Spokesperson
 
Posts: 199
Founded: Jun 29, 2005
Ex-Nation

Postby HMS Unicorn » Sun Apr 08, 2018 4:26 pm

HMS Unicorn wrote:Personally I'd like to see the SPDR census included [edit: in the daily nation dump]. The reason for this is that I often have to process region-wide SPDR rankings in large regions (TNP, other GCRs, Europeia). Doing so currently requires a very large number of API calls to fetch all of the regional census=65 rankings and values. Having this information available in the nation dumps would make this process much easier and less bandwidth-intensive.

Would it be possible to revisit this suggestion?

It was brought up here, and several players mentioned they would benefit from the addition. But the discussion soon digressed to including LASTUPDATE in the dumps.

It'd save me a few dozens of thousands of API calls per day, and I imagine it's the same for many other players.
Last edited by HMS Unicorn on Sun Apr 08, 2018 10:32 pm, edited 1 time in total.

User avatar
Caelapes
Ambassador
 
Posts: 1543
Founded: Apr 30, 2007
Ex-Nation

Postby Caelapes » Sun Apr 08, 2018 5:14 pm

I can’t say that it’d save thousands on our end, but I concur with the value of including SPDR in daily dumps, along with the potential of having two LASTUPDATE times (previous major and minor).
    
The Rose Commune of Caelapes
Ego vero custos fratris mei sum.
aka Misley

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

Postby Eluvatar » Mon Apr 09, 2018 6:23 am

As I'm still reluctant to pull out one census score as something that goes into the daily dumps, I'm considering making a new API for this purpose. I will lay out an approximate design in this post and ask for comments from the interested parties.

There would be a new thing called a 'report':
  1. A report could be generated through the private API with a set of parameters such as q=region.nations+nation.name+nation.scale&scale=65&mode=score&region=europeia
  2. A valid request to generate a report would get a 202 (Accepted) response back
  3. A report which has been generated would stick around for some period of time (24h? until a newer report has been generated with the same dataset?).
  4. We'd watch reports creation and possibly introduce extra rate limitations
  5. There would be a public index of available reports, searchable by the parameters, and returning URLs
  6. The index would include reports that are in progress and mark them as such
  7. The report itself would be publicly accessible at some particular URL and would return 503 until it was complete
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
HMS Unicorn
Spokesperson
 
Posts: 199
Founded: Jun 29, 2005
Ex-Nation

Postby HMS Unicorn » Tue Apr 10, 2018 8:41 am

I am not sure why selecting one particular census for inclusion in the daily dumps is such a big deal, given that there are already many other censuses that have been selectively included in the daily dumps.

As best as I can tell from the description, the "report" function would work fine for me, and I imagine it would be very useful for others that want to parse large volumes of statistics, for SPDR or other censuses. However, my main concern is whether implementing this whole new feature would mean that a solution would not be available for quite some time.

If adding reports would take several months, personally I'd strongly prefer to have the simpler solution of inclusion of SPDR in the daily dumps.

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

Postby Leppikania » Tue Apr 10, 2018 4:38 pm

Why would it need to be with the private API?
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
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Tue Apr 10, 2018 6:30 pm

An alternative would be to require an API key. The intent, either way, would be to better avoid abuse.

What censuses do you refer to as having been selectively included?
To Serve and Protect: UDL

Eluvatar - Taijitu member

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Ammmericaaaa, Bagong Timog Mindanao, Bisofeyr, Danternoust, Geopolity, Ioudaia, Lemsrow, Madrocea, North American Imperial State, Wing Como, Zakaruba

Advertisement

Remove ads