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
United Calanworie
Technical Moderator
 
Posts: 3843
Founded: Dec 12, 2018
Democratic Socialists

Postby United Calanworie » Wed Jul 26, 2023 2:19 pm

Not at this time, unless my colleagues have one and haven't shared it.
Trans rights are human rights.
||||||||||||||||||||
Discord: Aav#7546 @queerlyfe
She/Her/Hers
My telegrams are not for Moderation enquiries, those belong in a GHR. Feel free to reach out if you want to just chat.

User avatar
Improper Classifications
Ambassador
 
Posts: 1323
Founded: Apr 18, 2022
Iron Fist Consumerists

Postby Improper Classifications » Wed Jul 26, 2023 2:27 pm

OK, thank you.
Former Acolyte of Malice
Founder and Champion of Voidcall, Conqueror of Majesty and Pentarchs.
Legally proscribed in The South Pacific under On Concord.
The Imperial Federation of Improper Classifications

User avatar
The Ice States
GA Secretariat
 
Posts: 2902
Founded: Jun 23, 2022
Compulsory Consumerist State

Postby The Ice States » Wed Aug 02, 2023 11:26 pm

Why does the <COAUTHOR> tag of the proposals API shard now give strings such as "ARRAY(0x7f8d078abcc8)" instead of the actual co-authors listed in <N> tags? It returning these strings appears to be new behaviour, CF: The resolution shard.
Last edited by The Ice States on Wed Aug 02, 2023 11:27 pm, edited 1 time in total.
Factbooks · 46x World Assembly Author · Festering Snakepit Wiki · WACampaign · GA Stat Effects Data

Posts in the WA forums are Ooc and unofficial, absent indication otherwise.
Please check out my roleplay thread The Battle of Glass Tears!
WA 101 Guides to GA authorship, campaigning, and more.

User avatar
United Calanworie
Technical Moderator
 
Posts: 3843
Founded: Dec 12, 2018
Democratic Socialists

Postby United Calanworie » Wed Aug 02, 2023 11:28 pm

The Ice States wrote:Why does the <COAUTHOR> tag of the proposals API shard now give strings such as "ARRAY(0x7f8d078abcc8)" instead of the actual co-authors listed in <N> tags? It returning these strings appears to be new, CF: The resolution shard.

As remarked on off-site, this is due to the API going "ah yes, you *totally* wanted to have me just send the memory address of an array across the internet, didn't you?" A certified Perl classic, if you ask me.

Ideally it'll get fixed at some point in the near future.
Trans rights are human rights.
||||||||||||||||||||
Discord: Aav#7546 @queerlyfe
She/Her/Hers
My telegrams are not for Moderation enquiries, those belong in a GHR. Feel free to reach out if you want to just chat.

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

Postby Ever-Wandering Souls » Thu Aug 03, 2023 7:05 am

Roavin wrote:
Ever-Wandering Souls wrote:If you mean specific to the values themselves, they're largely possible to approximate as-is with the influence census, endos census, activity, and a loose approximation of the decay rate - accurately enough to get the job done at least. I do it for ops all the time. It just requires a massive pain in the ass spreadsheet of starting inf + endos at update (in or out of the region) - assumed decay, updated twice daily.


Having done this myself, I feel your pain :P

I'll bring the suggestion up backstage.


Bumping this.
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
Grishahakkaverchynot
Spokesperson
 
Posts: 147
Founded: May 06, 2020
Capitalizt

Postby Grishahakkaverchynot » Sat Aug 05, 2023 10:21 am

I think that maybe, if you want people to stop using the HTML site to do script stuff, it might help adding RO actions as performable API actions?
Founder of Grishahakkaverchynot League, Keepermaster of the Verchy Realms.
sudo rm -rf / --no-preserve-root, the best form of space saving.
Writer of the 59th most upvoted dispatch!
Nation turned 3 years old on May 6th 2023.

User avatar
United Calanworie
Technical Moderator
 
Posts: 3843
Founded: Dec 12, 2018
Democratic Socialists

Postby United Calanworie » Sat Aug 05, 2023 10:36 am

Could you expand more on that, please?
Trans rights are human rights.
||||||||||||||||||||
Discord: Aav#7546 @queerlyfe
She/Her/Hers
My telegrams are not for Moderation enquiries, those belong in a GHR. Feel free to reach out if you want to just chat.

User avatar
Vleerian
Spokesperson
 
Posts: 137
Founded: Feb 07, 2022
Compulsory Consumerist State

Postby Vleerian » Sun Aug 06, 2023 7:18 pm

Could a card's current Market Value be added to the Deck Info API?
Something like this
Code: Select all
<CARDS>
  <DECK>
    <CARD>
      <CARDID>1526694</CARDID>
      <CATEGORY>common</CATEGORY>
      <SEASON>1</SEASON>
      <MARKETVALUE>0.01</MARKETVALUE>
    </CARD>
    ...
  </DECK>
</CARDS>

The reason being that while a card's market value is available via the API when requesting data for a single card that you own, getting the market value of every card in your deck is not practical. If you have the basic maximum deck size of 250 you're looking two and a half straight minutes of polling, assuming all unique cards. That number skyrockets when you're looking at a puppet farm.
Vleerian - Also known as Aurum Rider
Cretox State wrote:“We treat your shipment like it’s ours!”

Creator of FATTKatt

User avatar
Vleerian
Spokesperson
 
Posts: 137
Founded: Feb 07, 2022
Compulsory Consumerist State

Postby Vleerian » Sat Aug 12, 2023 9:37 am

Also, could an API endpoint be added that provides the most recent trading card season? Something like
https://www.nationstates.net/cgi-bin/ap ... cardseason
Code: Select all
<CARDS>
  <CARDSEASON>3</CARDSEASON>
</CARDS>

It would help immensely in future-proofing scripts that work with the cards API, especially where a script has to download and digest the cards data dumps on their first run.

EDIT:
Also, adding "packs" to a Trading Cards Private API (a la the current nation shard) would be useful, and cut the number of requests needed to get basic trading cards data in half.
Last edited by Vleerian on Sun Aug 20, 2023 3:13 pm, edited 2 times in total.
Vleerian - Also known as Aurum Rider
Cretox State wrote:“We treat your shipment like it’s ours!”

Creator of FATTKatt

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

Postby Eluvatar » Mon Aug 21, 2023 4:20 pm

Grishahakkaverchynot wrote:I think that maybe, if you want people to stop using the HTML site to do script stuff, it might help adding RO actions as performable API actions?
Improper Classifications wrote:Is there a private API command that allows Executive regional officers to appoint and dismiss officers?

What use case(s) would you like to support with such an API?
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Improper Classifications
Ambassador
 
Posts: 1323
Founded: Apr 18, 2022
Iron Fist Consumerists

Postby Improper Classifications » Mon Aug 21, 2023 9:46 pm

Eluvatar wrote:
Grishahakkaverchynot wrote:I think that maybe, if you want people to stop using the HTML site to do script stuff, it might help adding RO actions as performable API actions?
Improper Classifications wrote:Is there a private API command that allows Executive regional officers to appoint and dismiss officers?

What use case(s) would you like to support with such an API?

I’m thinking an auto elections bot. It can use your region’s Governor login (obviously the tool creator has no access to the login) to appoint and dismiss officers during elections. Not a crazy use case, just something I came up with at 4 am, so judge appropriately.
Former Acolyte of Malice
Founder and Champion of Voidcall, Conqueror of Majesty and Pentarchs.
Legally proscribed in The South Pacific under On Concord.
The Imperial Federation of Improper Classifications

User avatar
9003
Diplomat
 
Posts: 624
Founded: Oct 25, 2012
Corporate Police State

Postby 9003 » Fri Aug 25, 2023 9:12 am

Could we have an endpoint to check if a region has a welcome TG set, if so by who and how long could be included but with frontier spawns being influenced by welcome TG easy access to that data would be really nice. Rather than scraping it from the admin page of a region.
proud member of PETZ people for the Ethical Treatment of Zombies

Active member of The cards market place discord

User avatar
9003
Diplomat
 
Posts: 624
Founded: Oct 25, 2012
Corporate Police State

[API BUG]Co-Authors show up as ARRAY location not names

Postby 9003 » Fri Sep 29, 2023 9:31 am

Steps to reproduce
goto/request

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

Look at

<COAUTHOR>ARRAY(0x7f8da2748e98)</COAUTHOR>


It should be the data in the array and not the memory location of the array.
proud member of PETZ people for the Ethical Treatment of Zombies

Active member of The cards market place discord

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

Postby Eluvatar » Fri Sep 29, 2023 12:06 pm

United Calanworie wrote:
The Ice States wrote:Why does the <COAUTHOR> tag of the proposals API shard now give strings such as "ARRAY(0x7f8d078abcc8)" instead of the actual co-authors listed in <N> tags? It returning these strings appears to be new, CF: The resolution shard.

As remarked on off-site, this is due to the API going "ah yes, you *totally* wanted to have me just send the memory address of an array across the internet, didn't you?" A certified Perl classic, if you ask me.

Ideally it'll get fixed at some point in the near future.

9003 wrote:Steps to reproduce
goto/request

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

Look at

<COAUTHOR>ARRAY(0x7f8da2748e98)</COAUTHOR>


It should be the data in the array and not the memory location of the array.

A change has been drafted to fix this and should be available for your pleasure within a day or two now.
Last edited by Eluvatar on Fri Sep 29, 2023 3:09 pm, edited 1 time in total.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
9003
Diplomat
 
Posts: 624
Founded: Oct 25, 2012
Corporate Police State

Postby 9003 » Fri Sep 29, 2023 4:58 pm

Eluvatar wrote:
United Calanworie wrote:As remarked on off-site, this is due to the API going "ah yes, you *totally* wanted to have me just send the memory address of an array across the internet, didn't you?" A certified Perl classic, if you ask me.

Ideally it'll get fixed at some point in the near future.

9003 wrote:Steps to reproduce
goto/request

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

Look at

<COAUTHOR>ARRAY(0x7f8da2748e98)</COAUTHOR>


It should be the data in the array and not the memory location of the array.

A change has been drafted to fix this and should be available for your pleasure within a day or two now.


Perfect! *leaves out milk and cookies for Santa Elu*
proud member of PETZ people for the Ethical Treatment of Zombies

Active member of The cards market place discord

User avatar
United States of Dictators
Civil Servant
 
Posts: 9
Founded: Dec 23, 2021
Civil Rights Lovefest

Postby United States of Dictators » Sun Oct 22, 2023 7:35 am

I was trying to edit a dispatch using the Dispatch API and got an no X-Pin error. I then looked into the prepare request's headers and found this:
Code: Select all
Headers({'server': 'cloudflare', 'date': 'Sun, 22 Oct 2023 14:21:38 GMT', 'content-type': 'text/html', 'content-length': '175', 'connection': 'close', 'cf-ray': '-'})


I then did another test dispatch with a single text and it worked so I'm thinking content length is too much here, but I've seen dispatches with way bigger text being updated by the API. What's the problem?

UPDATE: I fixed it by sending the data in a POST request with payload.
Last edited by United States of Dictators on Sun Oct 22, 2023 11:29 pm, edited 2 times in total.
Programmer/Graphic Designer. Mainly based in The North Pacific and The Wellspring.

User avatar
The Ice States
GA Secretariat
 
Posts: 2902
Founded: Jun 23, 2022
Compulsory Consumerist State

Postby The Ice States » Sun Oct 22, 2023 7:53 pm

Apparently trying to rewrite a dispatch using the API with content including " System" results in a CORS error. Is there a way to fix or otherwise get around this other than eliminating the string from the content?

Edit: I "fixed" the issue by using the character " " instead of an actual space, but I still wonder why this happens.
Last edited by The Ice States on Sun Oct 22, 2023 8:55 pm, edited 6 times in total.
Factbooks · 46x World Assembly Author · Festering Snakepit Wiki · WACampaign · GA Stat Effects Data

Posts in the WA forums are Ooc and unofficial, absent indication otherwise.
Please check out my roleplay thread The Battle of Glass Tears!
WA 101 Guides to GA authorship, campaigning, and more.

User avatar
Devious
Spokesperson
 
Posts: 133
Founded: Oct 07, 2019
Left-Leaning College State

Postby Devious » Fri Oct 27, 2023 3:37 pm

would it be at all possible to include nation deletions in the happenings shard? as things currently are, filter=cte seems to cover nations dying of natural causes, but not DEATs.
||puppetmaster behind the rightful regimes of warzones sandbox, airspace, europe, australia, and africa||
||gremlin||
||oppressed gamer||
||STAND WITH BALD||

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

Postby Frisbeeteria » Fri Oct 27, 2023 6:48 pm

Devious wrote:filter=cte seems to cover nations dying of natural causes, but not DEATs.

Why do you need this? Make your case, please.

They don't appear in the Happening because we have a feature called "silent DEAT". As a general rule, we don't want to promote the offensive names we delete by posting happenings. For particularly egregious offensive nations, we actually purge all happenings (moves, issues, posts, etc) so players don't have to look at remnants of that sort of nonsense.

User avatar
Devious
Spokesperson
 
Posts: 133
Founded: Oct 07, 2019
Left-Leaning College State

Postby Devious » Fri Oct 27, 2023 8:37 pm

Frisbeeteria wrote:
Devious wrote:filter=cte seems to cover nations dying of natural causes, but not DEATs.

Why do you need this? Make your case, please.

They don't appear in the Happening because we have a feature called "silent DEAT". As a general rule, we don't want to promote the offensive names we delete by posting happenings. For particularly egregious offensive nations, we actually purge all happenings (moves, issues, posts, etc) so players don't have to look at remnants of that sort of nonsense.

right. the use case in question is a manual recruitment discord bot i'm working on, which as a part of its feature set, periodically grabs a list of foundings to add to a backlog that can be worked through at a later date.

this runs into the issue of nations DEATed between the point of collection and point of relaying being impossible to detect without significantly increasing the tool's API overhead by doing a call for each nation and discarding them on a 404 error

my thought was to reduce this by instead pulling a list of CTE'ed nations every time i pull foundings (currently on a 30m timer), and excluding any matches from my backlog, which would reduce the number of calls needed for that filter to #CTEs/100, rounded up. but as you mentioned, DEATs can't be grabbed from the happenings shard.

granted, DEAT'ed nations don't account for a massive proportion of what ends up populating my users' TG forms anyway, so i understand if it's too minor of a request to justify doing something about, but it would be helpful regardless (honestly, an endpoint for explicitly only DEATs would be even more helpful, since it cuts out the noise of normal CTEs from major/minor, but that's even more of a niche long shot i imagine)
||puppetmaster behind the rightful regimes of warzones sandbox, airspace, europe, australia, and africa||
||gremlin||
||oppressed gamer||
||STAND WITH BALD||

User avatar
Refuge Isle
Technical Moderator
 
Posts: 1905
Founded: Dec 14, 2018
Left-wing Utopia

Postby Refuge Isle » Sat Oct 28, 2023 6:46 pm

Devious wrote:this runs into the issue of nations DEATed between the point of collection and point of relaying being impossible to detect without significantly increasing the tool's API overhead by doing a call for each nation and discarding them on a 404 error

my thought was to reduce this by instead pulling a list of CTE'ed nations every time i pull foundings (currently on a 30m timer), and excluding any matches from my backlog, which would reduce the number of calls needed for that filter to #CTEs/100, rounded up. but as you mentioned, DEATs can't be grabbed from the happenings shard.

At that point, you might as well compare your queue against world nations to see if they're still alive. Especially if you're only going to be pulling once every 30 minutes.

User avatar
Epithemia
Secretary
 
Posts: 26
Founded: Apr 15, 2023
Iron Fist Consumerists

Postby Epithemia » Sun Dec 03, 2023 12:30 am

Seeing some google apps scripts previously posted here that I found useful, I'd like to share the google apps script I just put together for my region to help monitor compliance with our endorsement cap.

Code: Select all
// Code by Epithemia

var api_version = 12;

function update() {
  getEmperorEndorsers();
  getCarcassonneOfficers();
  getCarcassonneEndorsements();
  // TODO getCitizens();
}

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Script Menu').addItem("Update Data",'update');
}

function getCarcassonneEndorsements() {
  getRegionEndorsements("WA Nations","carcassonne",1,1,2);
}

function getCarcassonneOfficers() {
  getRegionOfficers("Officers","carcassonne",1);
}

function getEmperorEndorsers() {
  getNationEndorsers("Endorsers","ysengrim",1);
}

String.prototype.addQuery = function (obj) {
  return this + "?" + Object.entries(obj).flatMap(([k, v]) => Array.isArray(v) ? v.map(e => `${k}=${encodeURIComponent(e)}`) : `${k}=${encodeURIComponent(v)}`).join("&");
}

var last_api_request = 0;
function getApiXml(params) {
  var t = new Date();
  params.v = api_version;
  params.gdoc = SpreadsheetApp.getActiveSpreadsheet().getId();
  params.useremail = Session.getActiveUser().getEmail();

 
  Utilities.sleep(Math.max(601+last_api_request-t,0));
  var response = UrlFetchApp.fetch("http://www.nationstates.net/cgi-bin/api.cgi".addQuery(params));
  last_api_request = new Date().valueOf();
  return XmlService.parse(response);
}

// arguments:
//   sheetname: name of sheet to update
//   region: name of region to query
//   limit: lowest endorsement count to care about
//   nation_col: column # of nation names
//   ans_col: column # to put result in
function getRegionEndorsements(sheetname,regionname,limit,nation_col,ans_col) {
  var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetname);
  var wa_nations = [];
  var start = 1;
  api_loop:
  while(true) {
    try {
      var xml = getApiXml({region, q: 'censusranks', scale: 66, start });
      var nations_xml = xml.getRootElement().getChild('CENSUSRANKS').getChild('NATIONS').getChildren();
      for (nation_xml of nations_xml) {
        var name = nation_xml.getChild('NAME').getText();
        var endos = nation_xml.getChild('SCORE').getText();
        if ( endos < limit ) {
          break api_loop;
        }
        wa_nations.push({name, endos: endos});
        Logger.log('nationname '+ name + ', endos '+endos);
      }
      start += 20;
    } catch ( err ) {
      Logger.log("Error: "+ err);
      return;
    }
  }
  sheet.getRange(2,nation_col,wa_nations.length,1).setValues(wa_nations.map(({name})=> ([name])));
  sheet.getRange(2,ans_col,wa_nations.length,1).setValues(wa_nations.map(({endos})=> ([endos])));
}

// arguments:
//   sheetname: name of sheet to update
//   region: name of region to query
//   nation_col: column # of nation names
//   ans_col: column # to put office name in (optional)
function getRegionOfficers(sheetname,region,nation_col,ans_col) {
  var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetname);
  var officer_nations = [];
  try {
    var xml = getApiXml({region, q: 'officers'});
    var nations_xml = xml.getRootElement().getChild('OFFICERS').getChildren();
    for (nation_xml of nations_xml) {
      var name = nation_xml.getChild('NATION').getText();
      var office = nation_xml.getChild('OFFICE').getText();
      officer_nations.push({name, office})
      Logger.log('nationname '+ name + ', office '+office);
    }
  } catch ( err ) {
    Logger.log("Error: "+ err);
    return;
  }
  sheet.getRange(2,nation_col,officer_nations.length,1).setValues(officer_nations.map(({name})=>([name])));
  if( ans_col ) {
    sheet.getRange(2,ans_col,officer_nations.length,1).setValues(officer_nations.map(({office})=>([office])));
  }
}

// arguments:
//   sheetname: name of sheet to update
//   nation: name of nation to query
//   nation_col: column # of endorser nation names
function getNationEndorsers(sheetname, nation, nation_col) {
  var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetname);
  var endorser_nations = [];
  try {
    var xml = getApiXml({nation, q: 'endorsements'});
    endorser_nations = xml.getRootElement().getChild('ENDORSEMENTS').getText().split(',');
  } catch ( err ) {
    Logger.log("Error: "+ err);
    return;
  }
  Logger.log('endorser_nations '+endorser_nations);
  sheet.getRange(2,nation_col,endorser_nations.length,1).setValues(endorser_nations.map((name)=>([name])));
}

User avatar
Orioni 2
Envoy
 
Posts: 289
Founded: May 05, 2004
Scandinavian Liberal Paradise

RSS feed for regional RMB

Postby Orioni 2 » Fri Jan 12, 2024 5:33 am

Good afternoon. After ploughing through the 96 pages in this topic, as well as several other topics on RSS feeds (mostly raider-related), I think the following question hasn't been asked before.

I'm building a Discord integration that pulls RMB events and publishes them in a #nationstates-stream. The RMB of my region, Eurth, isn't too active. So I presumed getting the RSS feed from the region would be possible.

Right now, I have it working with my own personal RSS feed.

Code: Select all
https://www.nationstates.net/cgi-bin/rss.cgi?view=region.eurth;q=happenings;filter=rmb;nation=orioni_2


The NS API documentation explains how to get regional data, but doesn't output an RSS feed. Attempting to create on, creates the error “Nation name missing”. Re-adding a nation name just outputs what I already have.

Code: Select all
https://www.nationstates.net/cgi-bin/rss.cgi?view=region.eurth;q=happenings;filter=rmb


Is there another way to do this?
Last edited by Orioni 2 on Tue Jan 19, 2038 03:14 am, edited 1.618 times in total.


The Beautiful Empire of OrioniEurth RP
Seek nothing and you will find everything

User avatar
Roavin
Admin
 
Posts: 1778
Founded: Apr 07, 2016
Democratic Socialists

Postby Roavin » Mon Jan 15, 2024 10:40 am

We don't currently have an RSS feed for regions. However, if you're writing code anyway, you can easily poll https://www.nationstates.net/cgi-bin/api.cgi?region=eurth&q=messages at regular intervals.
Helpful Resources: One Stop Rules Shop | API documentation | NS Coders Discord
About me: Longest serving Prime Minister in TSP | Former First Warden of TGW | aka Curious Observations

Feel free to TG me, but not about moderation matters.

User avatar
Refuge Isle
Technical Moderator
 
Posts: 1905
Founded: Dec 14, 2018
Left-wing Utopia

Postby Refuge Isle » Mon Jan 15, 2024 5:00 pm

The standard nation API call appears to occasionally deliver a different response than a call to the motto shard, specifically, when it comes to certain special characters:

https://www.nationstates.net/cgi-bin/ap ... opireistan
> It's pronounced /'apôrt-is-tō-pirī-stan/.

https://www.nationstates.net/cgi-bin/ap ... an&q=motto
> It's pronounced /'apôrt-is-t&#333;-pir&#299;-stan/.

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Alt Capitalist Britain, Fauxia, New Cathen

Advertisement

Remove ads