Links

API Keys

What is API Key?

API Key is an authentication mechanism used to protect the TRONSCAN API service from unauthorized access. It is a unique string generated by the system, assigned to each user for authentication during API calling. Users need to include the API Key in the header of their requests to authenticate their identity.

Why does TRONSCAN need API Key?

API Key is a security mechanism that ensures only authenticated users can access our API service, protecting the system from malicious attacks and abuse.

Get an API Key

In the system, each user can obtain unique API Keys for authentication when calling the TRONSCAN API service. Users can obtain an API Key by following these steps:
1. Log in to the system and go to the API Keys page.
2. Click the "Add" button to enter the editing page. Enter your application name and security options. Then, the system will generate a unique API Key for you.
3. Copy the generated API Key token to your application to authenticate your identity when calling the TRONSCAN API service.

How to use your API Key?

In your application, you need to add the API Key to the header of your requests for authentication. The method used to add the API Key to the header is as follow:
curl
java
go
javascript
curl -H 'TRON-PRO-API-KEY:your_api_key' 'https://apilist.tronscanapi.com/api/block'
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class TronscanAPIDemo {
public static void main(String[] args) {
String apiKey = "your_api_key";
String endpoint = "https://apilist.tronscanapi.com/api/block";
try {
HttpClient client = HttpClients.createDefault();
HttpGet request = new HttpGet(endpoint);
request.addHeader("TRON-PRO-API-KEY", apiKey);
BufferedReader reader = new BufferedReader(new InputStreamReader(client.execute(request).getEntity().getContent()));
StringBuilder responseBody = new StringBuilder();
String line;
while ((line = reader.readLine()) != null)
responseBody.append(line);
reader.close();
System.out.println(responseBody.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
apiKey := "your_api_key"
endpoint := "https://apilist.tronscanapi.com/api/block"
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("TRON-PRO-API-KEY", apiKey)
client := http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
const fetch = require('node-fetch');
const apiKey = 'your_api_key';
const endpoint = 'https://apilist.tronscanapi.com/api/block';
fetch(endpoint, {
headers: {
'TRON-PRO-API-KEY': apiKey
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Please replace “your_api_key” with your API Key.
If your request does not include the correct API Key, TRONSCAN will limit the rate of your request to protect the API service from abuse.

Notes

1. Do not disclose your API Key to anyone to prevent malicious use.
2. If your API Key is lost or leaked, you can delete your key on the “API Keys” page and generate a new one. If you are unable to operate your key, please contact our customer service immediately. We will invalidate the lost API Key and generate a new one for you.
3. If you need more help or encounter any problem, please click here to contact us. On the page that appears, click "API Related" and describe your problem. Our support team will respond to your ticket as soon as possible.
Last modified 7d ago