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!
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:
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.
Subgraph Studio
> API Keys
Overview
section. It looks something like: 106d························a90b
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>