Subgraphs Quickstart

A developer's guide to developing and deploying to Alchemy Subgraphs.

What is a Subgraph?

Subgraphs are an open-source tool for building custom GraphQL APIs with blockchain data.

How it works

  1. Write your subgraph code.
  2. Deploy to Alchemy Subgraphs.
  3. Query live blockchain data through your GraphQL API.

Why use a subgraph?

  • Ship in days, not weeks - Spend up to 50% less time on data indexing and dealing with forks / reorgs.
  • Simplify your infrastructure - Save hours every week on infra maintenance or downtime.

Getting Started

Creating a new subgraph

  1. Install the graph-cli:

    npm install -g @graphprotocol/graph-cli
    
  2. Create a new subgraph:

    graph init --product hosted-service
    
  3. Make modifications as necessary to the manifest, schema, and handlers.

  4. See Developing a Subgraph for more details.

Deploying your subgraph

  1. Get your deploy key from your Alchemy Dashboard.

  2. Run the following:

    cd <SUBGRAPH_DIRECTORY>
    
    graph deploy <SUBGRAPH_NAME> \
      --version-label <VERSION_NAME> \
      --node https://subgraphs.alchemy.com/api/subgraphs/deploy \
      --deploy-key <DEPLOY_KEY>
      --ipfs https://ipfs.satsuma.xyz
    

    See Deploying a Subgraph for more details.

  3. You’ll receive a link to view your newly deployed subgraph. Congrats! :tada: