NATION

PASSWORD

NationStates API (nationdata/regiondata)

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.

Remove ads

User avatar
Poopsadon
Civil Servant
 
Posts: 9
Founded: Jul 10, 2012
Anarchy

Postby Poopsadon » Sat Mar 11, 2017 2:43 pm

Does anyone know if there is a recommended way to make calls to answer issues. At the moment my understanding is the the API lets you access data but not modify anything but if I'm mistaken I'd be curious to know how.

My hope was to make a simple script to comb through a series of my puppets and randomly determine their daily fate :P

User avatar
Trotterdam
Minister
 
Posts: 3174
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Sat Mar 11, 2017 4:58 pm

I don't think there is currently an API call for that. A private API shard is expected at some point in the indefinite future, but currently even the private API shards are all read-only.

Unless [violet] is willing to take the time to add that, your best option is to write a non-API script that uses the same issue-answering URL human players do. Note that non-API scripts have different rules from API-using scripts, the most important one of which (for your application) is that the ratelimit is 10 per minute instead of 100 per minute.

Note that you can make things a little easier on both your script and the server by appending /template-overall=none to the URL, for example http://www.nationstates.net/page=dilemmas/template-overall=none. I'm not sure where I learned that, the linked script rules seem to make no mention of it.

Or more topically, http://www.nationstates.net/page=enact_dilemma/dilemma=X/choice-Y=1/template-overall=none (don't click on that!), where X is the number of the issue, and Y is the internal number of the option (usually one less than the displayed number, so 0 for the first option, 1 for the second option, etc., but can be different if some options don't appear due to option validities, and -1 for dismissal).

User avatar
Poopsadon
Civil Servant
 
Posts: 9
Founded: Jul 10, 2012
Anarchy

Postby Poopsadon » Sun Mar 12, 2017 12:36 am

Trotterdam wrote:I don't think there is currently an API call for that. A private API shard is expected at some point in the indefinite future, but currently even the private API shards are all read-only.

Unless [violet] is willing to take the time to add that, your best option is to write a non-API script that uses the same issue-answering URL human players do. Note that non-API scripts have different rules from API-using scripts, the most important one of which (for your application) is that the ratelimit is 10 per minute instead of 100 per minute.

Note that you can make things a little easier on both your script and the server by appending /template-overall=none to the URL, for example http://www.nationstates.net/page=dilemmas/template-overall=none. I'm not sure where I learned that, the linked script rules seem to make no mention of it.

Or more topically, http://www.nationstates.net/page=enact_dilemma/dilemma=X/choice-Y=1/template-overall=none (don't click on that!), where X is the number of the issue, and Y is the internal number of the option (usually one less than the displayed number, so 0 for the first option, 1 for the second option, etc., but can be different if some options don't appear due to option validities, and -1 for dismissal).


This is tremendously helpful; thank you! I was unaware of the template-overall=none trick but it definitely makes it easier to pick out the info I need.

User avatar
Imperium Anglorum
Negotiator
 
Posts: 6016
Founded: Aug 26, 2013
Civil Rights Lovefest

Postby Imperium Anglorum » Mon Mar 13, 2017 5:17 am

A bug report. Currently, when calling this query:

Code: Select all
https://www.nationstates.net/cgi-bin/api.cgi?wa=1&id=257&q=resolution

For the /WA/RESOLUTION/OPTION/text() field, I get 0 instead of the actual Area of Effect/Strength, Automobile Manufacturing.

This is the same with most other categories as well. For Mild resolutions, it shows 0 instead of Mild.
Last edited by Imperium Anglorum on Wed Mar 15, 2017 12:43 am, edited 1 time in total.
Delegate of Europe
Her Excellency Elsie Mortimer Wellesley PC MP
Ideological Bulwark 285

User avatar
Imperium Anglorum
Negotiator
 
Posts: 6016
Founded: Aug 26, 2013
Civil Rights Lovefest

Postby Imperium Anglorum » Fri Mar 17, 2017 8:19 am

Also, would it be possible to have an API query which tells us what kind of telegram is being sent? Something like:

Code: Select all
https://www.nationstates.net/cgi-bin/api.cgi?a=infoTG&tgid=(TGID)&key=(Secret Key)

Returning information on the telegram itself, like the delivery data, by whom the telegram was blocked, and what kind of telegram is being sent (recruitment, campaign, unmarked).
Delegate of Europe
Her Excellency Elsie Mortimer Wellesley PC MP
Ideological Bulwark 285

User avatar
HMS Unicorn
Spokesperson
 
Posts: 163
Founded: Jun 29, 2005
Inoffensive Centrist Democracy

Postby HMS Unicorn » Mon Mar 20, 2017 3:57 pm

Imperium Anglorum wrote:Also, would it be possible to have an API query which tells us what kind of telegram is being sent? Something like:

Code: Select all
https://www.nationstates.net/cgi-bin/api.cgi?a=infoTG&tgid=(TGID)&key=(Secret Key)

Returning information on the telegram itself, like the delivery data, by whom the telegram was blocked, and what kind of telegram is being sent (recruitment, campaign, unmarked).

This would be tremendously useful.

User avatar
Agadar
Powerbroker
 
Posts: 7608
Founded: Dec 06, 2009
Civil Rights Lovefest

Postby Agadar » Mon Mar 20, 2017 4:11 pm

Imperium Anglorum wrote:Also, would it be possible to have an API query which tells us what kind of telegram is being sent? Something like:

Code: Select all
https://www.nationstates.net/cgi-bin/api.cgi?a=infoTG&tgid=(TGID)&key=(Secret Key)

Returning information on the telegram itself, like the delivery data, by whom the telegram was blocked, and what kind of telegram is being sent (recruitment, campaign, unmarked).

I'd be glad with something as simple as an API call that requires a telegram id and returns the type of the corresponding telegram template (recruitment/campaign/unmarked). With something like that, us auto-telegrammer developers wouldn't have to rely any more on the users -possibly incorrectly- supplying the telegram type (which we need to know for the rate limits).

Never mind the above, I misread your feature request. I thought you meant for the telegram API to return that data, but you mean for an entirely new API call to do so. I would like something like that as well.
Last edited by Agadar on Mon Mar 20, 2017 4:13 pm, edited 1 time in total.
Information Secretary of The Western Isles, the #1 role-playing region!
Developer of Telegrammer, NS API Java Wrapper, and more!

User avatar
Imperium Anglorum
Negotiator
 
Posts: 6016
Founded: Aug 26, 2013
Civil Rights Lovefest

Postby Imperium Anglorum » Mon Mar 20, 2017 6:42 pm

Agadar wrote:With something like that, us auto-telegrammer developers wouldn't have to rely any more on the users -possibly incorrectly- supplying the telegram type (which we need to know for the rate limits).

I too trust my code more than the users. :P
Delegate of Europe
Her Excellency Elsie Mortimer Wellesley PC MP
Ideological Bulwark 285

User avatar
Panther Ausf G
Civilian
 
Posts: 1
Founded: Feb 11, 2016
Ex-Nation

Postby Panther Ausf G » Fri Mar 31, 2017 7:07 pm

Granted, this is likely a one-off thing, but is there a chance that we can get some API shards for the nuclear war, if possible?

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

Postby [violet] » Fri Mar 31, 2017 10:06 pm

Unfortunately it's not feasible to create API support for one-off events.

User avatar
TKS 20mm
Civilian
 
Posts: 1
Founded: Feb 12, 2016
Ex-Nation

Postby TKS 20mm » Sat Apr 01, 2017 1:35 am

Figured as much, but might as well ask anyway!
Thanks for the response ^^

User avatar
Drachmaland
Chargé d'Affaires
 
Posts: 428
Founded: Dec 14, 2014
Civil Rights Lovefest

Postby Drachmaland » Fri May 26, 2017 6:21 am

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.
Minister of The West Pacific Ministry of WA Affairs ☼ ex-Guardian of TWP — Snark LordMinister of The West Pacific Ministry of NS Daily Issues

User avatar
HMS Unicorn
Spokesperson
 
Posts: 163
Founded: Jun 29, 2005
Inoffensive Centrist Democracy

Postby HMS Unicorn » Sun May 28, 2017 8:39 am

Request

Would it be possible to add a shard providing the most recent date a nation joined the WA (or, say, 0 if the nation is not a member)?

This would be very helpful for various regional surveys we conduct in TNP and Europeia, to try to improve our WA membership rates.

I understand that the utility of this is relatively limited, but if this is something the game already tracks and can be easily added to the API, it would be very convenient. Otherwise, I can get this information from elsewhere.

Thanks!

User avatar
Roavin
Envoy
 
Posts: 262
Founded: Apr 07, 2016
Left-wing Utopia

Postby Roavin » Mon May 29, 2017 5:51 pm

Request

Is there a way to make the happenings shard easier to parse and store? At the moment, only the <TEXT> tag is included, and script authors relying on happenings must manually parse that text. While parsing out nations/regions are easy due to the use of tags with their canonical name (so we can just regex-match), other things are not so easy. Useful tags may be:
  • <REGION> - self-explanatory, optional
  • <NATION> - self-explanatory, optional
  • <TYPE> - This could be one of the filter types (law, cte, etc., or "other" for custom happenings)
  • <ISSUE_ID> - If this is a law happening, the ID of the issue that was answered
  • <ISSUE_ANSWER> - If this is a law happening, which answer was given for that issue
  • <INFLUENCE> - for Influence rank changes, from and to
  • ...etc...

I store happenings in a database, currently with a TEXT column plus pre-parsed region1, region2, nation1, nation2 columns for search. I intend to expand that to include at least the type, and possibly modify it so that when it's unambiguous, the text column is just NULLed to save space in the database. Besides, it just makes it easier to search in the DB in general - I can build indices, do funky joins, what have you.
Nakari wrote:You'd make an excellent evil genius if you weren't so nice.
Cormac wrote:Where I have shitposting down to a science, the Wardens have it down to an art.

Ohai there! I'm Scardino's Fendabro!
The South Pacific - Legislator, SPSF Officer
The Order of the Grey Wardens - First Warden
Unless explicitly stated otherwise, the opinions expressed in the above post are my own and not representative of any region I'm a part of.

Kitzerland: Senpai notices you :o

User avatar
Eluvatar
Tech Modling
 
Posts: 1207
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Mon May 29, 2017 6:26 pm

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.
HMS Unicorn wrote:Request

Would it be possible to add a shard providing the most recent date a nation joined the WA (or, say, 0 if the nation is not a member)?

This would be very helpful for various regional surveys we conduct in TNP and Europeia, to try to improve our WA membership rates.

I understand that the utility of this is relatively limited, but if this is something the game already tracks and can be easily added to the API, it would be very convenient. Otherwise, I can get this information from elsewhere.

Thanks!


The feature you request cannot easily be done.

Roavin wrote:Request

Is there a way to make the happenings shard easier to parse and store? At the moment, only the <TEXT> tag is included, and script authors relying on happenings must manually parse that text. While parsing out nations/regions are easy due to the use of tags with their canonical name (so we can just regex-match), other things are not so easy. Useful tags may be:
  • <REGION> - self-explanatory, optional
  • <NATION> - self-explanatory, optional
  • <TYPE> - This could be one of the filter types (law, cte, etc., or "other" for custom happenings)
  • <ISSUE_ID> - If this is a law happening, the ID of the issue that was answered
  • <ISSUE_ANSWER> - If this is a law happening, which answer was given for that issue
  • <INFLUENCE> - for Influence rank changes, from and to
  • ...etc...

I store happenings in a database, currently with a TEXT column plus pre-parsed region1, region2, nation1, nation2 columns for search. I intend to expand that to include at least the type, and possibly modify it so that when it's unambiguous, the text column is just NULLed to save space in the database. Besides, it just makes it easier to search in the DB in general - I can build indices, do funky joins, what have you.


A concern is that such a form for the happening would be considerably longer. Anyone saving the raw XML would not be pleased by the replacement of <TEXT>...</TEXT> with all of this info, presumably in addition to the TEXT.

This would also not be fun to implement. It's not happening in the foreseeable future.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Caelapes
Ambassador
 
Posts: 1186
Founded: Apr 30, 2007
Left-wing Utopia

Postby Caelapes » Mon May 29, 2017 6:31 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.

is there any significant use for the ID number beyond breaking ties in the census?
  ✿   
The Rose Commune of Caelapes
Ego vero custos fratris mei sum.
aka Misley

User avatar
Eluvatar
Tech Modling
 
Posts: 1207
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Mon May 29, 2017 8:18 pm

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

is there any significant use for the ID number beyond breaking ties in the census?

Where's the fun in answering that?
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Caelapes
Ambassador
 
Posts: 1186
Founded: Apr 30, 2007
Left-wing Utopia

Postby Caelapes » Mon May 29, 2017 8:25 pm

Eluvatar wrote:
Caelapes wrote:is there any significant use for the ID number beyond breaking ties in the census?

Where's the fun in answering that?

It was worth a shot. :P
  ✿   
The Rose Commune of Caelapes
Ego vero custos fratris mei sum.
aka Misley

Previous

Remove ads

Return to Technical

Who is online

Users browsing this forum: Greater United Texas

Remove ads