Page 69 of 97

PostPosted: Thu Jul 27, 2017 9:42 am
by Catlander
RantSpot wrote:This is a Google Sheets issue, not a NationStates issue, but... the URL needs to be in quotes.
Code: Select all
=HYPERLINK("https://www.nationstates.net/cgi-bin/api.cgi?nation=catlander&q=gdp")


Works! I just see the link.... perhaps how i can to get the value of 'gdp' into the cell?

edit: I'm still searching any google function able. This:

Code: Select all

=IMPORTXML("https://www.nationstates.net"; "/cgi.bin/api?nation=catlander&q=gdp")



I get an TRUE into the cell

PostPosted: Thu Jul 27, 2017 10:09 am
by RantSpot
For the second time, this is an elementary Google Sheets question, not a NationStates question. At all. NationStates puts out some XML. It does that correctly.

To change the link to say "GDP":
Code: Select all
=HYPERLINK("https://www.nationstates.net/cgi-bin/api.cgi?nation=catlander&q=gdp","GDP")

The first argument is the full URL, the second argument is the label. Consult the Google Sheets documentation for HYPERLINK.

To fill a cell with the actual GDP value:
Code: Select all
=IMPORTXML("https://www.nationstates.net/cgi-bin/api.cgi?nation=catlander&q=gdp","//GDP")

The first argument is the XML URL, the second argument is an XPATH query. Consult the Google Sheets documentation for IMPORTXML. I expect you will also need to learn more about XPATH.

These were Google Sheets/XPATH queries. These were not NationStates API questions. This is not a forum for Google Sheets questions.

PostPosted: Thu Jul 27, 2017 10:51 am
by Frisbeeteria
RantSpot wrote:These were Google Sheets/XPATH queries. These were not NationStates API questions. This is not a forum for Google Sheets questions.

^ This ^. If you continue to ask questions in inappropriate threads, you (Catlander, that is) will get warned for spamming.

PostPosted: Thu Jul 27, 2017 11:06 am
by Leppikania
My embassy telegram script has been getting a lot of timeouts and server errors; what's going on?

PostPosted: Fri Jul 28, 2017 9:29 pm
by Eluvatar
Leppikania wrote:My embassy telegram script has been getting a lot of timeouts and server errors; what's going on?

What is your script's user agent?
Frisbeeteria wrote:
RantSpot wrote:These were Google Sheets/XPATH queries. These were not NationStates API questions. This is not a forum for Google Sheets questions.

^ This ^. If you continue to ask questions in inappropriate threads, you (Catlander, that is) will get warned for spamming.

That being said, while you are here, please also add "&script=something_identifying_your_spreasdheet" to the end of the URL in your IMPORTXML call. I know you can't set a user agent in google sheets, but you must still identify yourself to us.

PostPosted: Sun Jul 30, 2017 12:42 pm
by Leppikania
Eluvatar wrote:
Leppikania wrote:My embassy telegram script has been getting a lot of timeouts and server errors; what's going on?

What is your script's user agent?

It's a generic user agent; the script is identified through the "script" URL parameter, which is "Embassy Telegram 2.0".

PostPosted: Sun Jul 30, 2017 12:52 pm
by Trotterdam
I'm pretty sure your identification, wherever it's put, is supposed to include something personal that can be used to contact you, like your nation name or email address.

PostPosted: Tue Aug 01, 2017 11:11 am
by RantSpot
Some other API questions/requests:

Is there any circumstance in which a ping request will receive a PING response other than 1? If there's an error, it seems there would not be a reply (HTTP response code other than 200, no XML response content). Are there ever PINGs of 0 or anything else !=1?

About the 50 requests in 30 seconds (or .6 second delay) rate limit:
  • Will the server implement this automatically?
  • I assume it applies to public, private, and TG shards, and applies per request not per shard
  • Does it apply to request times or responses? That is, if I make requests uniformly .6 seconds after the last (including delay waiting for a response), should I be safe?
  • The documentation implies it's a per-IP rate limit, but that spreading requests across IPs and agents would be detected. I assume that third-party public shard requests wouldn't impact users' ability to request public and private shards, especially since users can't necessarily control public shard API calls for their nations, even from tools they might use (e.g. Google Sheets)
  • Some of these answers and details would do well in the API documentation

There should be samples or details of private shard contents in the API documentation. Just clicking the link works for the public shards, but obviously not the private. It's not hard to figure out what each does and how they respond, but that would be good to include in documentation for clarity. A brief explanation of what some things are (like DBID) could be useful for those not intimately familiar with all the functions; in fact, such brief description could be produced and offered (in spoiler tags, on a details page, however) for all available calls. I'd be happy to contribute to a documentation enhancement. It's already helpfully offered for census and banners shards.

Could it be possible to join nation requests as it currently is shard requests? (i.e. nation=testlandia+maxtopia&q=gdp+population) It's already fairly trivial to request data for multiple nations and merge them (e.g. into one XML list with multiple NATION items), but being able to consolidate them would reduce the number of necessary requests, which should somewhat reduce bandwidth load (though I don't know how it would impact the server overall).

Sorry to be such a bother and toss so many questions/thoughts out at once. Just passing along what I encounter while developing/playing with the API.

PostPosted: Tue Aug 01, 2017 12:20 pm
by Greater Tern
RantSpot wrote:About the 50 requests in 30 seconds (or .6 second delay) rate limit:
  • Will the server implement this automatically?


You have to implement a rate limiter yourself. The server locks you out for 15 minutes if you violate this limit.

RantSpot wrote:
  • I assume it applies to public, private, and TG shards, and applies per request not per shard


Yes.

RantSpot wrote:
  • The documentation implies it's a per-IP rate limit, but that spreading requests across IPs and agents would be detected. I assume that third-party public shard requests wouldn't impact users' ability to request public and private shards, especially since users can't necessarily control public shard API calls for their nations, even from tools they might use (e.g. Google Sheets)


I think the point of that rule is to prevent one user from distributing their requests across multiple IPs to avoid the rate limit. Third-party users using the same tool should be fine.

PostPosted: Tue Aug 01, 2017 12:51 pm
by Phydios
RantSpot wrote:About the 50 requests in 30 seconds (or .6 second delay) rate limit

For the record, the rate limit is not 1 request per .6 seconds. You're welcome to do your requesting in spurts.
[violet] wrote:
Imperium Anglorum wrote:Also, if my calculations are correct, the rate limit is 0.6 seconds per request?

No. It's currently 50 requests per 30 seconds, which isn't the same thing. You can make 50 requests in 1s if you make none for the next 29s.

Rate limit doc is here.

PostPosted: Tue Aug 01, 2017 4:33 pm
by [violet]
RantSpot wrote:Is there any circumstance in which a ping request will receive a PING response other than 1? If there's an error, it seems there would not be a reply (HTTP response code other than 200, no XML response content). Are there ever PINGs of 0 or anything else !=1?

No.

RantSpot wrote:About the 50 requests in 30 seconds (or .6 second delay) rate limit:
  • Will the server implement this automatically?
  • I assume it applies to public, private, and TG shards, and applies per request not per shard
  • Does it apply to request times or responses? That is, if I make requests uniformly .6 seconds after the last (including delay waiting for a response), should I be safe?
  • The documentation implies it's a per-IP rate limit, but that spreading requests across IPs and agents would be detected. I assume that third-party public shard requests wouldn't impact users' ability to request public and private shards, especially since users can't necessarily control public shard API calls for their nations, even from tools they might use (e.g. Google Sheets)
  • Some of these answers and details would do well in the API documentation

The API doc is pretty clear in the Rate Limits section already, I'd say. It's not long and explicitly answers most of your questions above, like limits applying per request not per shard, it's 50 reqs per 30 seconds (not 0.6s per request), applied server-side, etc.

I'm not sure exactly what you mean by "third-party public shard requests," but it sounds like it's covered by Terms of Use #2: "Do Not Sneakily Exceed Rate Limits." That is, it would not be nice to run a tool from your own IP using 100% of your available ratelimit while simultaneously running another tool via Google Sheets that also made requests from another IP. But this isn't something that would be automatically detected; it would require an admin to figure it out and decide what to do about it.

RantSpot wrote:There should be samples or details of private shard contents in the API documentation. Just clicking the link works for the public shards, but obviously not the private. It's not hard to figure out what each does and how they respond, but that would be good to include in documentation for clarity. A brief explanation of what some things are (like DBID) could be useful for those not intimately familiar with all the functions; in fact, such brief description could be produced and offered (in spoiler tags, on a details page, however) for all available calls. I'd be happy to contribute to a documentation enhancement. It's already helpfully offered for census and banners shards.

Now this is true, and I'd gratefully accept better docs on each shard, since, as you say, at the moment you basically have to figure out what data you're likely to get returned by trying it.

RantSpot wrote:Could it be possible to join nation requests as it currently is shard requests?

It's not possible currently. See previous discussion in this thread e.g. here & here.

PostPosted: Fri Aug 25, 2017 1:22 pm
by Werreales
Hello, would it be possible to implement additional public shards regarding N-Day? For example, the following regional shards: targeted, launched and destroyed.

Thank you :)

(Note: the NS website does not support CORS policy. Will it be implemented in the future?)

PostPosted: Sat Aug 26, 2017 12:21 am
by HMS Unicorn
Request

Would it be possible to provide a World Assembly API call that gives you the list of all individual nations voting FOR or AGAINST the current resolution at vote?

I am trying to track the votes of individual WA nations within my region, in order to let each nation browse their voting history, as well as for analysis and statistics of our "get out the vote" campaigns.

However, it is proving very cumbersome to track this information from happenings. This is because of a very large number of corner cases that one needs to take into account (resolutions with the same name submitted right after another, nations withdrawing and re-voting, having to search voting happenings by a resolution's name and then cross-reference that with the resolution's start/end timestamp, and so on).

While not impossible to do, all of this would be greatly simplified if you could add the API call I suggested. It could be something like:

Code: Select all
https://www.nationstates.net/cgi-bin/api.cgi?wa=(council_id)&q=nationvotes


This would return two fields, NATIONVOTES_FOR and NATIONVOTES_AGAINST. Each of them would have a comma-separated list of the names of nations that are currently voting FOR or AGAINST the current resolution at vote in the corresponding WA council.

Thanks in advance!

PostPosted: Sat Aug 26, 2017 2:33 pm
by [violet]
Werreales wrote:Hello, would it be possible to implement additional public shards regarding N-Day? For example, the following regional shards: targeted, launched and destroyed.

Yes, there will be an N-Day API. Details to come in the next few days.

PostPosted: Sat Aug 26, 2017 8:23 pm
by Imperium Anglorum
HMS Unicorn wrote:

I absolutely second this request. It would be a fantastic addition to the game!

PostPosted: Fri Sep 01, 2017 4:58 am
by Roavin
Yay on an N-Day API! \o/

Another topic: I'd like to implement a small RMB-Messenger application. Currently, that's not possible without a little bit of scraping, but I think for the requirements I currently have, it'd suffice to have a private shard giving the ID of the last read RMB message for a nation. Posting or liking would be done using the normal POST calls (respecting that these are restricted actions and handling those accordingly of course).

PostPosted: Sat Sep 02, 2017 6:12 am
by Eluvatar
Would you be expecting API requests for RMB posts to affect the last read RMB post private shard?

PostPosted: Sat Sep 02, 2017 11:44 am
by Trotterdam
Eluvatar wrote:Would you be expecting API requests for RMB posts to affect the last read RMB post private shard?
RMB posts are public. So long as you retrieve them without logging in, which is easy for an API, they shouldn't affect any private shards, right?

PostPosted: Sat Sep 02, 2017 12:19 pm
by Roavin
Eluvatar wrote:Would you be expecting API requests for RMB posts to affect the last read RMB post private shard?


I wouldn't, for the reason Trotterdam stated - retrieving RMB posts is not a private shard and therefore can't (and shouldn't) affect any associated nation. This is important particularly for the app I have in mind, which deals with multiple nations and may operate on two or more nations in the same region. On the other hand, a private shard to reset (or rather, set) the last-read counter would be quite useful. If this is done through an explicit call to do so or implicitly by requesting RMB posts with authentication is a matter of taste I guess (the former would be "cleaner", the latter more convenient for several kinds of apps though not necessarily mine).

PostPosted: Sat Sep 02, 2017 3:17 pm
by Onderkelkia
HMS Unicorn wrote:Request

Would it be possible to provide a World Assembly API call that gives you the list of all individual nations voting FOR or AGAINST the current resolution at vote?

I am trying to track the votes of individual WA nations within my region, in order to let each nation browse their voting history, as well as for analysis and statistics of our "get out the vote" campaigns.

However, it is proving very cumbersome to track this information from happenings. This is because of a very large number of corner cases that one needs to take into account (resolutions with the same name submitted right after another, nations withdrawing and re-voting, having to search voting happenings by a resolution's name and then cross-reference that with the resolution's start/end timestamp, and so on).

While not impossible to do, all of this would be greatly simplified if you could add the API call I suggested. It could be something like:

Code: Select all
https://www.nationstates.net/cgi-bin/api.cgi?wa=(council_id)&q=nationvotes


This would return two fields, NATIONVOTES_FOR and NATIONVOTES_AGAINST. Each of them would have a comma-separated list of the names of nations that are currently voting FOR or AGAINST the current resolution at vote in the corresponding WA council.

Thanks in advance!

I would also be interested in this feature, is there any chance that the admins would implement it?"

PostPosted: Sun Sep 03, 2017 5:05 pm
by [violet]
HMS Unicorn wrote:Would it be possible to provide a World Assembly API call that gives you the list of all individual nations voting FOR or AGAINST the current resolution at vote?

This is now available as the WA API shard "voters".

PostPosted: Sun Sep 03, 2017 5:18 pm
by HMS Unicorn
Terrific, thanks!

PostPosted: Wed Sep 20, 2017 6:03 pm
by Greater Tern
Hey [v], can we get the edited timestamp on the RMB API? Thanks a bunch!

PostPosted: Wed Sep 20, 2017 9:23 pm
by [violet]
Greater Tern wrote:Hey [v], can we get the edited timestamp on the RMB API? Thanks a bunch!

Done!

PostPosted: Sat Sep 23, 2017 11:06 am
by Aurum Raider
On the Nation Data Dump, could the <INFLUENCE> tag be altered to have an attribute containing the SPDR stat, a la <INFLUENCE spdr="23">?