Introducing API Keys to the Hub GraphQL API

Our Hub API has always been open for anyone to query as we wanted to provide equal access to information for our users and integrators. This however has led to several issues related to API performance. To give you a better idea - we are receiving over 540 million requests per month.

While well-structured and timed requests are not posing a threat to the stability of the service we have seen some incidents caused by sudden outbursts of incoming requests, caused either by bots spamming the API or poor-quality code falling into endless loops.

We want to make sure that we limit the risk of API downtime and provide a reliable and continuous service. Therefore we decided to implement API Keys to make sure that the requests are coming from genuine users.

Do not worry if you are a current API user!

The API will be still available in the current form until September 12th to enable a smooth transition for everyone. After September 12th you will be able to query it without a key but at a much lower limit.

How can I get a key?

  1. If you haven’t already please fill in the following form:
  1. We will review your submission and whitelist the address you provided in the form.

  2. After 72 hours from the form submission you can continue with the next steps:

  3. Go to https://app.mycrypto.com/sign-message and connect your wallet using the account you provided in the submission form above.

  4. Sign the message with the keyword generateKey.

Sign the message with "generateKey".
Sign the message with "generateKey".
  1. Copy the signature and run the below curl command. Make sure to use the signature hash from step 5 in the sig param, do not paste the entire response after signing the message.
curl --location 'https://keycard.snapshot.org' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "method": "generate_key",
    "params": {
        "sig": "<SIGNATURE_HASH>"
    },
    "id": "123456789"
}'

Example:

...
    "method": "generate_key",
    "params": {
        "sig": "0x85bcabdeb3b43131364d21b32f8c74124d155009fc9d6d40901b4b725f23e0ac632808ebb00f3569bf875ded07b61ac5163ebe757b0897278ab276cdc982e3001c"
    },
...

That’s it, you should receive your unique API Key in the response!

Will the limit change?

During the next three months, the limits for keyless access to the API will not change:

🔓 No API Key: 120 requests every 20 seconds.

🔑 With the API Key: 2 million requests per month.

After September 12th, the limits will be updated to:

🔓 No API Key: 100 requests every minute.

🔑 With the API Key: 2 million requests per month.

If you are getting close to 2M requests a month please reach out to our team directly on Discord by creating a new ticket in the #helpdesk-tickets channel.

How to structure the query with my key?

The only change you need to make is to add the apiKey in the headers of your request:

curl 'https://hub.snapshot.org/graphql?' \
  -H 'content-type: application/json' \
  -H 'x-api-key: <YOUR-API-KEY>' \
  --data-raw '{"query":"\n{\n space(id:\"snapshot.dcl.eth\"){\n  id\n  name\n  members\n}\n}","variables":null}' \
  --compressed

Mint to subscribe

 

Resources

Subscribe to Snapshot Labs
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.