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
Kethania
Lobbyist
 
Posts: 21
Founded: Nov 01, 2015
Left-wing Utopia

Postby Kethania » Thu Jun 01, 2017 1:24 pm

[violet] wrote:The API doc has been updated with instructions on how to answer issues via API. This is the first "Private Command" where you can actually make your nation do stuff via the API, not just gather information about it.

Wonderful!

The wording here makes me assume there are more commands to come, is that correct? If so, will there be the same system as with shards for joining several commands into one request?
It appears to be impossible to request a nation shard and execute a command in a single call, is that the intended behaviour?

I would also like to report a nasty encoding bug in the API. Specifically, I get this mess:
Code: Select all
<NATION id="saidual"><MOTTO>Oi oi its the &#x97;unicode&#x97;police&#x97;</MOTTO></NATION>

The EM DASH character is replaced by END OF GUARDED AREA. This problem only affects the API, but I have seen it also show up when dealing with dispatch shards, so I am assuming it's not local.
The issue appears to be that somewhere on the server Windows-1252 encoded text is wrongly decoded as ISO-8859-1, then passed to the clients as an NCR. While it is technically possible to write a function to unscramble this mess, I'd rather prefer not having to do that :p

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

Postby [violet] » Thu Jun 01, 2017 3:22 pm

Kethania wrote:The wording here makes me assume there are more commands to come, is that correct?

Yes. It's a "squeaky wheel" kind of situation, where I'll probably implement what gets asked for the most persistently, since otherwise I can't tell what script authors are most keen to use.

Kethania wrote:If so, will there be the same system as with shards for joining several commands into one request?

Probably not. Chaining commands makes sense when you're grabbing information, because (a) the heaviest part of that for us is usually the initial nation load, so once we've done that, we can supply whatever data you want; and (b) there are no issues with state change. That's not the case when you're issuing commands that actually change your nation. There's also potential complication based around which commands get executed in what order.

Kethania wrote:It appears to be impossible to request a nation shard and execute a command in a single call, is that the intended behaviour?

Correct. You can't do both at the same time.

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

Postby [violet] » Thu Jun 01, 2017 3:41 pm

Kethania wrote:I would also like to report a nasty encoding bug in the API. Specifically, I get this mess:
Code: Select all
<NATION id="saidual"><MOTTO>Oi oi its the &#x97;unicode&#x97;police&#x97;</MOTTO></NATION>

The EM DASH character is replaced by END OF GUARDED AREA. This problem only affects the API, but I have seen it also show up when dealing with dispatch shards, so I am assuming it's not local.

Unfortunately I'm not sure this is fixable, because our character encoding is a disaster area. The site began in the lovely ASCII era of 2002 and has grown a few hacks to support extended character sets since then, but it doesn't have proper Unicode support. I've looked a few times at adding it, but we have such a mishmash of different encodings spread across millions of files and data sets, I'm not sure I'll ever get there.

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

Postby Eluvatar » Sun Jun 04, 2017 7:08 pm

Eluvatar wrote:
Drachmaland wrote:Would it be possible that NS API incorporates a new public shard to query a nation's id number?
I'm referring to the number that is currently used to resolve WA census ties in the ranking system.

It would certainly be possible. As [v] and I don't see a problem with doing it, it'll probably be done soon.

It's been done.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Drachmaland
Chargé d'Affaires
 
Posts: 439
Founded: Dec 14, 2014
Ex-Nation

Postby Drachmaland » Mon Jun 05, 2017 12:42 am

Eluvatar wrote:
Drachmaland wrote:Would it be possible that NS API incorporates a new public shard to query a nation's id number?
I'm referring to the number that is currently used to resolve WA census ties in the ranking system.

It's been done.

Code: Select all
q=dbid

Thanks a lot, Eluvatar! :bow:

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

Postby Agadar » Mon Jun 05, 2017 2:23 pm

Is there something of a changelog of the NS API available to us? As maintainer of one of the client libraries for the NS API, I find myself having to scour this thread for all the changes.
Proud resident of The Western Isles, the #1 role-playing region!
Developer of Telegrammer, NS API Java Wrapper, and more!

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

Postby Caelapes » Thu Jun 08, 2017 10:28 am

Eluvatar wrote:It's been done.

Is there any way of getting DBIDs for ex-nations?
    
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 » Thu Jun 08, 2017 6:10 pm

Caelapes wrote:
Eluvatar wrote:It's been done.

Is there any way of getting DBIDs for ex-nations?

Not at this time. Why do you want it?
Agadar wrote:Is there something of a changelog of the NS API available to us? As maintainer of one of the client libraries for the NS API, I find myself having to scour this thread for all the changes.

Not at this time. If someone were to make a record of API changes so far, however, I'm surmise that could be kept up going forward.
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby Caelapes » Thu Jun 08, 2017 7:23 pm

Eluvatar wrote:
Caelapes wrote:Is there any way of getting DBIDs for ex-nations?

Not at this time. Why do you want it?

Was just curious if it was possible.

Are there DBIDs for regions? If so, would it be possible to get a shard for them?
    
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 » Thu Jun 08, 2017 7:39 pm

Caelapes wrote:
Eluvatar wrote:Not at this time. Why do you want it?

Was just curious if it was possible.

Are there DBIDs for regions? If so, would it be possible to get a shard for them?

Drachmaland had a specific ask for dbid:
Drachmaland wrote:Would it be possible that NS API incorporates a new public shard to query a nation's id number?
I'm referring to the number that is currently used to resolve WA census ties in the ranking system.


What would the DBID of regions (or ex-nations that have them) tell you that you want to know?
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby Caelapes » Thu Jun 08, 2017 7:41 pm

Eluvatar wrote:What would the DBID of regions (or ex-nations that have them) tell you that you want to know?

Well, with all the secrecy around them, it's a fishing expedition to see what we can figure out from them. :P
    
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 » Thu Jun 08, 2017 8:07 pm

Caelapes wrote:
Eluvatar wrote:What would the DBID of regions (or ex-nations that have them) tell you that you want to know?

Well, with all the secrecy around them, it's a fishing expedition to see what we can figure out from them. :P

Helping you fish is not as exciting to me as other projects. :ugeek:

(Fifteen miles! In the snow! Uphill! Both ways! Off my lawn!)
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Drachmaland
Chargé d'Affaires
 
Posts: 439
Founded: Dec 14, 2014
Ex-Nation

Postby Drachmaland » Thu Jun 08, 2017 11:36 pm

Eluvatar wrote:What would the DBID of regions (or ex-nations that have them) tell you that you want to know?

Isn't the regions' DBID the factor that resolves WA census ties in the ranking of regions?

And as far as ex-nations go, I believe the API can't query for them at all, can it?

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

Postby Caelapes » Fri Jun 09, 2017 7:24 am

Drachmaland wrote:
Eluvatar wrote:What would the DBID of regions (or ex-nations that have them) tell you that you want to know?

Isn't the regions' DBID the factor that resolves WA census ties in the ranking of regions?

Hey! There we go. That's precisely why I want it.

Drachmaland wrote:And as far as ex-nations go, I believe the API can't query for them at all, can it?

Correct. The API returns a 404 error code for nations that do not currently exist.
    
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 » Fri Jun 09, 2017 5:09 pm

Caelapes wrote:
Drachmaland wrote:Isn't the regions' DBID the factor that resolves WA census ties in the ranking of regions?

Hey! There we go. That's precisely why I want it.


Of course.

This will probably be added fairly soon.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Greater Tern
Envoy
 
Posts: 331
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Sat Jun 10, 2017 6:59 pm

[v] or Elu -- for the issues API, could you guys wrap the <DESC> field in a CDATA? Stately's deserializer freaks out when it runs into characters like '%' or 'é'. Wrapping it in CDATA should let it deserialize the data properly.

EDIT: Same thing for the <HEADLINE> tags as well.
Last edited by Greater Tern on Sat Jun 10, 2017 8:30 pm, edited 2 times in total.

User avatar
Auralia
Senator
 
Posts: 4982
Founded: Dec 15, 2011
Ex-Nation

Postby Auralia » Sun Jun 11, 2017 5:55 am

[violet], would it be possible to exempt OPTIONS requests from the API rate limit? From a JS in-browser POV, it's difficult to know whether a request will trigger an additional OPTIONS request by the browser because of CORS -- this makes it difficult to do rate limiting.
Catholic Commonwealth of Auralia
"Amor sequitur cognitionem."

User avatar
Kethania
Lobbyist
 
Posts: 21
Founded: Nov 01, 2015
Left-wing Utopia

Postby Kethania » Wed Jun 14, 2017 1:02 pm

Would it be possible for the macros (such as @@NAME@@, @@DEMONYM@@, etc.) to be expanded in the HEADLINE elements from the issue API command, the way they are in DESC from the same command, as well as OPTIONs and TEXT from the issues private shard?

Also, the OK/ERROR system seems rather redundant. Can't you simply use HTTP codes?

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

Postby Eluvatar » Sun Jun 18, 2017 6:26 am

Auralia wrote:[violet], would it be possible to exempt OPTIONS requests from the API rate limit? From a JS in-browser POV, it's difficult to know whether a request will trigger an additional OPTIONS request by the browser because of CORS -- this makes it difficult to do rate limiting.


Unfortunately currently the API will give the full response in reply to an OPTIONS request, so exempting OPTIONS requests would let people get around the API rate limit entirely. Changing this will be considered.

Kethania wrote:Would it be possible for the macros (such as @@NAME@@, @@DEMONYM@@, etc.) to be expanded in the HEADLINE elements from the issue API command, the way they are in DESC from the same command, as well as OPTIONs and TEXT from the issues private shard?

Also, the OK/ERROR system seems rather redundant. Can't you simply use HTTP codes?

What ok/error system do you mean? Do you mean for TG queueing?
Last edited by Eluvatar on Sun Jun 18, 2017 6:27 am, edited 1 time in total.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Greater Tern
Envoy
 
Posts: 331
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Sun Jun 18, 2017 6:36 am

Eluvatar wrote:What ok/error system do you mean? Do you mean for TG queueing?

I think they're referring to the new issues API, which either returns an <OK> tag if the request was successful (along with the rest of the response), or an <ERROR> tag if the request failed. It might make more sense to just return the issue response by itself and HTTP 200 if it was successful, or return some HTTP 400 error code if it failed for some reason.

Also bumping my request to add the CDATA tag to the issues response. ^^

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

Postby [violet] » Sun Jun 18, 2017 6:11 pm

Greater Tern wrote:
Eluvatar wrote:What ok/error system do you mean? Do you mean for TG queueing?

I think they're referring to the new issues API, which either returns an <OK> tag if the request was successful (along with the rest of the response), or an <ERROR> tag if the request failed. It might make more sense to just return the issue response by itself and HTTP 200 if it was successful, or return some HTTP 400 error code if it failed for some reason.

The API is just dumping out what our internal system already provides, which is simpler than building a separate signaling system. I think that's fine.

User avatar
Greater Tern
Envoy
 
Posts: 331
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Mon Jun 19, 2017 8:13 am

[violet] wrote:The API is just dumping out what our internal system already provides, which is simpler than building a separate signaling system. I think that's fine.

Fair enough. Would you be able to modify it though to wrap the content in <DESC> and <HEADLINE> inside a CDATA tag?

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

Postby Caelapes » Mon Jun 19, 2017 6:49 pm

Since moderator-deleted nations are identifiable through the Boneyard (and thus it is not a secret that any nation has been moderator-deleted, just the reasoning) would it be possible to get some kind of indication in the nation's CTE happening (X has ceased to exist) that it was a moderator deletion?

Perhaps, only when the deletion is moderator-enacted, have an additional "TYPE" declaration as such:

Code: Select all
<EVENT id="156530714">
   <TIMESTAMP>1497896108</TIMESTAMP>
   <TEXT>
      <![CDATA[ @@bitler101@@ ceased to exist in %%the_pacific%%. ]]>
   </TEXT>
   <TYPE>DEAT</TYPE>
</EVENT>


or have TYPE declared for all, with 0 for regular lack-of-activity CTEs and 1 for moderator DEATs?
Last edited by Caelapes on Mon Jun 19, 2017 7:17 pm, edited 1 time in total.
    
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 Jun 19, 2017 7:22 pm

I think that you can probably tell whether or not it was time for that nation to be updating, no?
To Serve and Protect: UDL

Eluvatar - Taijitu member

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

Postby Caelapes » Mon Jun 19, 2017 7:25 pm

Eluvatar wrote:I think that you can probably tell whether or not it was time for that nation to be updating, no?

Not always. If the nation CTEs well after update, it's obvious, but sometimes mods DEAT nations during update and currently there is no way to tell if it's from activity or moderators without scraping the Boneyard.
    
The Rose Commune of Caelapes
Ego vero custos fratris mei sum.
aka Misley

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Ballistikov, Comfed, Majestic-12 [Bot], Orcland, The Lone Alliance, The United Kindom under Socialist Rule

Advertisement

Remove ads