Authenticate Your API Requests

Authenticate the Blockdaemon API Suite with your API key.

To use the Blockdaemon API Suite, you must authenticate your requests with your API key. Here's how to do it.

1. Getting an API Key

You need to get an API key to start using the Blockdaemon API Suite. 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 authenticate your requests.

Need a Free API key?

Enjoy Rapid, Scalable, Multi-Protocol Blockchain Access with our APIs.

2. New vs. Legacy API Keys

There are two types of Blockdaemon API Suite keys: new and legacy. If you created your key after August 2022, you have a new key. If you made your key before September 2022 or are an Enterprise tier user, you have a legacy key. The difference between these two types of keys is in the base URL and the available authentication methods.

2.1. Authenticating With a New API Key

The following authorization methods are available for new API keys:

  • Using API Key as a Query Parameter
  • Using API Key as a Bearer Token
  • Using API Key as an X-API-Key

If you have a new API key, you should use this base URL: https://svc.blockdaemon.com

2.2. Authenticating With a Legacy API Key

The following authorization methods are available for legacy API keys:

  • Using API Key as a Query Parameter
  • Using API Key as a Bearer Token

If you have a legacy API key, use this base URL: https://ubiquity.api.blockdaemon.com.

📘

Info:

Only legacy and Enterprise tier Blockdaemon API Suite users will use the above URL.

3. Using Your API Key

Once you have your API key, you can authenticate your requests. Overall, three different methods exist to authenticate Blockdaemon API Suite requests, depending on whether you have a new or legacy API key. Let's have a look at each below.

3.1. Using Your API Key as a Query Parameter

The easiest way to authenticate a Blockdaemon API Suite request is via a special query parameter:

  • parameter: apiKey
  • value: YOUR_API_KEY

At the end of any Blockdaemon API Suite endpoint, add the following: ?apiKey=YOUR_API_KEY. For example, to authorize a request for getting the current block number in Ethereum Mainnet using Blockdaemon REST API, use the following GET request:

https://svc.blockdaemon.com/universal/v1/ethereum/mainnet/sync/block_number?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 &.

3.2. Using Your API Key as a Bearer Token

In the authorization header, you can authenticate Blockdaemon API Suite requests by setting YOUR_API_KEY as a bearer token. 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 block number in Ethereum Mainnet using Blockdaemon REST API, use this:

curl --request GET 'https://svc.blockdaemon.com/universal/v1/ethereum/mainnet/sync/block_number' \
     --header 'Authorization: Bearer YOUR_API_KEY'

Or, if you prefer to use short options, run the following:

curl -X GET 'https://svc.blockdaemon.com/universal/v1/ethereum/mainnet/sync/block_number' \
     -H 'Authorization: Bearer YOUR_API_KEY'

➡️ Bearer Token in Postman

In Postman, you can set YOUR_API_KEY as a bearer token for a particular request and a collection of requests. To do this, go to a request or collection tab and do the following:

  1. Navigate to the Authorization or Auth tab.
  2. Select Bearer Token from the Type drop-down menu.
  3. Paste YOUR_API_KEY into the Token input box.

Then you can run your request.

3.3. Using Your API Key as an X-API-Key

You can authenticate Blockdaemon 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 block number in Ethereum Mainnet using Blockdaemon REST API, use this:

curl --request GET 'https://svc.blockdaemon.com/universal/v1/ethereum/mainnet/sync/block_number' \
--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/universal/v1/ethereum/mainnet/sync/block_number' \
-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:

  1. Navigate to the Authorization or Auth tab.
  2. Select API Key from the Type drop-down menu.
  3. Paste your YOUR_API_KEY into the Value input box.
  4. Ensure the Add to option is set to Header.

Then you can run your request.

3.4. Using Your API Key to Send a Request via API Reference Docs

Follow the steps below to access the Blockdaemon API Suite via the API reference docs:

  1. Navigate to the specific endpoint page within the API reference docs.
  1. Paste your API key in the Authentication field as the Bearer token or in the Header.
  1. Select your relevant Base URL if it is not already set up.
  1. Add relevant path or query parameters.
  1. Click the 'Try it' button on the API explorer.
  1. Receive your response.

👋 Need Help?

Contact us through email or our support page for any issues, bugs, or assistance you may need.