Page 96 of 97

PostPosted: Wed Jul 26, 2023 2:19 pm
by United Calanworie
Not at this time, unless my colleagues have one and haven't shared it.

PostPosted: Wed Jul 26, 2023 2:27 pm
by Improper Classifications
OK, thank you.

PostPosted: Wed Aug 02, 2023 11:26 pm
by The Ice States
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.

PostPosted: Wed Aug 02, 2023 11:28 pm
by United Calanworie
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.

PostPosted: Thu Aug 03, 2023 7:05 am
by Ever-Wandering Souls
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.

PostPosted: Sat Aug 05, 2023 10:21 am
by Grishahakkaverchynot
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?

PostPosted: Sat Aug 05, 2023 10:36 am
by United Calanworie
Could you expand more on that, please?

PostPosted: Sun Aug 06, 2023 7:18 pm
by Vleerian
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.

PostPosted: Sat Aug 12, 2023 9:37 am
by Vleerian
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.

PostPosted: Mon Aug 21, 2023 4:20 pm
by Eluvatar
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?

PostPosted: Mon Aug 21, 2023 9:46 pm
by Improper Classifications
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.

PostPosted: Fri Aug 25, 2023 9:12 am
by 9003
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.

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

PostPosted: Fri Sep 29, 2023 9:31 am
by 9003
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.

PostPosted: Fri Sep 29, 2023 12:06 pm
by Eluvatar
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.

PostPosted: Fri Sep 29, 2023 4:58 pm
by 9003
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*

PostPosted: Sun Oct 22, 2023 7:35 am
by United States of Dictators
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.

PostPosted: Sun Oct 22, 2023 7:53 pm
by The Ice States
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.

PostPosted: Fri Oct 27, 2023 3:37 pm
by Devious
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.

PostPosted: Fri Oct 27, 2023 6:48 pm
by Frisbeeteria
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.

PostPosted: Fri Oct 27, 2023 8:37 pm
by Devious
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)

PostPosted: Sat Oct 28, 2023 6:46 pm
by Refuge Isle
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.

PostPosted: Sun Dec 03, 2023 12:30 am
by Epithemia
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])));
}

RSS feed for regional RMB

PostPosted: Fri Jan 12, 2024 5:33 am
by Orioni 2
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?

PostPosted: Mon Jan 15, 2024 10:40 am
by Roavin
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.

PostPosted: Mon Jan 15, 2024 5:00 pm
by Refuge Isle
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/.