snapshot
Blog
  • Welcome to Snapshot docs
  • User guides
    • Spaces
      • What is a space?
      • Create a space
        • Register an ENS domain
        • Alternative way to create a space
      • Settings
      • Sub-spaces
      • Space verification
      • Space hibernation
      • Add a custom domain
      • Add a skin
      • Space roles
      • Space badges
      • Snapshot Pro
      • Space handbook
        • Most common
        • Voting threshold
        • Anti-whale
        • Sybil resistance, scam & spam prevention
        • Liquidity / staking pool
        • Delegation
        • NFT voting
          • Most common: ERC-721
          • Multi-token: ERC-1155
          • POAP - Proof of Attendance
        • Custom calculations
    • Create a proposal
    • Voting
      • Vote on a proposal
      • Delegate your voting power
    • Voting strategies
    • Validation strategies
    • Using Safe multi-sig
    • Delegation
  • Developer Guides
    • Create a voting strategy
    • Create a validation strategy
    • Identify integrator activity
    • Add a network
  • Tools
    • Tools overview
    • Snapshot.js
    • API
      • API Keys
    • Webhooks
    • Subgraphs
    • Mobile notifications
    • Bots
  • Snapshot X
    • Overview
    • User guides
      • Create a space
      • Proposals
      • Voting
      • Safe execution setup
    • Protocol
      • Overview
      • Space actions
      • Space controller actions
      • Authenticators
      • Proposal validations
      • Voting strategies
      • Starknet specifics
      • Execution strategies
      • Audits
    • Services
      • Architecture
      • API
      • SX.js
      • UI
      • Mana
  • V1 interface
    • Email notifications
    • Plugins
      • What is a plugin?
      • Create a plugin
      • oSnap
      • SafeSnap
      • POAP
      • Quorum
      • Domino notifications
      • Galxe
    • Boost
  • Community
    • Help center
    • Discord
    • X (Twitter)
    • GitHub
Powered by GitBook
On this page
  • The Snapshot Subgraph
  • Schema
  • Snapshot Subgraph endpoint
  • How to obtain your own API key
  • Other Snapshot Subgraphs
  • How to Query through the API
  • Sample code (Node.js):
  • How to use the Visual Query Editor
  • About The Graph
  • Benefits of using The Graph
  • Additional resources

Was this helpful?

Edit on GitHub
Export as PDF
  1. Tools

Subgraphs

Query data with Subgraphs on The Graph.

PreviousWebhooksNextMobile notifications

Last updated 7 months ago

Was this helpful?

Snapshot’s onchain data can be easily queried with open APIs known as subgraphs. Subgraphs are decentralized APIs powered by The Graph, a protocol for indexing & querying data from blockchains.

The Snapshot Subgraph

You can see an interactive query playground on the , where you can test any query.

Check out the following examples:

Example Query: Get the first 5 delegations from Snapshot
{
  delegations(first: 5) {
    id
    delegator
    space
    delegate
  }
}

Example output

{
  "data": {
    "delegations": [
      {
        "delegate": "0xde1e6a7ed0ad3f61d531a8a78e83ccddbd6e0c49",
        "delegator": "0x00000000005ef87f8ca7014309ece7260bbcdaeb",
        "id": "0x00000000005ef87f8ca7014309ece7260bbcdaeb-cvx.eth-0xde1e6a7ed0ad3f61d531a8a78e83ccddbd6e0c49",
        "space": 
      },
  //…
     ]}
}

Schema

Snapshot Subgraph endpoint

https://gateway.thegraph.com/api/[api-key]/subgraphs/id/4YgtogVaqoM8CErHWDK8mKQ825BcVdKB8vBYmb4avAQo

How to obtain your own API key

Other Snapshot Subgraphs

How to Query through the API

You can pass any GraphQL query to the Snapshot endpoint and receive data in JSON format.

This following code example will return the exact same output as above.

Sample code (Node.js):

const axios = require('axios');

const graphqlQuery = `{
  delegations(first: 5) {
    id
    delegator
    space
    delegate
  }
}`;

const queryUrl = 'https://gateway.thegraph.com/api/[api-key]/subgraphs/id/4YgtogVaqoM8CErHWDK8mKQ825BcVdKB8vBYmb4avAQo';

const graphQLRequest = {
  method: 'post',
  url: queryUrl,
  data: {
    query: graphqlQuery,
  },
};

// Send the GraphQL query
axios(graphQLRequest)
  .then((response) => {
    // Handle the response here
    const data = response.data.data;
    console.log(data);
  })
  .catch((error) => {
    // Handle any errors
    console.error(error);
  });

How to use the Visual Query Editor

You can use the GraphiQL Explorer to compose your GraphQL queries by clicking on the fields you want.

About The Graph

The Graph is a decentralized protocol that enables seamless querying and indexing of blockchain data. It simplifies the complex process of querying blockchain data through the use of subgraphs (open APIs).

Benefits of using The Graph

  • Anyone can query subgraphs on The Graph

  • All users get 100,000 free queries per month

  • Unlocking more queries is a seamless experience, you can pay with crypto or a credit card

Additional resources

The schema for this subgraph is defined .

This is visible from the on Graph Explorer.

Go to and connect your wallet.

Go to to create an API key.

You can use this API key on any subgraph on , and it’s not limited to just Snapshot.

For more information about querying data from your subgraph, .

To explore all the ways you can optimize & customize your subgraph for a better performance, read more about .

Snapshot subgraph’s page on The Graph Explorer
here in Snapshot’s GitHub
Snapshot subgraph’s page
thegraph.com/studio
https://thegraph.com/studio/apikeys/
Graph Explorer
Snapshot on Arbitrum
Snapshot on Fantom
Snapshot on Gnosis Chain
See all other subgraphs published by Snapshot Labs.
read more here
creating a subgraph here