Javascript/API problem

Hi all,
I have spent too much time on this, searching and searching and it is not working.
i would like to catch data from https://
When logged I can see maunual API but I can not make it works.

I get information:
Your key: 709a7d013e4fda8f3e21166c33a1a691
curl --header "x-key: 709a7d013e4fda8f3e21166c33a1a691

and listing of API

I want to get into
which is JSON with gas storage information on daily history. Don`t mind that variables already been declared.

I get: error: Uncaught SyntaxError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'x-key:' is not a valid HTTP header field name.

What is proper way to do it?
Many thanks for help

With $

 let urls1="";
 let apiKey = "709a7d013e4fda8f3e21166c33a1a691";
  headers: {"x-key:": apiKey},
  dataType: "json",
  success: function (data) {console.log(data);},
  error: function (msg) { console.log(msg); }
}) ;

And with XMLHttpRequest

let urls1="";
let apiKey = "709a7d013e4fda8f3e21166c33a1a691";
const xhr = new XMLHttpRequest();

xhr.addEventListener("load", function() {
    if (xhr.status === 200) {
        console.log(xhr.response);    }
xhr.addEventListener("error", function() {
    console.log("ERROR",  xhr.readyState, "   ",xhr.status);
});"GET", urls1);

Try just “x-key” without the colon. You may also get a cors error, I added a proxy. BTW, it returns over 3000 results.

jQuery version

let urls1 =
let apiKey = "709a7d013e4fda8f3e21166c33a1a691";
  headers: { "x-key": apiKey },
  url: urls1,
  dataType: "json",
  success: function (data) {
  error: function (msg) {

OMG. Amazing. I think it took me 6 hours seraching and trying. I`m beggining in JS from VBA previously.

The colon is one thing, thanks very much,
but could You explain
https:// cors-anywhere.herokuapp. com/

will it be necessary always when getting any API?

1 Like

I think you have to use the proxy. I’m not sure the API was setup to do what you want. It seems like they want you to curl or open the data in the browser (or download it as an Excel).

1 Like

You are right about EXCEL, they prefer downloading to harddrive, which I did and worked in VBA, but VBA is not very stable, it can stop working. So I downloaded EXCEL then to SQL and then used query in VBA.

Thanks for help.