# ESI for Citadel orders in Google Sheets

**URL:** <https://forums.eveonline.com/t/esi-for-citadel-orders-in-google-sheets/140682>\
**Category:** Science & Industry\
**Created:** [February 17, 2019, 7:00pm UTC](https://forums.eveonline.com/t/esi-for-citadel-orders-in-google-sheets/140682 "2019-02-17T19:00:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esoteric\_Travesty](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/esoteric_travesty/32/134753_2.png) [@Esoteric\_Travesty](https://forums.eveonline.com/u/Esoteric_Travesty)\
**Post date:** [February 17, 2019, 7:00pm UTC](https://forums.eveonline.com/t/esi-for-citadel-orders-in-google-sheets/140682/1 "2019-02-17T19:00:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Piotr\_Leusten](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/piotr_leusten/32/169358_2.png) [@Piotr\_Leusten](https://forums.eveonline.com/u/Piotr_Leusten)\
**Post date:** [February 17, 2019, 7:44pm UTC](https://forums.eveonline.com/t/esi-for-citadel-orders-in-google-sheets/140682/2 "2019-02-17T19:44:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Professor\_JinMine](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/professor_jinmine/32/430079_2.png) [@Professor\_JinMine](https://forums.eveonline.com/u/Professor_JinMine)\
**Post date:** [February 18, 2019, 4:50am UTC](https://forums.eveonline.com/t/esi-for-citadel-orders-in-google-sheets/140682/3 "2019-02-18T04:50:51Z")

</div>

=markets\_structures\_structure(_structure\_id_, “_GESI authed character name_”, **-1** )

---

<div class="post-metadata">

**Author:** ![Esoteric\_Travesty](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/esoteric_travesty/32/134753_2.png) [@Esoteric\_Travesty](https://forums.eveonline.com/u/Esoteric_Travesty)\
**Post date:** [February 18, 2019, 6:16pm UTC](https://forums.eveonline.com/t/esi-for-citadel-orders-in-google-sheets/140682/4 "2019-02-18T18:16:01Z")

</div>

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+’/](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;

---

<div class="post-metadata">

**Author:** ![Piotr\_Leusten](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/piotr_leusten/32/169358_2.png) [@Piotr\_Leusten](https://forums.eveonline.com/u/Piotr_Leusten)\
**Post date:** [February 18, 2019, 7:31pm UTC](https://forums.eveonline.com/t/esi-for-citadel-orders-in-google-sheets/140682/5 "2019-02-18T19:31:25Z")

</div>

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](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;
}
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [May 19, 2019, 7:33pm UTC](https://forums.eveonline.com/t/esi-for-citadel-orders-in-google-sheets/140682/6 "2019-05-19T19:33:27Z")

</div>

Closed on May 19, 2019, 7:33pm UTC

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