> ## Documentation Index
> Fetch the complete documentation index at: https://docs.uniblock.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticate Uniblock API requests with your API key

> Authenticate requests to the Uniblock Unified API by adding your project API key in the X-API-Key header from cURL, JavaScript, Python, and more.

# How to authenticate your Uniblock API key

Every request to the Uniblock API must include your project API key in the request header. The key identifies your project, tracks usage, and gates access to the endpoints your plan supports.

## Steps

1. **Obtain your API key:** Navigate to your [Uniblock dashboard](https://dashboard.uniblock.dev), open your project, and copy the API key shown on the Overview page.

2. **Include the key in every request:** Add an `X-API-Key` header to each HTTP request you make to the Uniblock API.

<CodeGroup>
  ```bash cURL theme={null}
  curl --location \
  'https://api.uniblock.dev/uni/v1/nft/balance?chainId=1&walletAddress=0x...' \
  --header 'X-API-Key: YOUR_UNIBLOCK_API_KEY'
  ```

  ```javascript JavaScript theme={null}
  const options = {
    method: 'GET',
    headers: {
      accept: 'application/json',
      'X-API-Key': 'YOUR_UNIBLOCK_API_KEY'
    }
  };

  fetch('https://api.uniblock.dev/uni/v1/nft/balance?chainId=1&walletAddress=0x...', options)
    .then(res => res.json())
    .then(console.log);
  ```
</CodeGroup>

3. **Test in the API Tester:** Open the [Uniblock Explorer](https://explorer.uniblock.dev), click **Authorize**, paste your API key, and click **Authorize** again. Every endpoint in the explorer will now send requests authenticated as your project.

4. **Start calling endpoints:** With your key in place, you're ready to call any Unified API endpoint your plan supports. Usage and analytics for all authenticated calls appear in your project dashboard under **Endpoints → Analytics**.

<Info>
  If you switch projects in the dashboard, update the API key in your code to match the new project, since each project has its own key and its own usage metrics.
</Info>

## Header-only authentication for HTTP endpoints

Uniblock HTTP endpoints accept the API key only in the `X-API-Key` header. This applies to the Unified API, the Unified JSON-RPC endpoint (`https://api.uniblock.dev/uni/v1/json-rpc`), and Direct API endpoints.

There is no URL format that embeds the API key in the path or as a query parameter. If you are migrating from a provider that uses key-in-URL endpoints, keep the URL key-free and move the key into the `X-API-Key` header:

```bash theme={null}
# Not supported: key embedded in the URL
# https://api.uniblock.dev/uni/v1/json-rpc/YOUR_UNIBLOCK_API_KEY

# Supported: key in the X-API-Key header
curl --request POST \
  --url 'https://api.uniblock.dev/uni/v1/json-rpc?chainId=1' \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: YOUR_UNIBLOCK_API_KEY' \
  --data '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}'
```

WebSocket connections are the exception. Most WebSocket endpoints also use the `X-API-KEY` header, but some provider-specific endpoints accept an `apiKey` query parameter instead. See [Authenticating Uniblock WebSocket connections](/reference/websockets/authentication).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.