Skip to content

Commit 6036093

Browse files
committed
Adding Section
1 parent ceda510 commit 6036093

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

website/src/pages/en/subgraphs/querying/managing-api-keys.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,32 @@ A new window will pop up:
2626

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

29+
## Using Your API Key
30+
31+
> [!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.
32+
33+
When you query The Graph from your dapp, you can use your API key in two ways:
34+
35+
1. In the URL (Optimal Method for Subgraph Queries):
36+
37+
Append the API Key directly to your query endpoint:
38+
39+
```
40+
https://gateway.thegraph.com/api/<YOUR_API_KEY>/subgraphs/id/<SUBGRAPH_ID>
41+
```
42+
43+
> [!NOTE] This allows you to use various GraphQL client libraries to query Subgraphs and populate your application with indexed data.
44+
45+
2. As a Bearer Token:
46+
47+
Include your API Key in the request header for added security:
48+
49+
```
50+
Authorization: Bearer <YOUR_API_KEY>
51+
```
52+
53+
Check out [Querying from an App](/subgraphs/querying/from-an-application) for more details.
54+
2955
## Manage API Keys
3056

3157
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.

0 commit comments

Comments
 (0)