Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions website/src/pages/en/subgraphs/querying/managing-api-keys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ A new window will pop up:

![Create API Key Window](/img/create-api-key.png)

## Using Your API Key

> [!IMPORTANT] Always keep your API key in environment variables or a secure secrets manager. Do not hardcode it in your codebase or expose it in client-side apps.

When you query The Graph from your dapp, you can use your API key in two ways:

1. In the URL (Optimal Method for Subgraph Queries):
Comment thread
idalithb marked this conversation as resolved.
Outdated

Append the API Key directly to your query endpoint:
Comment thread
idalithb marked this conversation as resolved.
Outdated

```
https://gateway.thegraph.com/api/<YOUR_API_KEY>/subgraphs/id/<SUBGRAPH_ID>
```

> [!NOTE] This allows you to use various GraphQL client libraries to query Subgraphs and populate your application with indexed data.
Comment thread
idalithb marked this conversation as resolved.
Outdated

2. As a Bearer Token:
Comment thread
idalithb marked this conversation as resolved.
Outdated

Include your API Key in the request header for added security:
Comment thread
idalithb marked this conversation as resolved.
Outdated

```
Authorization: Bearer <YOUR_API_KEY>
```

Check out [Querying from an App](/subgraphs/querying/from-an-application) for more details.

## Manage API Keys

The “API keys” table lists existing API keys and allows you to manage or delete them. For each key, you can see its status, the cost for the current period, the spending limit for the current period, and the total number of queries.
Expand Down