ESI for Citadel orders in Google Sheets

I’ve created with the help of fuzzyworks, GESI, and a bunch of research a google spreadsheet that will get all necessary information and tokens to access a citadel’s market information and get it pasted in a Google Sheet. Information coming from the pull is close to actual pricing but isn’t correct. I’m also only getting 1000 rows of data. How can I pull all the data for all sell orders on the market in a given citadel so that I can sort it?

ESI results are paged, with 1000 results per page. There’s a header on the response that tells you how many pages there are. So grab the first page, read the number of pages, then send a request for each page.

=markets_structures_structure(structure_id, “GESI authed character name”, -1)

I’m not sure where the header you’re referring to would show. Below is part of the script I’m using. Is there another way I would see the header or the number of pages?

function getCitadel(citadelid) {

var config=getSetup();

config=getAccessToken(config);

var url = ‘https://esi.evetech.net/dev/markets/structures/’+citadelid+’/’;

var parameters = {method : “get”, headers : {‘Authorization’:'Bearer '+ config.access_token}, muteHttpExceptions: true,};

var jsonFeed = UrlFetchApp.fetch(url, parameters).getContentText();
var json = JSON.parse(jsonFeed);
var prices=;
prices.push([‘buy’,‘price’,‘typeid’])
if(json) {
for(i in json) {
var price=[json[i].is_buy_order,
json[i].price,
json[i].type_id,
];
prices.push(price);
}
}
return prices;

The response to your request (jsonFeed in your code, I believe) comes wrapped in an HTTP header. In that header is a value named “x-pages”, which is the total number of pages your request requires.

So do a one-page request. Parse the HTTP response header for the “x-pages” value, then do a loop to send a request for each page.

You can see what’s in the response header by looking at the headers section of the Eve ESI spec for structure orders:
https://esi.evetech.net/latest/#!/Market/get_markets_structures_structure_id

I use PHP, and CURL to make my requests. FWIW, here’s the function I use to parse the response and get the page count. It grabs the headers, then loops through them looking for the “x-pages” value.

function get_page_count_from_curl_response($response) {
	
    $header_text = substr($response, 0, strpos($response, "\r\n\r\n"));

    foreach (explode("\r\n", $header_text) as $i => $line) {
       list ($key, $value) = explode(': ', $line);
		if(strtolower($key) === "x-pages") {
			$headers = $value;
		}
     }
    return $headers;
}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.