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
Leppikania
Minister
 
Posts: 2257
Founded: Apr 13, 2015
Left-wing Utopia

Postby Leppikania » Tue Apr 10, 2018 7:55 pm

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

I just don't think it would make sense as a private shard. Another option, I think, would be to have a stricter rate limit.
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
HMS Unicorn
Spokesperson
 
Posts: 199
Founded: Jun 29, 2005
Ex-Nation

Postby HMS Unicorn » Fri Apr 13, 2018 7:17 am

Eluvatar wrote:What censuses do you refer to as having been selectively included?

Don't the various stats included in the nation dump correspond to various censuses?

User avatar
Imperium Anglorum
Powerbroker
 
Posts: 8275
Founded: Aug 26, 2013
Left-Leaning College State

Postby Imperium Anglorum » Tue Apr 17, 2018 11:09 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).

Bump.

Author: 1 SC and 24 GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and Regional Records
Delegate for Europe
Out-of-character unless marked otherwise
Ideological Bulwark 285, WALL delegate

User avatar
Roavin
Diplomat
 
Posts: 912
Founded: Apr 07, 2016
Left-wing Utopia

Postby Roavin » Fri May 11, 2018 12:08 am

For synchronization purposes, it'd be really useful if there was a server time shard.

That is, this request:
Code: Select all
https://www.nationstates.net/cgi-bin/api.cgi?q=time


Returns this:
Code: Select all
<WORLD><TIME>1526022475</TIME></WORLD>
RoavinNPO shill from the South Pacific
Warning: This nation may exhibit ambitions to coup Balder. Handle with care.

“Better die a Cormac than live an Onder.”

NS Coders Discord | I am a LOLcat | Former First Warden of TGW

User avatar
Darcania
Attaché
 
Posts: 93
Founded: Dec 29, 2014
Left-wing Utopia

Postby Darcania » Fri May 11, 2018 10:00 am

Roavin wrote:For synchronization purposes, it'd be really useful if there was a server time shard.

HTTP requests return a "DATE" header field with the server's current time. That should be useful for your purposes. It's a string in the format of "Fri, 11 May 2018 16:59:03 GMT" so you'll have to parse it a bit.
Last edited by Darcania on Fri May 11, 2018 10:00 am, edited 1 time in total.

User avatar
Eluvatar
Site Admin
 
Posts: 2140
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Fri May 11, 2018 1:14 pm

Darcania is correct, and Roavin should actually have access to examples of my code that use that, such as:
Code: Select all
    timestamp = timegm(xml.headers.getdate("Date"))

(Where the variable xml is the result from a call to api.request from trawler-parser-python)
Imperium Anglorum wrote:
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).

Bump.

Yes that's a good idea, but it's lower in my priorities than, say, improving update speed right now. Sorry.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Roavin
Diplomat
 
Posts: 912
Founded: Apr 07, 2016
Left-wing Utopia

Postby Roavin » Fri May 11, 2018 4:33 pm

Eluvatar wrote:Darcania is correct, and Roavin should actually have access to examples of my code that use that, such as:
Code: Select all
    timestamp = timegm(xml.headers.getdate("Date"))

(Where the variable xml is the result from a call to api.request from trawler-parser-python)


Oh, welp, somehow I missed that. Thanks, Darc and Elu!
RoavinNPO shill from the South Pacific
Warning: This nation may exhibit ambitions to coup Balder. Handle with care.

“Better die a Cormac than live an Onder.”

NS Coders Discord | I am a LOLcat | Former First Warden of TGW

User avatar
Agadar
Powerbroker
 
Posts: 7749
Founded: Dec 06, 2009
Corrupt Dictatorship

Postby Agadar » Sun May 20, 2018 5:22 am

It would be awesome if it were possible to send telegrams without requiring a telegram id with a secret key, instead simply supplying a body. That would, for example, allow a new application I'm developing for assisting me in my TWI Info Office duties to send me a notification telegram whenever new updates are available for publishing.
Information Secretary of The Western Isles, the #1 role-playing region!
Developer of Telegrammer, NS API Java Wrapper, and more!

User avatar
Honk Donk
Lobbyist
 
Posts: 11
Founded: Mar 18, 2018
Civil Rights Lovefest

possible bug (?)

Postby Honk Donk » Sun May 20, 2018 8:53 am

for the nation verification api, the api currently returns
"0\n"
or
"1\n"
. However the documentation says it should return
"0"
or
"1"
(no newline). Is this a bug or is it intended? If it's intended, would it be possible to update the documentation?

(it just confused me a bit because it didn't equal 1 or 0 when I was using it)
Last edited by Honk Donk on Sun May 20, 2018 8:55 am, edited 1 time in total.
First Secretary/WA Delegate for Conifer

User avatar
Agadar
Powerbroker
 
Posts: 7749
Founded: Dec 06, 2009
Corrupt Dictatorship

Postby Agadar » Sun May 20, 2018 3:48 pm

On another note, it does not seem possible to retrieve the number of RMB pages from the API, nor to derive it from other data. Instead, I will have to resort to scraping the webpage itself, which is messy. Is it possible to have this number made available from the API?
Information Secretary of The Western Isles, the #1 role-playing region!
Developer of Telegrammer, NS API Java Wrapper, and more!

User avatar
Eluvatar
Site Admin
 
Posts: 2140
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Sun May 20, 2018 8:57 pm

Agadar wrote:It would be awesome if it were possible to send telegrams without requiring a telegram id with a secret key, instead simply supplying a body. That would, for example, allow a new application I'm developing for assisting me in my TWI Info Office duties to send me a notification telegram whenever new updates are available for publishing.

Not allowing scripts to send arbitrary text is a design feature, not a bug. And no script should create any telegram template.

It may be possible to work around this by sending a telegram which links to a dispatch which is separately updated.

Honk Donk wrote:for the nation verification api, the api currently returns
"0\n"
or
"1\n"
. However the documentation says it should return
"0"
or
"1"
(no newline). Is this a bug or is it intended? If it's intended, would it be possible to update the documentation?

(it just confused me a bit because it didn't equal 1 or 0 when I was using it)


I don't intend to change this.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Imperium Anglorum
Powerbroker
 
Posts: 8275
Founded: Aug 26, 2013
Left-Leaning College State

Postby Imperium Anglorum » Sun May 20, 2018 11:20 pm

Eluvatar wrote:I don't intend to change this.

But why? Why keep it when it is including a new line, especially when the documentation says it doesn't do that?

Author: 1 SC and 24 GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and Regional Records
Delegate for Europe
Out-of-character unless marked otherwise
Ideological Bulwark 285, WALL delegate

User avatar
Agadar
Powerbroker
 
Posts: 7749
Founded: Dec 06, 2009
Corrupt Dictatorship

Postby Agadar » Mon May 21, 2018 4:18 am

Eluvatar wrote:
Agadar wrote:It would be awesome if it were possible to send telegrams without requiring a telegram id with a secret key, instead simply supplying a body. That would, for example, allow a new application I'm developing for assisting me in my TWI Info Office duties to send me a notification telegram whenever new updates are available for publishing.

Not allowing scripts to send arbitrary text is a design feature, not a bug. And no script should create any telegram template.

It may be possible to work around this by sending a telegram which links to a dispatch which is separately updated.


That would not be very useful for my use case, as it's not possible (nor allowed) to update dispatches via scripts, which is what your proposed solution would entail.

I suppose I'll have to resort to my script e-mailing me or something when it has updates ready for me.
Information Secretary of The Western Isles, the #1 role-playing region!
Developer of Telegrammer, NS API Java Wrapper, and more!

User avatar
Honk Donk
Lobbyist
 
Posts: 11
Founded: Mar 18, 2018
Civil Rights Lovefest

Postby Honk Donk » Sun May 27, 2018 6:45 am

Eluvatar wrote:I don't intend to change this.

Why not? I understand why you wouldn't change the api itself but surely you can modify the documentation to include a note about the newline?
First Secretary/WA Delegate for Conifer

User avatar
Eluvatar
Site Admin
 
Posts: 2140
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Sun May 27, 2018 6:00 pm

I meant that I don't intend to change the behavior.

I may make a change to the documentation.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Glen-Rhodes
Powerbroker
 
Posts: 8975
Founded: Jun 25, 2008
Civil Rights Lovefest

Postby Glen-Rhodes » Sat Jul 14, 2018 6:04 pm

Would it be possible to include a "natives" shard in the region API, listing which nations count as "natives" for poll purposes?
Last edited by Glen-Rhodes on Sat Jul 14, 2018 6:06 pm, edited 1 time in total.

User avatar
Honk Donk
Lobbyist
 
Posts: 11
Founded: Mar 18, 2018
Civil Rights Lovefest

Postby Honk Donk » Mon Jul 23, 2018 3:43 am

If you don't specify any shard names (for nation, region, etc), what is the default list that is used? The docs just say "a compendium of the most commonly sought information" - what does this mean exactly?

Edit: after some time manually working this out, I have calculated that for nations, the default shard list is
Code: Select all
name+type+fullname+motto+category+wa+endorsements+freedom+region+population+tax+animal+currency+demonym+demonym2+demonym2plural+flag+majorindustry+govtpriority+govt+founded+firstlogin+lastlogin+lastactivity+influence+freedomscores+publicsector+deaths+leader+capital+religion+cardcategory
, or everything except for
Code: Select all
govtdesc, richest, legislation, tgcanrecruit, census, notable, banners, industrydesc, banner, wcensus, happenings, dbid, policies, dispatchlist, animaltrait, factbooklist, customcapital, admirable, sectors, customleader, tgcancampaign, crime, poorest, scvote, zombie, gavote, sensibilities, customreligion, gdp, rcensus, wabadges, factbooks, foundedtime, income, dispatches


Would it be possible for this info to be put into the API docs, as well as the corresponding info for regions, etc?
Last edited by Honk Donk on Mon Jul 23, 2018 3:56 am, edited 1 time in total.
First Secretary/WA Delegate for Conifer

User avatar
Trotterdam
Negotiator
 
Posts: 6749
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Mon Jul 23, 2018 6:18 am

I would really recommend against using a "default list", unless you're just quickly testing something rather than making a real application. I always tune my API requests to ask exactly the information I'm interested in and going to use (or at least information that I'm maybe going to use depending on what other information from the same request looks like), nothing more or less.

User avatar
Honk Donk
Lobbyist
 
Posts: 11
Founded: Mar 18, 2018
Civil Rights Lovefest

Postby Honk Donk » Mon Jul 23, 2018 8:19 am

Trotterdam wrote:I would really recommend against using a "default list", unless you're just quickly testing something rather than making a real application. I always tune my API requests to ask exactly the information I'm interested in and going to use (or at least information that I'm maybe going to use depending on what other information from the same request looks like), nothing more or less.

True, but for what I'm doing (API wrapper library) I do need to know this.
First Secretary/WA Delegate for Conifer

User avatar
Zone 71
Envoy
 
Posts: 226
Founded: Apr 20, 2018
Ex-Nation

Postby Zone 71 » Wed Jul 25, 2018 6:39 am

I currently have a Client Key for the purposes of recruitment in my region, The Quarantine. Would I need to request a different Client Key if I were to instead use my API to promote World Assembly legislation?

User avatar
Frisbeeteria
Senior Game Moderator
 
Posts: 22974
Founded: Dec 16, 2003
Anarchy

Postby Frisbeeteria » Wed Jul 25, 2018 9:01 am

Zone 71 wrote:I currently have a Client Key for the purposes of recruitment in my region, The Quarantine. Would I need to request a different Client Key if I were to instead use my API to promote World Assembly legislation?

The same key works for all API purposes, so no, you don't need another one. All keys are currently issued as recruitment keys, and consequently all regional recruitment telegrams related to that key are permanently tied to the original region. Campaign and/or other telegrams don't include a regional recruitment link, so you're fine. Don't forget to tick the appropriate checkbox when creating your TG template.

User avatar
Zone 71
Envoy
 
Posts: 226
Founded: Apr 20, 2018
Ex-Nation

Postby Zone 71 » Wed Jul 25, 2018 9:08 am

Frisbeeteria wrote:
Zone 71 wrote:I currently have a Client Key for the purposes of recruitment in my region, The Quarantine. Would I need to request a different Client Key if I were to instead use my API to promote World Assembly legislation?

The same key works for all API purposes, so no, you don't need another one. All keys are currently issued as recruitment keys, and consequently all regional recruitment telegrams related to that key are permanently tied to the original region. Campaign and/or other telegrams don't include a regional recruitment link, so you're fine. Don't forget to tick the appropriate checkbox when creating your TG template.

Awesome. Thank you.

User avatar
Vungar
Attaché
 
Posts: 80
Founded: Nov 19, 2016
Iron Fist Consumerists

Postby Vungar » Wed Jul 25, 2018 10:52 am

Can somebody get me a very detailed step by step guide on this? I am not very good with this kind of stuff.
I’m terrible at writing signatures.

User avatar
August
Spokesperson
 
Posts: 110
Founded: Oct 07, 2011
Anarchy

Postby August » Tue Aug 21, 2018 9:16 am

Got a couple requests for new shards.

1. Site staff. This would be a Nation API shard, something like this: <STAFF>Moderator</STAFF>. Other options would be Administrator and Issues Editor. (More options like Forum Moderator, Game Moderator, Tech Modling, Issues Tech, etc, would be nice, but not as important.) Non-staff nations would just have an empty tag: <STAFF></STAFF>.
2. More modes for the census shard on the Nation and Region APIs. At the moment, nation=august;q=census;scale=0+1+2;mode=score+rank gets my scores and ranks for Civil Rights, Economy, and Political Freedom. Now, I can use the World API to grab the description, title, name, and units for those census categories (using a separate API call for each, because they cannot be combined), but that adds up quickly. It would be very helpful to have ;mode=name+title+units+desc or something to that effect.

Thank you for considering.
Augustin Alliance Central Strategic Committee
AARFGHCKLENADNJTFReference

|| AA Founder

Other Links: NS Founders | Tech suggestions | AA server | AugustinAndroid | About me
I heard it was you / talkin' 'bout a world where all is free / it just couldn't be / and only a fool would say that...

User avatar
Eluvatar
Site Admin
 
Posts: 2140
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Fri Aug 24, 2018 8:30 am

Why do you want (1)?

Can't you cache the description, title, name, and units once fetched? What do you wish to do for which having the API fill them in for you would help?

(Not saying these requests definitely won't be implemented, just trying to get some context for them.)
To Serve and Protect: UDL

Eluvatar - Taijitu member

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: No registered users

Advertisement

Remove ads