# Make a REST API request with your API keys

Source URL: https://helpcenter.dxp-frontend.devserver.app/blockstream-explorer-api/use-explorer-api/make-a-rest-api-request-with-your-api-keys
Updated: 2026-04-09T09:35:49.000Z
Category: Blockstream Explorer API
Section: Use Explorer API

---

A **Representational State Transfer** (**REST) API request** allows you to ask a server for specific information (such as Bitcoin transaction data from [Blockstream Explorer](https://blockstream.info/)) or tell it to perform an action (e.g. submitting data).

1. To get started, navigate to the **Manage Keys** page and copy the _client\_id_ and _client\_secret_ values from one of your active API keys.

![Blockstream Explorer API Manage Keys page](https://storage.googleapis.com/blockstream_dev_tmp/content/blockstream-explorer-api/use-explorer-api/make-a-rest-api-request-with-your-api-keys/52415086085785.png)

1. In order to make [REST API](https://glossary.blockstream.com/rest-api/) requests to the Blockstream Explorer Enterprise endpoints, you first need to request an access token using your client\_id and client\_secret to this endpoint: _https://login.blockstream.com/realms/blockstream-public/protocol/openid-connect/token_

**Note:** The access token is the value of the _access\_token_ key in the JSON object returned from the token endpoint.

1. Here’s a cURL example on how to obtain an access token using your _client\_id_ and _client\_secret:_

_**REQUEST:**_

Shell

```
CLIENT_ID=MY_CLIENT_ID
CLIENT_SECRET=MY_CLIENT_SECRET

curl --location \
  --request POST 
"https://login.blockstream.com/realms/blockstream-public/protocol/openid-connect/token" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "client_id=${CLIENT_ID}" \
  --data-urlencode "client_secret=${CLIENT_SECRET}" \
  --data-urlencode "grant_type=client_credentials" \
  --data-urlencode "scope=openid"
  
```

_**RESPONSE:**_

JSON

```
{
  "access_token": "",
  "expires_in": 300,
  "refresh_expires_in": 0,
  "token_type": "Bearer",
  "id_token": "",
  "not-before-policy": 0,
  "scope": "openid token-portal email"
}
  
```

1. Here’s a Python example on how to obtain an access token using your _client\_id_ and _client\_secret:_

_**REQUEST:**_

Python

```
import requests

url = 'https://login.blockstream.com/realms/blockstream-public/protocol/openid-connect/token'

CLIENT_ID='MY_CLIENT_ID'
CLIENT_SECRET='MY_CLIENT_SECRET'

payload = {
    'client_id': CLIENT_ID,
    'client_secret': CLIENT_SECRET,
    'grant_type': 'client_credentials',
    'scope': 'openid'
}

headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
}

response = requests.post(url, data=payload, headers=headers)

print(response.json())
  
```

_**RESPONSE:**_

JSON

```
{
  "access_token": "",
  "expires_in": 300,
  "refresh_expires_in": 0,
  "token_type": "Bearer",
  "id_token": "",
  "not-before-policy": 0,
  "scope": "openid token-portal email"
}
  
```

Keep in mind that these access tokens expire after 300 seconds (5 min), so you will have to refresh them periodically.

Now you can use the value of the _access\_token_ key in the JSON object returned from the token endpoint in your REST API request to the Explorer Enterprise endpoints. 

- Explorer Enterprise API base endpoints:
  - **Bitcoin mainnet:** https://enterprise.blockstream.info/api
  - **Bitcoin testnet:** https://enterprise.blockstream.info/testnet/api
  - **Liquid mainnet:** https://enterprise.blockstream.info/liquid/api
  - **Liquid testnet:** https://enterprise.blockstream.info/liquidtestnet/api
1. Here’s a cURL example on how to get the hash of the last Bitcoin mainnet block:

_**REQUEST:**_

Shell

```
ACCESS_TOKEN=MY_ACCESS_TOKEN

curl \
  --request GET \
  --location "https://enterprise.blockstream.info/api/blocks/tip/hash" \
  --header "Authorization: Bearer ${ACCESS_TOKEN}"
  
```

_**RESPONSE:**_

JSON

```
<block_hash>
  
```

1. Here’s a Python example on how to get the hash of the last Bitcoin mainnet block:

_**REQUEST:**_

Python

```
import requests

url = "https://enterprise.blockstream.info/api/blocks/tip/hash"
access_token = "your_access_token"

headers = {
    "Authorization": f"Bearer {access_token}"
}

response = requests.get(url, headers=headers)

print(response.text)  # Use response.json() if it’s JSON
  
```

_**RESPONSE:**_

JSON

```
<block_hash>
  
```

1. At the bottom of the **Manage Keys** page and on the left-side navigation bar, you will see **Code Examples**_._ This page shows you code snippets (cURL, python, Javascript) on how to request access tokens using your _client\_id_ and _client\_secret_ and how to make a request to get the Explorer Enterprise endpoints.
1. In the **Manage Keys**page, you will also see a **Technical Docs** button that shows the [full list of available REST API endpoints](https://github.com/Blockstream/esplora/blob/master/API.md).

![Blockstream Explorer API Code Examples page](https://storage.googleapis.com/blockstream_dev_tmp/content/blockstream-explorer-api/use-explorer-api/make-a-rest-api-request-with-your-api-keys/52415084406297.png)

Navigation: Blockstream Help Center > Blockstream Explorer API > Make a REST API request with your API keys

## Related Articles in This Section
- [Make a REST API request with your API keys](https://helpcenter.dxp-frontend.devserver.app/blockstream-explorer-api/use-explorer-api/make-a-rest-api-request-with-your-api-keys) (current)
- [Check your API usage](https://helpcenter.dxp-frontend.devserver.app/blockstream-explorer-api/use-explorer-api/check-your-api-usage)
- [Request an enterprise deployment](https://helpcenter.dxp-frontend.devserver.app/blockstream-explorer-api/use-explorer-api/request-an-enterprise-deployment)
- [Request support for Explorer API](https://helpcenter.dxp-frontend.devserver.app/blockstream-explorer-api/use-explorer-api/request-support-for-explorer-api)
