HomeGuidesAPI ReferenceChangelog
GuidesAPI ReferenceCommunityDiscordBlogFAQBug BountyAnnouncementsChange Log
API Reference

Introduction

Select network

📘

Note:

Currently using Trongrid to request the Shasta/Nile testnet does not need to set an API Key.

What are API Keys

TronGrid provides all full-node HTTP APIs and extended APIs of the TRON network. In order to ensure reasonable allocation of requested resources, all request APIs need to carry the parameter API Key, and requests without API Keys will not be responded to.

How to get an API Key

After logging in Trongrid, users can quickly create API Keys on the Dashboard or API Key list. Each API Key has its separate configuration page, and users can configure API Keys to meet different needs.

How to use API Keys

At present, an API Key is used by adding the parameter TRON_PRO_API_KEY=API Key to the header of the request.

HTTP Examples:

curl -X POST \
  https://api.trongrid.io/wallet/createtransaction \
  -H 'Content-Type: application/json' \
  -H 'TRON-PRO-API-KEY: 25f66928-0b70-48cd-9ac6-da6f8247c663' \
  -d '{
    "to_address": "41e9d79cc47518930bc322d9bf7cddd260a0260a8d",
    "owner_address": "41D1E7A6BC354106CB410E65FF8B181C600FF14292",
    "amount": 1000
}'
import requests

url = "https://api.trongrid.io/wallet/createtransaction"

payload = "{\n    \"to_address\": \"41e9d79cc47518930bc322d9bf7cddd260a0260a8d\",\n    \"owner_address\": \"41D1E7A6BC354106CB410E65FF8B181C600FF14292\",\n    \"amount\": 1000\n}"
headers = {
    'Content-Type': "application/json",
    'TRON-PRO-API-KEY': "25f66928-0b70-48cd-9ac6-da6f8247c663"
    }
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
var request = require("request");

var options = { method: 'POST',
  url: 'https://api.trongrid.io/wallet/createtransaction',
  headers: {  
     'TRON-PRO-API-KEY': '25f66928-0b70-48cd-9ac6-da6f8247c663',
     'Content-Type': 'application/json' 
},
  body: { 
      to_address: '41e9d79cc47518930bc322d9bf7cddd260a0260a8d',
     owner_address: '41D1E7A6BC354106CB410E65FF8B181C600FF14292',
     amount: 1000 
},
  json: true 
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

GRPC Examples:

import io.grpc.Metadata;
import io.grpc.stub.MetadataUtils;

// add these new codes: create a custom header
Metadata header=new Metadata();
Metadata.Key<String> key =
    Metadata.Key.of(“TRON-PRO-API-KEY”, Metadata.ASCII_STRING_MARSHALLER);
header.put(key, “25f66928-0b70-48cd-9ac6-da6f8247c663");

// create client stub
ServiceGrpc.ServiceBlockingStub stub = ServiceGrpc.newBlockingStub(channel);

// add this new line to attach header
stub = MetadataUtils.attachHeaders(stub, header);

public Block getNowBlock() {
    return stub.getNowBlock(EmptyMessage.newBuilder().build());
}