Learn how to authenticate your Staking Reporting API requests.
If you want to use the Staking Reporting API, you need to authenticate your requests with your Blockdeamon API SuiteAPI key. Here's how to do it.
Getting an API Key
To start using the Blockdeamon API Suite, you need to get an API key. If you don't have one, you can get a free one by signing up for Blockdaemon. Once you have an API key, you can use it to authenticate your requests.
Need a Free API key?
Enjoy Rapid, Scalable, Multi-Protocol Blockchain Access with Ubiquity.
Using Your API Key
Once you have your API key, you can use it to authenticate your requests. Overall, there are three different methods to authenticate Blockdeamon API Suite API requests, depending on whether you have a new or legacy API key. Let's have a look at each below.
1. Using Your API Key as a Query Parameter
The easiest way to authenticate a Blockdeamon API Suite request is via a special query parameter:
- parameter:
apiKey
- value: YOUR_API_KEY
At the end of any Blockdeamon API Suite endpoint, just add the following: ?apiKey=YOUR_API_KEY
. For example, to get the current status by a user-defined nominator address for Polkadot using our Staking Reporting API, use the following GET request:
https://svc.blockdaemon.com/reporting/staking/v1/polkadot/mainnet/nominator/status/{address}?apiKey=YOUR_API_KEY
Authentication with a query parameter can be used with any tool - no additional actions are needed.
Info:
Note that if the query has additional parameters, replace
?
with&
.
2. Using Your API Key as a Bearer Token
You can authenticate Blockdeamon API Suite API requests by setting YOUR_API_KEY as a bearer token in the authorization header. Here are the instructions for doing this in cURL and Postman.
Bearer Token in cURL
When working with cURL, use the following code to set your YOUR_API_KEY as a bearer token:
--header 'Authorization: Bearer YOUR_API_KEY'
For example, to get the current status by a user-defined nominator address for Polkadot using our Staking Reporting API, use the following code:
curl --request GET 'https://svc.blockdaemon.com/reporting/staking/v1/polkadot/mainnet/nominator/status/{address}' \
--header 'Authorization: Bearer YOUR_API_KEY'
Or, if you prefer to use short options, run the following:
curl -X GET 'https://svc.blockdaemon.com/reporting/staking/v1/polkadot/mainnet/nominator/status/{address}' \
-H 'Authorization: Bearer YOUR_API_KEY'
Bearer Token in Postman
In Postman, you can set YOUR_API_KEY as a bearer token not only for a particular request but also for a collection of requests. To do this, go to a request or collection tab and do the following:
- Navigate to the Authorization or Auth tab.
- Select Bearer Token from the Type drop-down menu.
- Paste YOUR_API_KEY into the Token input box.
Then you can run your request.
3. Using Your API Key as an X-API-Key
You can authenticate Blockdeamon API Suite requests by passing your YOUR_API_KEY in the X-API-Key header. Here are the instructions for doing this in cURL and Postman.
X-API-Key in cURL
When working with cURL, use the following code to set YOUR_API_KEY as a bearer token:
--header 'X-API-Key: YOUR_API_KEY'
For example, to get the current status by a user-defined nominator address for Polkadot using our Staking Reporting API, use the following cURL request:
curl --request GET 'https://svc.blockdaemon.com/reporting/staking/v1/polkadot/mainnet/nominator/status/{address}' \
--header 'X-API-Key: YOUR_API_KEY'
Or, if you prefer to use short options, run the following:
curl -X GET 'https://svc.blockdaemon.com/reporting/staking/v1/polkadot/mainnet/nominator/status/{address}' \
-H 'X-API-Key: YOUR_API_KEY'
X-API-Key in Postman
In Postman you can set YOUR_API_KEY as an X-API-Key not only for a particular request but also for a collection of requests. Go to a request or collection tab and do the following:
- Navigate to the Authorization or Auth tab.
- Select API Key from the Type drop-down menu.
- Paste your YOUR_API_KEY into the Value input box.
- Make sure that the Add to option is set to Header.
Then you can run your request.
Getting the Result
If YOUR_API_KEY is correct, your request will be authorized, and you will get the result. For example, the requests from the sections above return the current status by a user-defined nominator address for Polkadot.
{
"address": "1FmuvFXSkL988k8NQHeq4HDR43sHo3eEm2BbDhfuSeBs3qi",
"status": "active",
"commission": 1,
"activationDate": "2022-09-23"
}
If the key is incorrect or missing, you will get this error:
{
"status": 401,
"type": "unauthorized",
"title": "Invalid Token"
}