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
Ballotonia
Site Admin
 
Posts: 5440
Founded: Antiquity
Liberal Democratic Socialists

Postby Ballotonia » Fri Jul 03, 2020 5:18 am

The Northern Light wrote:Request

Would it be possible to expand the cards API and include options to retrieve a nation's asks and bids?

Bids in particular would be useful for collectors, who may want to check what cards from a large set they have placed bids on, or to check for bids on cards they already own, etc.

Thank you in advance!


Quick turn-around on this one!

Implemented. Example: https://www.nationstates.net/cgi-bin/ap ... me=carinov
See the API page (Section Cards.4) for the details: https://www.nationstates.net/pages/api.html#cards

Ballotonia
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
Ballotonia
Site Admin
 
Posts: 5440
Founded: Antiquity
Liberal Democratic Socialists

Postby Ballotonia » Fri Jul 03, 2020 5:47 am

Aurum Raider wrote:Would it be possible to alter the "CATEGORY" field on the cards API to "CARDCATEGORY", and "CARDID" to "ID"?
In it's present form, the output from the API is incongruent with the data dumps.

EDIT: I'm referring specifically to the decklist provided by "cards+deck;nationname="


While I do enjoy consistency, this would break the scripts of all current users. I think this is manageable on user-side.

Akragas wrote:Hi all, I am a compete beginner to the API so my apologies in advance if what I am asking is overly simple.

The specific stat I’d like to know about is total number of issues answered (I looked up in the documentation but couldn’t find a relevant shard); I would presume this is kept track of somewhere since there exist banners for reaching specific milestones. Thanks for any help!


Added to the Nation API: ISSUES_ANSWERED. See for example: https://www.nationstates.net/cgi-bin/ap ... testlandia

Note that this only keeps track of all issues answered since back when this counter was added. Especially older nations will find a lower value than what really happened. It's been quite some years already though, so by far most nations will have the right value.

Ballotonia
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
Ballotonia
Site Admin
 
Posts: 5440
Founded: Antiquity
Liberal Democratic Socialists

Postby Ballotonia » Fri Jul 03, 2020 6:16 am

The Northern Light wrote:Feature request:

Would it be possible to add an option to the cards API to list the IDs and names of all current collections in a nation's deck?

For example, it could be:

Code: Select all
https://www.nationstates.net/cgi-bin/api.cgi?q=cards+collections;nationname=testlandia


Ideally it could be combined with deck and info:

Code: Select all
https://www.nationstates.net/cgi-bin/api.cgi?q=cards+info+deck+collections;nationname=testlandia


One downside of my example proposal that you may want to take into account is that the syntax is very similar to the "+collection" option for listing the contents of a specific collection. Feel free to use some other syntax.

Thanks in advance!


Implemented as suggested. I know the singular/plural is similar, but this is not the first time we've had that. Since I don't see these two being used within the same call, it's OK.

Example: https://www.nationstates.net/cgi-bin/ap ... ationid=38

Ballotonia
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
The Northern Light
Spokesperson
 
Posts: 137
Founded: Oct 10, 2014
Inoffensive Centrist Democracy

Postby The Northern Light » Fri Jul 03, 2020 3:32 pm

Thanks for all these new features!
Home of the WADP, Planet Eras, and the Constibillocode!
Join The North Pacific!
Where the democracy is strong, the debate robust, and the rum plentiful!

Forum | Discord Chat | Citizenship | Executive Staff | North Pacific Army | World Assembly Ministry | Roleplay | Trading Cards | Handbook

User avatar
HN67
Political Columnist
 
Posts: 3
Founded: Mar 11, 2015
Liberal Democratic Socialists

API Feature Request

Postby HN67 » Fri Jul 10, 2020 7:31 pm

Would it be possible to add shards to the cards API that shows the sales/buys of a nation, (i.e. https://www.nationstates.net/page=deck/ ... ades=sales and https://www.nationstates.net/page=deck/show_trades=buys)? similar to the existing askbids shard (e.g. https://www.nationstates.net/cgi-bin/ap ... testlandia), although ideally separate shards. It could use the XML syntax similar to the other trades shards (e.g. https://www.nationstates.net/cgi-bin/ap ... 1;season=1).

This would be useful for summarizing the activity of puppets.

Thanks,
HN67

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

NS API Historical resolutions

Postby Imperium Anglorum » Wed Jul 15, 2020 3:40 pm

The NS API doesn't have NSUN resolutions, I think. I tried with the following links:

https://www.nationstates.net/cgi-bin/ap ... resolution
https://www.nationstates.net/cgi-bin/ap ... resolution

Could it be added (or the specific location be added to the documentation, if already present)?
Last edited by Imperium Anglorum on Wed Jul 15, 2020 3:40 pm, edited 1 time in total.

Author: 1 SC and 36 GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and InfoEurope
Toxic villainous globalist kittehs
Delegate for Europe
Elsie Mortimer Wellesley (EMW); OOC unless otherwise indicated
Ideological Bulwark 285, WALL delegate
Dastardly villain providing free services to the community sans remuneration

User avatar
Valentine Z
Powerbroker
 
Posts: 8056
Founded: Nov 08, 2015
Left-wing Utopia

Postby Valentine Z » Tue Aug 18, 2020 4:08 am

API / Shard Request:

Hello there! Will it be possible to have "Issues Answered" as a separate shard that I can add together along with the other shards?

For my data-collecting purposes, I use this single line / API call to get all the data that I need: https://www.nationstates.net/cgi-bin/api.cgi?nation=valentine_z&q=policies+category+flag+region+census+sectors+deaths+govt+hdi;scale=all&cards+info. I unfortunately can't get the Issues Answered data this way, because it is only available in an API call without shards (https://www.nationstates.net/cgi-bin/api.cgi?nation=testlandia), and I don't really want to do 2 separate API calls for one nation.

Image


Thank you in advance! ^^
Last edited by Valentine Z on Tue Aug 18, 2020 4:19 am, edited 2 times in total.



Valentine Z GIF Flag (Improved!)
De Valentian CV.
Flag Bracket - 1st for Mk I! 2nd for Mk II!
Issues Thread 4th in Gen Sec

The Sixty! Opinions Deposit! Valentian Stories! Gwen's Adventures! Cat Anthem! Valentian News.
If you are reading my sig, I want you to have the best day ever ! You are worth it, do not let anyone get you down !
Glory to De Geweldige Sierlijke Katachtige Utopia en Zijne Autonome Machten ov Valentine Z !
Q & A Here! | Heights of NS! | F7 Etiquette

Clarissa mistaken for Smurf/Avatar: 10
Valentijn called She: 40
If above = 50, make him a Lesbian.

• Eat my fking tranquility. - Zenyatta
• Never trouble trouble until trouble troubles you.
• World Map is a cat playing with Australia.

• Am I a pretty girl?

User avatar
SherpDaWerp
Diplomat
 
Posts: 843
Founded: Mar 02, 2016
Civil Rights Lovefest

Postby SherpDaWerp » Sun Aug 23, 2020 4:51 pm

A couple additions to the basic nation query, please. Namely, I would like the plural forms of currency and animal to be made available.

I know the game has a system for custom pluralisations of different currencies, this thread specifies as much. I'm pretty sure a system for custom pluralisations of animals exists too: this thread certainly appears that way.

Could these fields be added to the basic nation query (https://www.nationstates.net/cgi-bin/api.cgi?nation=testlandia), similarly to Demonym2 and Demonym2Plural?

If this is unfeasible, then perhaps other queries could be added:
https://www.nationstates.net/cgi-bin/api.cgi?q=animalplurals
https://www.nationstates.net/cgi-bin/api.cgi?q=currencyplurals
that would return a list of singular fields and their plural variants, as tracked by the game. Format could be something like
Code: Select all
<DATA>
<CURRENCY>
<SINGULAR>denarius</SINGULAR>
<PLURAL>denarii</PLURAL>
</CURRENCY>
<CURRENCY>
<SINGULAR>yen</SINGULAR>
<PLURAL>yen</PLURAL>
</CURRENCY>
</DATA>

If it helps; my end goal here is to get an automatically-updating "spoiler list" of issues. Correctly categorising macros is going to be difficult (especially randomnames); I'm currently creating a list of all known fields from a nation so it's possible to do a "find-and-replace" search. That includes categorising plurals - if someone's currency is the "denarius" then my script won't pick up "denarii" as a @@CURRENCYPLURAL@@, it'll assume it's just a regular word. So, I want information about what the plurals are for a nation, so I can accurately categorise @@CURRENCYPLURAL@@ and @@ANIMALPLURAL@@ macros. Of course, currencies like the yen will be more annoying, but having plural information for such a currency will at least let me know that it could be a plural instead of assuming it's definitely a singular.


Also, bumping my request:
Can the "total amount bid" (as viewable on the bottom of this page) be added to the Deck Owner Info shard? It's publicly viewable information anyway, and it would make it possible to calculate the amount of bank a nation has "free" to use.
Last edited by SherpDaWerp on Sun Aug 23, 2020 7:16 pm, edited 2 times in total.

User avatar
Trotterdam
Powerbroker
 
Posts: 8853
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Tue Aug 25, 2020 6:19 am

Trotterdam wrote:I have another case of the "improperly initialized census scores" bug.

The zombie census scores are reported as blank on New Docistan. This is not true of all nations founded after the zombie apocalypse was over, as I verified by picking a random newly-made nation.
Wow, it's been that long since I reported this? (Well, this was slightly more recent.)

So since this is still happening (on a bunch of nations), I finally went and updated my own code to be a little more robust to bugged API results. Doesn't seem like they're ever going to get fixed properly.

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

Postby Imperium Anglorum » Thu Aug 27, 2020 1:06 pm

Last edited by Imperium Anglorum on Thu Aug 27, 2020 1:09 pm, edited 2 times in total.

Author: 1 SC and 36 GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and InfoEurope
Toxic villainous globalist kittehs
Delegate for Europe
Elsie Mortimer Wellesley (EMW); OOC unless otherwise indicated
Ideological Bulwark 285, WALL delegate
Dastardly villain providing free services to the community sans remuneration

User avatar
Evrigenis
Lobbyist
 
Posts: 16
Founded: Dec 12, 2019
Left-Leaning College State

Postby Evrigenis » Tue Sep 01, 2020 2:49 pm

A few rules clarifications, please:
1. “Using a script or tool to send telegrams from the regular Telegrams page is a violation of our Script Rules“. But since using the standard HTML form is (as far as I know) the only way to draft API telegrams, it is allowed to submit drafts via HTML (with the slower rate limit) since drafting does not fall under any of the restricted actions categories. Is this understanding correct?
2. To me, there seems to be a grey area between sending requests to the API and sending requests to the user-facing site. For example, I’ve noticed that the build_nation endpoint seems to have its own rate limit. Is there documentation about that?
3. Technically not part of the API, but still in that grey area: Is changing a nation’s flag considered a restricted action? I’d think it would be similar custom fields settings changes, but I’d rather be safe.

User avatar
Trotterdam
Powerbroker
 
Posts: 8853
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Tue Sep 01, 2020 3:22 pm

Trotterdam wrote:So since this is still happening (on a bunch of nations), I finally went and updated my own code to be a little more robust to bugged API results. Doesn't seem like they're ever going to get fixed properly.
...Which, of course, is how I discover that we're still also suffering blank census scores on issue-relevant scores. It does seem to have been fixed rather quickly (if you look now, the non-issue-relevant scores on The Most Holy E are blank, but the issue-relevant scores are not), but when my program looked two hours ago, the issue-relevant scores were too (or at least score 0, Civil Rights, was, at which point my program threw up and error and choked).

Evrigenis wrote:1. “Using a script or tool to send telegrams from the regular Telegrams page is a violation of our Script Rules“. But since using the standard HTML form is (as far as I know) the only way to draft API telegrams, it is allowed to submit drafts via HTML (with the slower rate limit) since drafting does not fall under any of the restricted actions categories. Is this understanding correct?
Why would you want to do that? Writing drafts is generally not something you want to do en masse, so it doesn't benefit from automation.

Evrigenis wrote:2. To me, there seems to be a grey area between sending requests to the API and sending requests to the user-facing site. For example, I’ve noticed that the build_nation endpoint seems to have its own rate limit. Is there documentation about that?
I'm not 100% sure what you're trying to ask here, but I've been kinda curious about a similar-sounding question, so I guess I'll ask.

The API ratelimit is (effectively) 100 requests per minute, while the non-API ratelimit is 10 requests per minute. How do these interact if you're using both? Could you do both at maximum throttle to send a total of 110 requests per minute, or should you apply an "exchange rate" where you get 100 points per minute, API requests cost 1 point, and non-API requests cost 10 points? Or just make no more than 100 total requests per minute, of which at most 10 may be non-API (leaving 90 for the API)?

It's not something I actually want to do (the API is a lot more convenient than site-scraping, and even when it doesn't cover something I might want to automate it's easier to ask for a new API feature than to scrape HTML that's meant to be human-readable), but I've been wondering.

Evrigenis wrote:3. Technically not part of the API, but still in that grey area: Is changing a nation’s flag considered a restricted action? I’d think it would be similar custom fields settings changes, but I’d rather be safe.
Hmm. My first guess was that it would be allowed by a literal reading of the current rules since it isn't changing anything except your own nation. Then I realized that since your flag is also displayed on the regional and world nation lists (and in, say, the happenings of another nation that you interacted with, such as by endorsing), it technically does affect something other than your own nation. Then again, the same also applies to pretitles, and I really thought you were allowed to change those. And then I took a closer look at the current rules and saw that the exact wording is "anything that generates a Happenings event line in a region, the World Assembly, or a nation other than your own", which means that it would be okay, since changing your flag definitely doesn't do that.

Regardless of the current words-as-written, though, the unusually large data transfer involved in uploading a new flag image means that it isn't something you should spam. So even if the current rules don't technically forbid it, I think that's an oversight, and it probably should be.

User avatar
United Calanworie
Secretary
 
Posts: 37
Founded: Dec 12, 2018
Democratic Socialists

[API] N-Day shard request

Postby United Calanworie » Tue Sep 01, 2020 4:51 pm

Can we get a shard for factions that returns the number of nations in that faction? It'd be exceptionally useful for a variety of things, including history tracking of factions, and analyzing the growth of factions over the event.
Aav#7137

* The Ragerian Imperium
* Hartfelden
* WebTrigger

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

Postby [violet] » Tue Sep 01, 2020 5:09 pm

United Calanworie wrote:Can we get a shard for factions that returns the number of nations in that faction? It'd be exceptionally useful for a variety of things, including history tracking of factions, and analyzing the growth of factions over the event.

Added as <NATIONS> in the "factions" shard. Example.

User avatar
United Calanworie
Secretary
 
Posts: 37
Founded: Dec 12, 2018
Democratic Socialists

Postby United Calanworie » Tue Sep 01, 2020 5:27 pm

[violet] wrote:
United Calanworie wrote:Can we get a shard for factions that returns the number of nations in that faction? It'd be exceptionally useful for a variety of things, including history tracking of factions, and analyzing the growth of factions over the event.

Added as <NATIONS> in the "factions" shard. Example.

Thanks [v]!
Aav#7137

* The Ragerian Imperium
* Hartfelden
* WebTrigger

User avatar
Valentine Z
Powerbroker
 
Posts: 8056
Founded: Nov 08, 2015
Left-wing Utopia

Postby Valentine Z » Thu Sep 03, 2020 9:10 pm

Valentine Z wrote:API / Shard Request:

Hello there! Will it be possible to have "Issues Answered" as a separate shard that I can add together along with the other shards?

For my data-collecting purposes, I use this single line / API call to get all the data that I need: https://www.nationstates.net/cgi-bin/api.cgi?nation=valentine_z&q=policies+category+flag+region+census+sectors+deaths+govt+hdi;scale=all&cards+info. I unfortunately can't get the Issues Answered data this way, because it is only available in an API call without shards (https://www.nationstates.net/cgi-bin/api.cgi?nation=testlandia), and I don't really want to do 2 separate API calls for one nation.



Thank you in advance! ^^

I hope you don't mind me bumping it, and pardon the impatience I might have hinted, but I would still like this for my next data trawl. ^^

In short, I would like Issues_Answered as a public shard that I can add into here the URL/API call.
Last edited by Valentine Z on Thu Sep 03, 2020 9:11 pm, edited 1 time in total.



Valentine Z GIF Flag (Improved!)
De Valentian CV.
Flag Bracket - 1st for Mk I! 2nd for Mk II!
Issues Thread 4th in Gen Sec

The Sixty! Opinions Deposit! Valentian Stories! Gwen's Adventures! Cat Anthem! Valentian News.
If you are reading my sig, I want you to have the best day ever ! You are worth it, do not let anyone get you down !
Glory to De Geweldige Sierlijke Katachtige Utopia en Zijne Autonome Machten ov Valentine Z !
Q & A Here! | Heights of NS! | F7 Etiquette

Clarissa mistaken for Smurf/Avatar: 10
Valentijn called She: 40
If above = 50, make him a Lesbian.

• Eat my fking tranquility. - Zenyatta
• Never trouble trouble until trouble troubles you.
• World Map is a cat playing with Australia.

• Am I a pretty girl?

User avatar
The Python
Civilian
 
Posts: 1
Founded: Jul 24, 2020
Left-wing Utopia

Founding nations

Postby The Python » Sat Sep 12, 2020 3:56 pm

How do you automatically found nations using the API?

User avatar
Merni
Ambassador
 
Posts: 1271
Founded: May 03, 2016
Democratic Socialists

Postby Merni » Sat Sep 12, 2020 8:50 pm

The Python wrote:How do you automatically found nations using the API?

Not possible.
COVID19 still exists! | Free time? Help Gutenberg!
The Labyrinth | GA Committee List | Tools written by me

Admins: Please allow blocking WA TGs!
Fora
NSP2:zxq
Anti-R/D demsoc
meth
I've noticed that everybody that is for abortion has already been born. — Ronald Reagan

When the people are being beaten with a stick, they are not much happier if it is called 'the People’s Stick.' — Mikhail Bakunin (to Karl Marx)

You're supposed to be employing the arts of diplomacy, not the ruddy great thumping sledgehammers of diplomacy. — Ardchoille

The West won the world not by the superiority of its ideas or values or religion [...] but rather by its superiority in applying organised violence. — Samuel P. Huntington (even he said that!)

E -7.75 S -3.64

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

Postby [violet] » Sun Sep 13, 2020 5:31 pm

Valentine Z wrote:API / Shard Request:

Hello there! Will it be possible to have "Issues Answered" as a separate shard that I can add together along with the other shards?

For my data-collecting purposes, I use this single line / API call to get all the data that I need: https://www.nationstates.net/cgi-bin/api.cgi?nation=valentine_z&q=policies+category+flag+region+census+sectors+deaths+govt+hdi;scale=all&cards+info. I unfortunately can't get the Issues Answered data this way, because it is only available in an API call without shards (https://www.nationstates.net/cgi-bin/api.cgi?nation=testlandia), and I don't really want to do 2 separate API calls for one nation.

Added! There is now an "answered" shard.

User avatar
Valentine Z
Powerbroker
 
Posts: 8056
Founded: Nov 08, 2015
Left-wing Utopia

Postby Valentine Z » Sun Sep 13, 2020 10:12 pm

[violet] wrote:
Valentine Z wrote:API / Shard Request:

Hello there! Will it be possible to have "Issues Answered" as a separate shard that I can add together along with the other shards?

For my data-collecting purposes, I use this single line / API call to get all the data that I need: https://www.nationstates.net/cgi-bin/api.cgi?nation=valentine_z&q=policies+category+flag+region+census+sectors+deaths+govt+hdi;scale=all&cards+info. I unfortunately can't get the Issues Answered data this way, because it is only available in an API call without shards (https://www.nationstates.net/cgi-bin/api.cgi?nation=testlandia), and I don't really want to do 2 separate API calls for one nation.

Added! There is now an "answered" shard.

Woo hoo, thanks, Violet! ^^



Valentine Z GIF Flag (Improved!)
De Valentian CV.
Flag Bracket - 1st for Mk I! 2nd for Mk II!
Issues Thread 4th in Gen Sec

The Sixty! Opinions Deposit! Valentian Stories! Gwen's Adventures! Cat Anthem! Valentian News.
If you are reading my sig, I want you to have the best day ever ! You are worth it, do not let anyone get you down !
Glory to De Geweldige Sierlijke Katachtige Utopia en Zijne Autonome Machten ov Valentine Z !
Q & A Here! | Heights of NS! | F7 Etiquette

Clarissa mistaken for Smurf/Avatar: 10
Valentijn called She: 40
If above = 50, make him a Lesbian.

• Eat my fking tranquility. - Zenyatta
• Never trouble trouble until trouble troubles you.
• World Map is a cat playing with Australia.

• Am I a pretty girl?

Previous

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Keipeitaoic Tai Pei, Phydios, The USOC

Advertisement

Remove ads