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
Xtoshtia
Bureaucrat
 
Posts: 41
Founded: Oct 04, 2014
Ex-Nation

Postby Xtoshtia » Fri May 29, 2015 6:53 pm

Hello, sorry if I went to the wrong person, I just don't know where else to go about this, but I haven't been on nation states for a couple days. I checked today at about 9:00PM (Eastern Time, United States) and I got a message from the WA saying I violated rules by having more than one nation in the WA. I didn't do this. I do have multiple nations, but none of them are in the WA, so I'm not sure what happened, I just don't want to lose admission in the WA. Thanks for any help.
B.I.L., Regal and Majesty Poobah of the Desert Cheese Hierarchy State: Xtoshtia


Xtoshtia is a technologically advanced, environment aware, balanced, and monarch state. It specializes in Information Technology, and Tourism. The economy is terrible, but civil rights are good, and political freedoms improving.
PRO:Zionism, Israel, United States, Capitalism, Direct Democracy, Freedom of Speech Press and Assembly.
ANTI: Radical Islam, Palestine, Police States, Terrorism, Corruption, Unfairness, Oppressive States.

User avatar
Kaboomlandia
Negotiator
 
Posts: 7395
Founded: May 22, 2013
Ex-Nation

Postby Kaboomlandia » Fri May 29, 2015 6:54 pm

Xtoshtia wrote:Hello, sorry if I went to the wrong person, I just don't know where else to go about this, but I haven't been on nation states for a couple days. I checked today at about 9:00PM (Eastern Time, United States) and I got a message from the WA saying I violated rules by having more than one nation in the WA. I didn't do this. I do have multiple nations, but none of them are in the WA, so I'm not sure what happened, I just don't want to lose admission in the WA. Thanks for any help.

File a GHR.
In=character, Kaboomlandia is a World Assembly member and abides by its resolutions. If this nation isn't in the WA, it's for practical reasons.
Author of GA #371 and SC #208, #214, #226, #227, #230, #232
Co-Author of SC #204
"Insanity is doing the same thing over and over and expecting a different result."
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

"Your legitimacy, Kaboom, has melted away in my eyes. I couldn't have believed that only a shadow of your once brilliant WA career remains."

User avatar
Tribes Republic
Ambassador
 
Posts: 1166
Founded: Jun 15, 2012
Democratic Socialists

Postby Tribes Republic » Wed Jun 17, 2015 10:43 am

Are there any plans to build a REST API set up for windows phone apps as a direct app would be good to have the mobile site is fine, but I want to include other features from NS++ in the app just I may have to work around gameside until I can find a way to integrate the forum in the app so it's not just a link to the forums on the mobile browser.
Nation Leader: Principal Chief Giltra Hurid
WA Ambassador: Leui Henri
Nation Name: The Colony of Tribes Republic
RP Population: 64.1 Million(UK Pop as of 2013)
Nation Tech: PT, MT, PMT

My Political Compass
Economic Left/Right: 3.25
Social Libertarian/Authoritarian: -2.21

This is Bunny:
(\__/)
(='.'=)
(")_(") Copy and paste Bunny into your signature to help him gain world domination.
(5)At War
(4)Troops On Standby
(3)Ready<--
(2)High Alert
(1)Peace
[url]new link coming soon[/url]

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

Postby [violet] » Wed Jun 17, 2015 4:38 pm

Zacherie wrote:On the Telegram API: When the script breaks the API script limit, it doesn't give much useful information other than that you broke it.
I think in the style of the "queued" message, it'd be more helpful if it returned something along the lines of "@@Rate Limit Hit@@ by &&CLIENT&& wait @@X@@ seconds to send" to allow easy error checking.

The API does return a "Retry-After" HTTP header when you break the rate limit, which specifies how many seconds you need to wait before you can successfully try again.

User avatar
Xoriet
Minister
 
Posts: 2046
Founded: Jun 08, 2012
Corrupt Dictatorship

Postby Xoriet » Mon Jun 22, 2015 1:23 pm

I'm not 100% sure this belongs here, but the Timestamps for the API area seem to be a little wonky right now. I've used several different methods and I keep getting times which do not add up conclusively with update length. I was using the legislation timestamps to determine the exact update time of specific regions during one update, which is how I found a weird inconsistency with the update times. Some are too soon for Major and some are well after the last region updates.

Result samples from Yahoo Pipes during update Friday Major, June 19th.
Fri, 19 Jun 2015 23:11:19 -0700
Fri, 19 Jun 2015 23:58:47 -0700
Fri, 19 Jun 2015 23:35:33 -0700
Fri, 19 Jun 2015 22:58:11 -0700
Fri, 19 Jun 2015 21:07:19 -0700


Result samples from Online Conversion for the same regions with the same Timestamps.
Sat, 20 Jun 2015 06:11:19 GMT
Sat, 20 Jun 2015 06:58:47 GMT
Sat, 20 Jun 2015 06:35:33 GMT
Sat, 20 Jun 2015 05:58:11 GMT
Sat, 20 Jun 2015 04:07:19 GMT


Is/was there something up with the Timestamps?
Senator of Diplomatic Affairs of the New Pacific Order

This flame we carry into battle
A fading memory
This light will conquer the darkness
Shining bright for all to see

User avatar
Frisbeeteria
Senior Game Moderator
 
Posts: 27796
Founded: Dec 16, 2003
Capitalizt

Postby Frisbeeteria » Mon Jun 22, 2015 1:32 pm

Xoriet wrote:Is/was there something up with the Timestamps?

Update timing got screwed up in the latest maintenance cycle last weekend. There's a thread about it here in Tech. Check your timings there.

User avatar
The Norths Alliance
Political Columnist
 
Posts: 3
Founded: Jun 22, 2015
Ex-Nation

Telegrams API

Postby The Norths Alliance » Thu Jun 25, 2015 8:21 pm

I have an issue with the telegrams API (I'm sure I'm just being stupid and not doing something right):
I am just trying to test the API telegram I have composed by copying and pasting the url into my browser. I am only sending it to myself to do the test, and I receive the following error:
Error: 429 API Recruitment TG ratelimit exceeded by client "@The Northern Alliance@ The Norths Allia".

Help? :?

User avatar
Frisbeeteria
Senior Game Moderator
 
Posts: 27796
Founded: Dec 16, 2003
Capitalizt

Postby Frisbeeteria » Thu Jun 25, 2015 8:29 pm

The Norths Alliance wrote:Error: 429 API Recruitment TG ratelimit exceeded by client "@The Northern Alliance@ The Norths Allia".

I don't know if this reflects accurately on the API itself, but TGs tagged as recruitment are blocked if they exceed more than [one TG, per nation, per region, every 28 days]. So the first TG sent or tested would be successful, but you can't send it to yourself for another month. Also, your TGs are rate limited to one every 180 seconds (I believe), so you'd have gotten an error if you tried to test more than once every 3 minutes.

Then again, it could be something else entirely. I'm not an API user or expert.

User avatar
The Norths Alliance
Political Columnist
 
Posts: 3
Founded: Jun 22, 2015
Ex-Nation

Postby The Norths Alliance » Thu Jun 25, 2015 8:34 pm

Frisbeeteria wrote:
The Norths Alliance wrote:Error: 429 API Recruitment TG ratelimit exceeded by client "@The Northern Alliance@ The Norths Allia".

I don't know if this reflects accurately on the API itself, but TGs tagged as recruitment are blocked if they exceed more than [one TG, per nation, per region, every 28 days]. So the first TG sent or tested would be successful, but you can't send it to yourself for another month. Also, your TGs are rate limited to one every 180 seconds (I believe), so you'd have gotten an error if you tried to test more than once every 3 minutes.

Then again, it could be something else entirely. I'm not an API user or expert.

So, I can only send one recruitment telegram with API every 28 days? :unsure:

User avatar
Frisbeeteria
Senior Game Moderator
 
Posts: 27796
Founded: Dec 16, 2003
Capitalizt

Postby Frisbeeteria » Thu Jun 25, 2015 8:40 pm

The Norths Alliance wrote:So, I can only send one recruitment telegram with API every 28 days?

As of this moment, "The world contains 134,609 nations in 18,656 regions." Since you can only send one API recruitment telegram every 3 minutes, it would take you 279.81 days just to hit each of them once. So yeah, the [28 day / per region / per nation] limit isn't really that much of a limitation.

User avatar
Ever-Wandering Souls
Negotiator
 
Posts: 7268
Founded: Jan 01, 2014
Father Knows Best State

Postby Ever-Wandering Souls » Thu Jun 25, 2015 8:44 pm

The Norths Alliance wrote:
Frisbeeteria wrote:I don't know if this reflects accurately on the API itself, but TGs tagged as recruitment are blocked if they exceed more than [one TG, per nation, per region, every 28 days]. So the first TG sent or tested would be successful, but you can't send it to yourself for another month. Also, your TGs are rate limited to one every 180 seconds (I believe), so you'd have gotten an error if you tried to test more than once every 3 minutes.

Then again, it could be something else entirely. I'm not an API user or expert.

So, I can only send one recruitment telegram with API every 28 days? :unsure:


To any given nation, to be specific. And you can send them, they just won't be received :P
Proud Raider; General of The Black Hawks, Ret.
TG me anytime; I'm always happy to talk about anything!

The Alicorns (Equestria) wrote:Let them stay, no need to badmouth them...From our view a bunch of nations just came in, seized the delegate position, and changed a few superficial things...we play NationStates differently...there's really no reason for us to be butthurt.
http://www.nationstates.net/page=rmb/postid=8944227
http://www.nationstates.net/page=rmb/postid=8951258

Misley wrote:
Hobbesistan wrote:Don't think I understand the question.
The color or what?..

Jesus, Hobbes, it's 2015. You can't just call someone "the color".

Reploid Productions wrote:Raiders are endlessly creative

How Do I Telegram API?

Omnis delenda est.

User avatar
The Norths Alliance
Political Columnist
 
Posts: 3
Founded: Jun 22, 2015
Ex-Nation

Postby The Norths Alliance » Thu Jun 25, 2015 8:45 pm

But, why wasn't I able to send the API telegram to myself even once?
Also, does my API script have to call the NS API once every 3 minutes, or can it make one big call and then NS will send the telegram to a nation every 3 minutes?

User avatar
Misley
Diplomat
 
Posts: 609
Founded: Jan 05, 2009
Ex-Nation

Postby Misley » Fri Jun 26, 2015 8:34 am

The Norths Alliance wrote:But, why wasn't I able to send the API telegram to myself even once?
Also, does my API script have to call the NS API once every 3 minutes, or can it make one big call and then NS will send the telegram to a nation every 3 minutes?

One call every 3 minutes. It's safest to make it call the API something like every 3 minutes + 2 seconds though, because if your script skips a tick and tries to send another TG too early, it won't send.
EGO·VERO·CUSTOSFRATRIS·MEI·SUM
Socialist People's Provinces of Misley

   
Editor of the Red & Black
Fleet Admiral of The Red Fleet
Custodian of The Internationale

User avatar
Lordieth
Post Czar
 
Posts: 31603
Founded: Jun 18, 2010
New York Times Democracy

Postby Lordieth » Sun Jun 28, 2015 5:20 am

I mused some time ago about creating an online version of NationWars, an old application I built a few years back, and I have a question regarding the registration system;

Nations will be able to register their nation to participate in NationWars, and use their nation to compete against other registered Nations. To ensure only Nation owners can register their own Nation, the system would have to automatically send a telegram to that nation with a confirmation link to activate their account.

I once brought this up with Violet quite some time ago, and I believe it was something that could be discussed, even though it's not covered by the current rules. In order for the system to work, Nation owners have to be able to verify themselves with NationWars. You just can't build an account-based system on top of NationStates without user authentication, and this is the easiest way to do it. All the telegrams would come from just one Nation, which will be used to send the authentication telegrams, so this could be cleared beforehand if some sort of exception rule has to be added within the system to allow it to send the telegrams.

Is this possible? If so, I might consider going ahead with building the platform. Firstly I'll need to automate downloading and converting the daily dump file into a database to limit API calls before I even start on the infrastructure, but I know it's worth pursuing if I know users will be able to register their nations. Otherwise, I'll be rather limited in what kind of platform I'll be able to build.

I'm not saying I still couldn't build something without user registration, but it won't be anywhere near as fun.

(Edit: as an aside, I've written a quick parser in PHP for the daily data dump, and it takes approx between 0-20 seconds to find a Nation, or return no result, which is why I'll be writing a cron script to store nations in a database table for lightning-fast indexing)
Last edited by Lordieth on Sun Jun 28, 2015 8:08 am, edited 2 times in total.
There was a signature here. It's gone now.

User avatar
The Vines
Secretary
 
Posts: 36
Founded: Oct 25, 2014
Civil Rights Lovefest

Postby The Vines » Sun Jun 28, 2015 11:56 pm

Lordieth wrote:*snip*


Have you looked into the Authentication API? That feature was designed specifically for use cases like yours.
Ambassador of the Vines - Factbook - NS API for Haskell
I love you

User avatar
Lordieth
Post Czar
 
Posts: 31603
Founded: Jun 18, 2010
New York Times Democracy

Postby Lordieth » Wed Jul 01, 2015 11:18 am

The Vines wrote:
Lordieth wrote:*snip*


Have you looked into the Authentication API? That feature was designed specifically for use cases like yours.


Ah, very good. I'll look into that. Could be just what I need.
There was a signature here. It's gone now.

User avatar
The Vines
Secretary
 
Posts: 36
Founded: Oct 25, 2014
Civil Rights Lovefest

Postby The Vines » Wed Jul 01, 2015 4:36 pm

For all you FP nerds out there, I've released an API client for Haskell (docs, github).

[violet] you might like to add this to the list :)
Last edited by The Vines on Wed Jul 01, 2015 4:50 pm, edited 1 time in total.
Ambassador of the Vines - Factbook - NS API for Haskell
I love you

User avatar
Esterild
Spokesperson
 
Posts: 152
Founded: Apr 28, 2011
Scandinavian Liberal Paradise

Censusmax/censusmin

Postby Esterild » Thu Jul 09, 2015 8:21 pm

Would it be possible to add censusmax and censusmin shards to the World API? These would be similar to the censusmedian shard. They could represent either the absolute minimum and maximum census values - or, if there are no absolute limits, they could represent the calculated maximum and minimum over all the nations in the census. Thank you!

User avatar
Esterild
Spokesperson
 
Posts: 152
Founded: Apr 28, 2011
Scandinavian Liberal Paradise

Postby Esterild » Sat Aug 01, 2015 10:49 am

Esterild wrote:Would it be possible to add censusmax and censusmin shards to the World API? These would be similar to the censusmedian shard. They could represent either the absolute minimum and maximum census values - or, if there are no absolute limits, they could represent the calculated maximum and minimum over all the nations in the census. Thank you!


Bump! I know everyone's pretty busy, but it would be great if this could happen.

User avatar
Eclectic Danta
Political Columnist
 
Posts: 4
Founded: Aug 13, 2015
Ex-Nation

Postby Eclectic Danta » Sat Aug 15, 2015 12:17 pm

So where would I go if I want to learn how to use NS API in Java (assuming I don't really know how to do anything at all)? I'm interested in making a small script to do automatic calculations of RP Statistics for various nations in my region. But I have no idea how to put together a program that calls the NS API and has it return information from various shards, including population, name, govt - or even how to extract GDP information from industrydesc. Essentially, my question is, where can I find an example of a script that calls for information from NS API and puts it to use in the program?

User avatar
Laevendell
Envoy
 
Posts: 220
Founded: Jan 29, 2011
Left-wing Utopia

Postby Laevendell » Sat Aug 15, 2015 12:42 pm

Eclectic Danta wrote:So where would I go if I want to learn how to use NS API in Java (assuming I don't really know how to do anything at all)? I'm interested in making a small script to do automatic calculations of RP Statistics for various nations in my region. But I have no idea how to put together a program that calls the NS API and has it return information from various shards, including population, name, govt - or even how to extract GDP information from industrydesc. Essentially, my question is, where can I find an example of a script that calls for information from NS API and puts it to use in the program?

Here is a short example that should get you going: https://code.google.com/p/ns-api/wiki/BasicUsage
I haven't updated the API in a little while, so it might be missing some of the latest features.

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

Postby [violet] » Sun Aug 16, 2015 4:49 pm

The Vines wrote:For all you FP nerds out there, I've released an API client for Haskell (docs, github).

[violet] you might like to add this to the list :)

Added!

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

Postby [violet] » Sun Aug 16, 2015 4:50 pm

Esterild wrote:Would it be possible to add censusmax and censusmin shards to the World API? These would be similar to the censusmedian shard. They could represent either the absolute minimum and maximum census values - or, if there are no absolute limits, they could represent the calculated maximum and minimum over all the nations in the census. Thank you!

We don't collect those values at the moment, so there is nothing to export. You could only calculate them for the current World Census by scanning a daily dump for the largest and smallest values.

User avatar
Zemnaya Svoboda
Diplomat
 
Posts: 867
Founded: Jan 06, 2004
Civil Rights Lovefest

Encoding Again

Postby Zemnaya Svoboda » Tue Aug 18, 2015 11:09 am

Code: Select all
XML Parsing Error: undefined entity
Location: http://www.nationstates.net/cgi-bin/api.cgi?q=region+endorsements+happenings&v=5&nation=niimiipu
Line Number 32, Column 96:

<TEXT>Following new legislation in @@niimiipu@@, Rupert Bear is considered to be the most risqu&eacute; TV programme in Niimiipu.</TEXT>
-----------------------------------------------------------------------------------------------^


Basically in nation api requests with happenings included such as this one it's possible to get an "&eacute;" which is not valid XML unless explicitly defined. Since the encoding is now UTF-8, it should be possible to communicate the legislation without such escaping (assuming of course that nation custom fields are all properly screened against badness). Alternatively of course you could say that the NS API will include html entities and we should deal with that :P

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

Postby [violet] » Tue Aug 18, 2015 4:11 pm

Zemnaya Svoboda wrote:with happenings included such as this one it's possible to get an "&eacute;"

Should be fixed now.

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Aserlandia, Comfed, Jerzylvania, Keddie, New Oros, Radicalania, Shazbotdom

Advertisement

Remove ads