Making API Calls
You call the Radix Gateway API by sending a POST HTTP request to the URL of a specific endpoint, with a JSON post body containing the parameters of the request. The response is received in JSON.
To make the API call, you will need to specify a gateway endpoint to make the request to. You can use radix’s gateway https://mainnet.radixdlt.com for exploring these API’s.
If you want dedicated endpoints for your own use or application, we recommend you install and configure your gateway that can offer them. |
A simple API query example
Let’s start with a query to a simple info method on the /token/native
endpoint. This query asks for information about the native token of the Radix network (which of course we expect to be XRD).
We can check the Gateway API Gateway Redocly specification to find the expected JSON input to the /token/native
endpoint. We make the call by including the JSON input in a curl
command (and a little python
to parse the output) as follows:
/token/native
methodcurl -d '{
"network_identifier": {
"network": "mainnet"
}
}' -H 'X-Radixdlt-Target-Gw-Api: 1.0' -H "Content-Type: application/json" -X POST "https://mainnet.radixdlt.com/token/native" | python -m json.tool
In above command, text |
If all goes well, you should receive a response like this:
/token/native
call{
"ledger_state": {
"version": 81045742,
"timestamp": "2022-02-10T13:13:20.332Z",
"epoch": 7293,
"round": 8121
},
"token": {
"token_identifier": {
"rri": "xrd_rr1qy5wfsfh"
},
"token_supply": {
"value": "12167721868383800000000000000",
"token_identifier": {
"rri": "xrd_rr1qy5wfsfh"
}
},
"info": {
"total_minted": {
"value": "12167804733193400000000000000",
"token_identifier": {
"rri": "xrd_rr1qy5wfsfh"
}
},
"total_burned": {
"value": "82864809600000000000000",
"token_identifier": {
"rri": "xrd_rr1qy5wfsfh"
}
}
},
"token_properties": {
"name": "Radix",
"description": "The Radix Public Network's native token, used to pay the network's required transaction fees and to secure the network through staking to its validator nodes.",
"icon_url": "https://assets.radixdlt.com/icons/icon-xrd-32x32.png",
"url": "https://tokens.radixdlt.com",
"symbol": "xrd",
"is_supply_mutable": true,
"granularity": "1"
}
}
}
The result
includes all of the various pieces of metadata you might want to know about XRD, Radix’s native token.
One particularly interesting bit of info is the token.token_identifier.rri
. This is the "radix resource identifier" of the token. All tokens created on Radix have an rri
that you can use with a different API path: /token
.
Let’s use the rri
of the XRD token to try out this api path to see what it’s like to pass this to an API endpoint method:
/token
methodcurl -d '{
"network_identifier": {
"network": "mainnet"
},
"token_identifier": {
"rri": "xrd_rr1qy5wfsfh"
}
}' -H 'X-Radixdlt-Target-Gw-Api: 1.0' -H "Content-Type: application/json" -X POST "https://mainnet.radixdlt.com/token" | python -m json.tool
You should receive a result very similar to the tokens.get_native_token
method – but this one you can use with any token rri
that you find on the Radix network.
Now that you’ve done a simple query, you might want to proceed on to learning how to make transactions using the Node API.