Quick Start
These subgraphs only take a few minutes to set up. To get started, follow these three steps:- Initialize your subgraph project
- Deploy & Publish
- Query from your dapp
1. Initialize your subgraph project
Create a subgraph on Subgraph Studio
Go to the Subgraph Studio and connect your wallet. Once your wallet is connected, you can begin by clicking “Create a Subgraph”. When entering the subgraph name, it is recommended to use Title Case: “Subgraph Name Chain Name.” Create a Subgraph You will then land on your subgraph’s page. All the CLI commands you need will be visible on the right side of the page: CLI CommandsInstall the Graph CLI
On your local machine run the following:Initialize your Subgraph
You can copy this directly from your subgraph page to include your specific subgraph slug:2. Deploy & Publish
Deploy to Subgraph Studio
First run these commands:Test your subgraph
You can test your subgraph by making a sample query in the playground section. The Details tab will show you an API endpoint. You can use that endpoint to test from your dapp. Run your graphql query in StudioPublish Your Subgraph to The Graph’s Decentralized Network
Once your subgraph is ready to be put into production, you can publish it to the decentralized network. On your subgraph’s page in Subgraph Studio, click on the Publish button: Click Publish Before you can query your subgraph, Indexers need to begin serving queries on it. In order to streamline this process, you can curate your own subgraph using GRT. When publishing, you’ll see the option to curate your subgraph. Signaling GRT on your own subgraph helps ensure that it is indexed and available for querying as soon as possible. See The Graph’s curating documentation for current guidance on how much GRT to signal. Publish Screen3. Query your Subgraph
Congratulations! You can now query your subgraph on the decentralized network! For any subgraph on the decentralized network, you can start querying it by passing a GraphQL query into the subgraph’s query URL which can be found at the top of its Explorer page. Here’s an example from the CryptoPunks Ethereum subgraph by Messari: Query URL The query URL for this subgraph is:https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK
Now, you need to fill in your own API Key to start sending GraphQL
queries to this endpoint.
Getting your own API Key
API keys In Subgraph Studio, you’ll see the “API Keys” menu at the top of the page. Here you can create API Keys.Appendix
Sample Query
This query shows the most expensive CryptoPunks sold.Sample code
Additional resources:
- To explore all the ways you can optimize & customize your subgraph for a better performance, read more about creating a subgraph here.
- For more information about querying data from your subgraph, read more here.