Skip To Content

Blockdaemon Documentation

Authentication

Overview
Generating a Ubiquity API Key
Authentication via a Query Parameter
Authentication via a Bearer Token
Getting the Result


Overview

This article explains how generate a Ubiquity API key and use it to authenticate Ubiquity API requests.

You can pass the key either as a query parameter or as a bearer token in the authorization header. Below you will find examples showing how to set the bearer token in cURL and Postman.


Generating a Ubiquity API Key

To use the Ubiquity API, you need to get the API access key. This is a 47-character unique number.

To generate a Ubiquity API key, sign up to the Blockdaemon application and take the following steps:

  1. Navigate to the Ubiquity API section
  2. Click on Start using the Blockdaemon API
  3. In the pop-up window, enter your desired Key Name
  4. Click on the Create API Key button to generate the key
  5. Click on your key to copy it

Existing Blockdaemon API key holders:

  • Navigate to Ubiquity API > Configure
  • Click on Create New Key
  • Take steps 3–5 above

Check out Keke’s video guide on creating your Ubiquity API Key

Please Note

  • If you lose the key, you will not be able to retrieve it
  • You should immediately store your key in a secure place

Authentication via a Query Parameter

The easiest way to authenticate a Ubiquity request is via a special query parameter:

  • parameter: apiKey
  • value: your API key

At the end of any Ubiquity endpoint, just add the following: ?apiKey=YOUR_TOKEN

For example, to authorize a request for getting the current block number in Ethereum Mainnet, use the following code:


https://ubiquity.api.blockdaemon.com/v1/ethereum/mainnet/sync/block_number?apiKey=YOUR_TOKEN

Notes

  • If the query has other parameters, replace ? with &
  • This authentication method can be used with any tool, no additional actions needed

Authentication via a Bearer Token

You can authenticate Ubiquity API requests by setting your API key as a bearer token in the authorization header. Below you will find examples showing how to do it when using cURL and Postman.

Bearer Token in cURL

When working with cURL, use the following code to set your API key as a bearer token:

--header 'Authorization: Bearer YOUR_TOKEN'

For example, to get the current block number in Ethereum Mainnet, run this code:


curl --request GET 'https://stg.ubiquity.api.blockdaemon.com/v1/ethereum/mainnet/sync/block_number' --header 'Authorization: Bearer YOUR_TOKEN'

If you prefer to use short options, run the following:


curl -X GET 'https://stg.ubiquity.api.blockdaemon.com/v1/ethereum/mainnet/sync/block_number' -H 'Authorization: Bearer YOUR_TOKEN'

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.

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. For example, to get the current block number in Ethereum Mainnet, use the following:

https://ubiquity.api.blockdaemon.com/v1/ethereum/mainnet/sync/block_number

Getting the Result

If the API key is correct, your request will be authorized, and you will get the result.

The requests from the sections above return the current block number in Ethereum Mainnet, for example:

14589247

If the key is incorrect or missing, you will get the following error:

{
    "status": 401,
    "type": "unauthorized",
    "title": "Invalid Token"
}

We don't support Internet Explorer

Please use Chrome, Safari, Firefox, or Edge to view this site.