• Register

How to make a request

Retrieve an Access Token

Please refer to the following examples in order to send a POST for retrieving an Access Token.

JavaScript - Fetch

        var myHeaders = new Headers();
        myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
        
        var urlencoded = new URLSearchParams();
        urlencoded.append("grant_type", "client_credentials");
        urlencoded.append("client_id", "your_API_Key");
        urlencoded.append("client_secret", "your_API_Secret");
        
        var requestOptions = {
          method: 'POST',
          headers: myHeaders,
          body: urlencoded,
          redirect: 'follow'
        };
        
        fetch("https://api.terna.it/public-api/access-token", requestOptions)
          .then(response => response.text())
          .then(result => console.log(result))
          .catch(error => console.log('error', error));
    

Calling our APIs

JavaScript - Fetch

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer n3fujtnubkgx48rhvcf7yxz7");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://api.terna.it/transparency/v1.0/gettotalload?dateFrom=10/05/2022&dateTo=11/05/2022", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));