make HTTP request with header and parse json


I am working with an Arduino Mega 2560 and want to make an HTTP request about a CO2 signal. The problem is that the homepage (API Reference) needs an API key (header). I have the key but I have no idea how to use it with the HTTP request. Anyone who knows how to solve it? Afterwards, i want to receive the json data and parse it. Thanks for help!

void APIabfrage() {
HttpClient client;
// Make a HTTP request:
// headers={"auth-token":"xy"}).json;

// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c =;

//static const char* queries = { "carbonIntensity", "price"};
// StreamJsonReader jsonreader(queries, 2); // 2 queries
// while(char c = read()){
// jsonreader.process_char(c);


With shell, you can just pass the correct header with each request

-H "auth-token: myapitoken
(This information from

Have a look at Arduinojson library to help parse the data.


thanks for your answer? but how to implement #header with arduino?

Pasting into a web search shows the information you would get.

I think you should edityour key as anyone could use it.




Perfect, it works!!! Thanks a lot!