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
Minoa
Negotiator
 
Posts: 6079
Founded: Oct 05, 2011
Civil Rights Lovefest

Postby Minoa » Thu Nov 02, 2017 11:25 am

Eluvatar wrote:
Minoa wrote:While testing a census query (https://www.nationstates.net/cgi-bin/ap ... mode=score and https://www.nationstates.net/cgi-bin/ap ... p;scale=76), I noticed that Census ID 76 is returning a number in exponential form, but the "gdp" shard returns the full number correctly.

I wonder if the Census ID 76 shard can be shown as a full number like the "gdp" shard?

Also, I would like to see the ability to exclude certain shards while doing the "scale=all" query: for example, I type "scale=all-81-82-83-84" (literally "all scales except 81-84") to exclude the Zombie-related shards.

-- Minoa


I think it would make sense for 'all' to mean 'all active' and ignore the shards that aren't being updated. I would like to confirm [violet] doesn't have any issue with such a change first however.

I have no thoughts on census 76.

In respect of the Z-day IDs, may I suggest that:

  • "scale=all" returns censuses 0-80 (without the Z-day specific categories).
  • "scale=all+z" returns censuses 0-84 (with the Z-day specific categories).
However, my suggestion for exclusion filters ("scale=all-65-80", for example) still stand, as I am planning to exclude a handful of census IDs that are irrelevant to my tests, yet still be useful to others.
Mme A. d'Oiseau, B.A. (State of Minoa)

User avatar
Trotterdam
Postmaster-General
 
Posts: 10541
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Thu Nov 02, 2017 12:52 pm

It's always possible to spell out the censi you want as 0+1+2+3+4+5+6+7+8+9+10+11+12+etc. It's long, but there's no maximum limit on URL lengths, and the string is easy enough to construct if you use a loop rather than do it manually.

If you use "all", there's always a risk that you'll catch new censi that were just added to the game and that your script doesn't know about yet. If you want only the ones that you explicitly know what to do with, you shouldn't use "all".

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

Postby [violet] » Thu Nov 02, 2017 4:18 pm

Eluvatar wrote:I think it would make sense for 'all' to mean 'all active' and ignore the shards that aren't being updated.

Yep, agreed.

"all+z" I have no real opinion on.

Exclusions sound troublesome, for the reason Trotterdam mentions... it creates a trap for script authors who think they're defining the precise scales they want, but aren't.

User avatar
Mexico y Luisiana
Political Columnist
 
Posts: 3
Founded: Oct 28, 2016
Ex-Nation

Discord Help

Postby Mexico y Luisiana » Fri Nov 03, 2017 8:10 pm

I am new to API but have seen it used and was thinking it would be great if I could connect Discord to the RMB of my region, however, I am not sure how to do it can I get some help I read the guide and my head spun.

User avatar
Glen-Rhodes
Powerbroker
 
Posts: 9027
Founded: Jun 25, 2008
Ex-Nation

Postby Glen-Rhodes » Sun Nov 05, 2017 5:22 pm

Mexico y Luisiana wrote:I am new to API but have seen it used and was thinking it would be great if I could connect Discord to the RMB of my region, however, I am not sure how to do it can I get some help I read the guide and my head spun.

You'd need to learn Node.js first of all, because Discord bots use that. Once you have a good command of that, you'd basically just need to grab the API data for your RMB posts, format it, and have your bot spit that out in your channel.

If you're asking about posting to the RMB from Discord, that's not allowed or even possible at the moment.

User avatar
Darcania
Envoy
 
Posts: 205
Founded: Dec 29, 2014
Civil Rights Lovefest

Postby Darcania » Sun Nov 05, 2017 5:31 pm

Glen-Rhodes wrote:You'd need to learn Node.js first of all, because Discord bots use that. Once you have a good command of that, you'd basically just need to grab the API data for your RMB posts, format it, and have your bot spit that out in your channel.

If you're asking about posting to the RMB from Discord, that's not allowed or even possible at the moment.

Not all Discord bots use Node.js. Just Google a Discord API wrapper for your language of choice and you should find one (the one I use is discord.py for Python, for example).

User avatar
Flanderlion
Minister
 
Posts: 2226
Founded: Nov 25, 2013
Psychotic Dictatorship

Postby Flanderlion » Sun Nov 05, 2017 6:03 pm

Glen-Rhodes wrote:
Mexico y Luisiana wrote:I am new to API but have seen it used and was thinking it would be great if I could connect Discord to the RMB of my region, however, I am not sure how to do it can I get some help I read the guide and my head spun.

You'd need to learn Node.js first of all, because Discord bots use that. Once you have a good command of that, you'd basically just need to grab the API data for your RMB posts, format it, and have your bot spit that out in your channel.

If you're asking about posting to the RMB from Discord, that's not allowed or even possible at the moment.

Wouldn't it count as a restricted action, but still be doable?
As always, I'm representing myself.
Information
Wishlist

User avatar
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Sun Nov 05, 2017 6:31 pm

Flanderlion wrote:
Glen-Rhodes wrote:You'd need to learn Node.js first of all, because Discord bots use that. Once you have a good command of that, you'd basically just need to grab the API data for your RMB posts, format it, and have your bot spit that out in your channel.

If you're asking about posting to the RMB from Discord, that's not allowed or even possible at the moment.

Wouldn't it count as a restricted action, but still be doable?


I think there's a good chance that a (non-bot) user sending a Discord message could count as user input for the purposes of restricted actions.

There'd be trouble with following the simultaneity rule, however.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Glen-Rhodes
Powerbroker
 
Posts: 9027
Founded: Jun 25, 2008
Ex-Nation

Postby Glen-Rhodes » Mon Nov 06, 2017 9:10 am

Eluvatar wrote:
Flanderlion wrote:Wouldn't it count as a restricted action, but still be doable?


I think there's a good chance that a (non-bot) user sending a Discord message could count as user input for the purposes of restricted actions.

There'd be trouble with following the simultaneity rule, however.

Is there a way for a third-party server to post RMB messages on behalf of another user, though?

User avatar
Mexico y Luisiana
Political Columnist
 
Posts: 3
Founded: Oct 28, 2016
Ex-Nation

Postby Mexico y Luisiana » Mon Nov 06, 2017 10:23 pm

Glen-Rhodes wrote:
Mexico y Luisiana wrote:I am new to API but have seen it used and was thinking it would be great if I could connect Discord to the RMB of my region, however, I am not sure how to do it can I get some help I read the guide and my head spun.

You'd need to learn Node.js first of all, because Discord bots use that. Once you have a good command of that, you'd basically just need to grab the API data for your RMB posts, format it, and have your bot spit that out in your channel.

If you're asking about posting to the RMB from Discord, that's not allowed or even possible at the moment.


I was asking about the other way around I want the message people post in the RMB to be posted in discord so people get an alert when someone post. As for the rest of that I don't really understand.
Edit Sorry the top part was the relevant part don't know or understand much about this hence why I am asking.
Could someone give me more of a step by step guide please?
Last edited by Mexico y Luisiana on Mon Nov 06, 2017 11:32 pm, edited 2 times in total.

User avatar
Phydios
Minister
 
Posts: 2569
Founded: Dec 06, 2014
Left-Leaning College State

Postby Phydios » Tue Nov 07, 2017 9:36 pm

Mexico y Luisiana wrote:
Glen-Rhodes wrote:You'd need to learn Node.js first of all, because Discord bots use that. Once you have a good command of that, you'd basically just need to grab the API data for your RMB posts, format it, and have your bot spit that out in your channel.

If you're asking about posting to the RMB from Discord, that's not allowed or even possible at the moment.


I was asking about the other way around I want the message people post in the RMB to be posted in discord so people get an alert when someone post. As for the rest of that I don't really understand.
Edit Sorry the top part was the relevant part don't know or understand much about this hence why I am asking.
Could someone give me more of a step by step guide please?

You need to have knowledge of Node.js first. That's the language Discord bots use. Here's a good place to start learning. Until you learn that, the other steps won't really make sense.
If you claim to be religious but don’t control your tongue, you are fooling yourself, and your religion is worthless. Pure and genuine religion in the sight of God the Father means caring for orphans and widows in their distress and refusing to let the world corrupt you. | Not everyone who calls out to me, ‘Lord! Lord!’ will enter the Kingdom of Heaven. Only those who actually do the will of my Father in heaven will enter. On judgment day many will say to me, ‘Lord! Lord! We prophesied in your name and cast out demons in your name and performed many miracles in your name.’ But I will reply, ‘I never knew you. Get away from me, you who break God’s laws.’
James 1:26-27, Matthew 7:21-23

User avatar
Darcania
Envoy
 
Posts: 205
Founded: Dec 29, 2014
Civil Rights Lovefest

Postby Darcania » Tue Nov 07, 2017 11:01 pm

Phydios wrote:You need to have knowledge of Node.js first. That's the language Discord bots use. Here's a good place to start learning. Until you learn that, the other steps won't really make sense.

As I said just five posts ago, you don't have to learn Node.js. viewtopic.php?p=32828212#p32828212

User avatar
Mexico y Luisiana
Political Columnist
 
Posts: 3
Founded: Oct 28, 2016
Ex-Nation

Postby Mexico y Luisiana » Thu Nov 09, 2017 7:54 am

Darcania wrote:
Phydios wrote:You need to have knowledge of Node.js first. That's the language Discord bots use. Here's a good place to start learning. Until you learn that, the other steps won't really make sense.

As I said just five posts ago, you don't have to learn Node.js. viewtopic.php?p=32828212#p32828212

Okay so I have downloaded the top result for discord api wrapper but the more I look at it the more confused I get thanks for the help though I think doing it manually will still be less time consuming so I will stick with that.

User avatar
Trotterdam
Postmaster-General
 
Posts: 10541
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Thu Nov 09, 2017 6:08 pm

I was asked to cross-post my request in this thread, so here goes:

I would like a national policies shard on the API. Returned fields should include category ("Government"), title/name ("Autocracy"), description ("The nation does not hold democratic elections."), and banner number ("k8").

Perhaps even a world API shard for all policies that can exist, like how we can look up banners by number regardless of whether we know of a nation that has them? In which case, the national API could just reference these rather than including the full description on each request, just like with banners.

(I also still want notables and admirables shards, the policy listing has a lot of overlap in function but is not identical.)

User avatar
Greater Tern
Envoy
 
Posts: 331
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Thu Nov 09, 2017 10:14 pm

I'd love to have a nation API on policies as well.

EDIT: Also, are there any changes to the issues API now that policies show up when answering issues?
Last edited by Greater Tern on Thu Nov 09, 2017 10:26 pm, edited 1 time in total.

User avatar
Kethania
Lobbyist
 
Posts: 21
Founded: Nov 01, 2015
Left-wing Utopia

Postby Kethania » Fri Nov 10, 2017 3:46 am

Trotterdam wrote:I would like a national policies shard on the API. Returned fields should include category ("Government"), title/name ("Autocracy"), description ("The nation does not hold democratic elections."), and banner number ("k8").

To add to that list, there also needs to be a way to determine if the effect is "negative," as in whether the banner has to be crossed out or not.


On the private issues shard, there is a bug where autoselected pronouns differ even though they relate to the same character. The most absurd example of this is the issue #709:
Walking down the corridors of power at your usual brisk pace, you’re caught a little off guard when one of your accompanying clerks suddenly crumples to the ground mid-stride, her left lower leg detaching from the rest of him. To your relief, the dismembered member of staff has in fact lost a prosthetic limb rather than an organic one. As you help her up, she explains that his prosthetic is a cheap import of low quality: she’d love a better one, but high quality models are far and few between.

I was unable to reproduce this issue on the web interface, so I'm assuming it's API-specific.


I once again wish to attract admin attention to macros not being expanded in the headlines of the private issue comand. This is causing me great inconvenience, as they are quite inconsistent and unpredictable. I've encountered oddities such as:
Code: Select all
@@PL(DEMONYM2)@@
@@uc($nation->query("name"))@@
@@$nation->query_capital()@@

As I have no way to collect all of the possible headlines, I can only add corner cases as these when I encounter them during normal usage, which is rather suboptimal.

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

Postby [violet] » Fri Nov 10, 2017 9:36 pm

Trotterdam wrote:I would like a national policies shard on the API.

Added "policies" shard. Here's an example, as per the updated doc:

https://www.nationstates.net/cgi-bin/ap ... q=policies

i.e.
Code: Select all
<NATION id="testlandia">
  <POLICIES>
    <POLICY>
      <NAME>Devolution</NAME>
      <PIC>t64</PIC>
      <CAT>Government</CAT>
      <DESC>Government power is substantially delegated to local authorities.</DESC>
    </POLICY>
    <POLICY>
      <NAME>Free Press</NAME>
      <PIC>tv7</PIC>
      <CAT>Government</CAT>
      <DESC>The media's right to free reporting is legally protected.</DESC>
    </POLICY>
    ...


Greater Tern wrote:Also, are there any changes to the issues API now that policies show up when answering issues?

Yep, when answering an issue via the private API command "issue", the returning hash may now include the new fields <NEW_POLICIES> and <REMOVED_POLICIES>. When present, these will include a list of policies following the same format as the "policies" shard above. When absent, that means no policies were added/removed by that issue choice.

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

Postby [violet] » Fri Nov 10, 2017 9:53 pm

Kethania wrote:On the private issues shard, there is a bug where autoselected pronouns differ even though they relate to the same character.

Should be fixed now.

Kethania wrote:I once again wish to attract admin attention to macros not being expanded in the headlines of the private issue comand.

Sorry about that! Now fixed.

User avatar
Greater Tern
Envoy
 
Posts: 331
Founded: Mar 04, 2010
Civil Rights Lovefest

Postby Greater Tern » Sat Nov 11, 2017 1:45 am

Thank you so much [v]! Looks great so far.

User avatar
Caelapes
Ambassador
 
Posts: 1543
Founded: Apr 30, 2007
Ex-Nation

Postby Caelapes » Sun Nov 12, 2017 9:18 am

Noticed something peculiar - the numbers of nations between the region and nation data dumps don't match up. The most recent nation data dump has information on 153,742 nations; the region data dump only has 141,280 nations in it. I know nations move around during update, but the World page says that NationStates currently has over 174,000 nations. Is it really possible that between 20,000 and 30,000 nations surf update and don't get caught in the daily dumps? Or are there 20-30,000 nations not being updated properly?
    
The Rose Commune of Caelapes
Ego vero custos fratris mei sum.
aka Misley

User avatar
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Sun Nov 12, 2017 9:41 am

Caelapes wrote:Noticed something peculiar - the numbers of nations between the region and nation data dumps don't match up. The most recent nation data dump has information on 153,742 nations; the region data dump only has 141,280 nations in it. I know nations move around during update, but the World page says that NationStates currently has over 174,000 nations. Is it really possible that between 20,000 and 30,000 nations surf update and don't get caught in the daily dumps? Or are there 20-30,000 nations not being updated properly?

The last update saw a large number of nations not update properly. This should be fixed now.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Leppikania
Minister
 
Posts: 2332
Founded: Apr 13, 2015
Left-wing Utopia

Postby Leppikania » Sun Nov 19, 2017 1:28 pm

I've been getting a lot of 500 errors recently, and I think it's from the database issues. But why am I getting so many 403s?
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
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Sun Nov 19, 2017 1:41 pm

Leppikania wrote:I've been getting a lot of 500 errors recently, and I think it's from the database issues. But why am I getting so many 403s?

Could you be more specific?
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Leppikania
Minister
 
Posts: 2332
Founded: Apr 13, 2015
Left-wing Utopia

Postby Leppikania » Sun Nov 19, 2017 2:23 pm

Eluvatar wrote:
Leppikania wrote:I've been getting a lot of 500 errors recently, and I think it's from the database issues. But why am I getting so many 403s?

Could you be more specific?

My script got 25 403s last night. That's all it's telling me. I've set it up to show the actual error message next time, though.
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
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Sun Nov 19, 2017 3:20 pm

Leppikania wrote:
Eluvatar wrote:Could you be more specific?

My script got 25 403s last night. That's all it's telling me. I've set it up to show the actual error message next time, though.

You got 403s when the site was taken down for maintenance. You got 500s when the site went down on its own.
To Serve and Protect: UDL

Eluvatar - Taijitu member

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Destral nui, Missouria, New Aradania, North American Imperial State, Oceara, Riemstagrad, Santiago AU, Smatania, The Fennecs

Advertisement

Remove ads