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
Trotterdam
Postmaster-General
 
Posts: 10545
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Tue Jan 16, 2024 2:36 am

Refuge Isle wrote:The standard nation API call appears to occasionally deliver a different response than a call to the motto shard, specifically, when it comes to certain special characters:

https://www.nationstates.net/cgi-bin/ap ... opireistan
> It's pronounced /'apôrt-is-tō-pirī-stan/.

https://www.nationstates.net/cgi-bin/ap ... an&q=motto
> It's pronounced /'apôrt-is-tō-pirī-stan/.
An interesting bit of trivia, but a standards-compliant XML parser should parse those both into the same string? I suppose it's an inconvenience if you're using regexps or a homebrew XML parser instead of a properly standards-compliant one.

Wait, no, that's incorrect. I checked the actual exact bytes for the latter link, which turns out to be "/'apôrt-is-tō-pirī-stan/". In other words, the server is double-encoding the string: first transforming "ō" to "ō" (which is correct), but then re-transforming "&" to "&" (which is incorrect, and will cause XML parsers to think the ampersand is "actually supposed to be there" instead of a character entity reference). Interestingly, the first link performs neither transformation (transmitting the string directly in UTF-8), so there's somehow two different steps that get added between the two.

I'm more also concerned over certain other parts of the API encoding characters in what appears to be JSON instead of XML, which is definitely not standards-compliant, and which I reported six years ago and still hasn't been fixed.
Last edited by Trotterdam on Tue Jan 16, 2024 2:42 am, edited 1 time in total.

User avatar
Notanam
Envoy
 
Posts: 227
Founded: Feb 21, 2019
Civil Rights Lovefest

Postby Notanam » Tue Feb 13, 2024 7:14 pm

Right now, the officers shard of the region API doesn't return the governor if they are not otherwise an RO. Since the governor is presented as an RO on the site, could they be added to the shard (with possibly some indicator that said nation is the governor)?

This would also allow for a way to access the name of the governor position of a region through API, which if I recall correctly doesn't currently exist.
Last edited by Notanam on Tue Feb 13, 2024 7:17 pm, edited 2 times in total.
This is Nota's signature.

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

Postby Merni » Sat Feb 17, 2024 12:18 am

Notanam wrote:Right now, the officers shard of the region API doesn't return the governor if they are not otherwise an RO. Since the governor is presented as an RO on the site, could they be added to the shard (with possibly some indicator that said nation is the governor)?

This would also allow for a way to access the name of the governor position of a region through API, which if I recall correctly doesn't currently exist.

Additionally, the "governor" shard of the region API, which does exist (and returns the name of the governor), is still undocumented.
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
Imperium Anglorum
GA Secretariat
 
Posts: 12664
Founded: Aug 26, 2013
Left-Leaning College State

Postby Imperium Anglorum » Mon Apr 01, 2024 8:19 am

Is there a list of the response codes that the API returns on errors? I'm aware only of 429 and 404.

Author: 1 SC and 56+ GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and InfoEurope
GenSec (24 Dec 2021 –); posts not official unless so indicated
Delegate for Europe
Elsie Mortimer Wellesley
Ideological Bulwark 285, WALL delegate
Twice-commended toxic villainous globalist kittehs

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

Postby Trotterdam » Mon Apr 01, 2024 9:08 am

Imperium Anglorum wrote:Is there a list of the response codes that the API returns on errors? I'm aware only of 429 and 404.
I don't think there's a concrete list, since any error that can happen on normal HTTP requests can also happen on the API, including some errors that are caused by CloudFlare if the request never even reaches the real server.

The only error codes that I'm aware of as being caused by the API itself as an actual response to the user's query, instead of indicating that the query failed to be processed at all, are 404 (if you attempt to query a nation that doesn't exist, including one that was deleted just seconds ago by the moderators - notably does not indicate that the query itself was malformed), 429 (if you run afoul of the ratelimit), 403 (if you supply a wrong password to a private shard/command, not applicable to public shards), and 409 (if you attempt to log in in too rapid succession, likewise only relevant to private shards/commands).

User avatar
Great Schwanien
Political Columnist
 
Posts: 3
Founded: Jan 21, 2024
Left-wing Utopia

Postby Great Schwanien » Tue Apr 02, 2024 8:19 am

Sorry, if this has been asked before, but, as far I can see, the API only supports XML. Are there plans for adding JSON support?

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

Postby United Calanworie » Tue Apr 02, 2024 10:49 am

Plans? Yes. In progress? Eeehhhhh.
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
Imperium Anglorum
GA Secretariat
 
Posts: 12664
Founded: Aug 26, 2013
Left-Leaning College State

Postby Imperium Anglorum » Sat Apr 06, 2024 10:41 pm

Is there a shard which would tell someone the type of telegram given a secret key and telegram ID?

Author: 1 SC and 56+ GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and InfoEurope
GenSec (24 Dec 2021 –); posts not official unless so indicated
Delegate for Europe
Elsie Mortimer Wellesley
Ideological Bulwark 285, WALL delegate
Twice-commended toxic villainous globalist kittehs

Previous

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: North American Imperial State

Advertisement

Remove ads