Querying an existing subgraph

Each subgraph deployed on the decentralized network has a query URL that allows you to query the blockchain data indexed by that subgraph. Let’s learn how to use an existing subgraph to query data to your frontend application!


Using the Graph Explorer

Open a subgraph you want to query from the Graph Explorer and click on “Query” to access the query URL. It looks something like: https://gateway.thegraph.com/api/**[api-key]**/subgraphs/id/AVZ1dGwmRGKsbDAbwvxNmXzeEkD48voB3LfGqj5w7FUS

Note the **[api-key]** placeholder. This needs to be replaced with a real API-key:

Creating your first API Key

API Keys are required to query subgraphs. You can receive 1,000 free queries on your first API key. You can create and manage your API keys in the Subgraph Studio from the API Keys section.

  1. Open Subgraph Studio > API Keys
  2. Click on “Create API Key”
  3. Enter the name of your API Key and hit “Create API Key”
  4. Enter email to claim 1,000 free queries
  5. Click on “Copy” to copy the API Key from the Overview section. It looks something like: 106d························a90b

Adding the API Key

Update the query URL for the subgraph with the newly created API Key from the previous step. The result would be something like:

[https://gateway.thegraph.com/api/](<https://gateway.thegraph.com/api/%5Bapi-key%5D/subgraphs/id/AVZ1dGwmRGKsbDAbwvxNmXzeEkD48voB3LfGqj5w7FUS>)106d························a90b[/subgraphs/id/AVZ1dGwmRGKsbDAbwvxNmXzeEkD48voB3LfGqj5w7FUS](<https://gateway.thegraph.com/api/%5Bapi-key%5D/subgraphs/id/AVZ1dGwmRGKsbDAbwvxNmXzeEkD48voB3LfGqj5w7FUS>)

<aside> 💡 Note: Querying subgraphs using your API keys will generate query fees that will be paid in GRT. You can learn more about billing here: https://thegraph.com/docs/en/querying/billing/

</aside>


More Resources