Skip to content

API integration

Subgraphs endpoint, GraphQL request, authentication, identifier, metadata, and error contracts.

Use this reference to build Subgraph requests and interpret their responses. GraphOps Subgraphs exposes standard GraphQL query endpoints over HTTPS. Each endpoint is selected by Deployment CID, Graph Network Subgraph ID, or GraphOps Endpoint Alias, and authenticated with an API key that includes Subgraphs.

Endpoint patterns

Header-authenticated endpoints:

Reference

https://subgraphs.graphops.xyz/v1/deploymentCID/<DEPLOYMENT_CID>
https://subgraphs.graphops.xyz/v1/subgraphId/<SUBGRAPH_ID>
https://subgraphs.graphops.xyz/v1/alias/<ALIAS>
A Subgraphs endpoint names what to query in its path: the identifier type, then the identifier. This example uses an Endpoint Alias; deploymentCID and subgraphId work the same way. Send the API key in the Authorization header or append it to the path.

Route-token endpoints:

Reference

https://subgraphs.graphops.xyz/v1/deploymentCID/<DEPLOYMENT_CID>/<GRAPHOPS_API_KEY>
https://subgraphs.graphops.xyz/v1/subgraphId/<SUBGRAPH_ID>/<GRAPHOPS_API_KEY>
https://subgraphs.graphops.xyz/v1/alias/<ALIAS>/<GRAPHOPS_API_KEY>

Endpoint preview

Use a Qm… Deployment CID for one version.

Replace placeholders with your identifier and API key before making requests.

See Authentication to choose how to send your API key and protect it in logs.

Request envelope

Subgraph queries use the standard GraphQL HTTP request shape:

FieldTypeRequiredNotes
querystringYesGraphQL query or mutation text. Query support depends on the Subgraph schema.
variablesobjectNoVariables referenced by the query.
operationNamestringNoRequired only when the document contains multiple named operations.

JSON

{
  "query": "query Pools($first: Int!) { pools(first: $first) { id } }",
  "variables": {
    "first": 5
  },
  "operationName": "Pools"
}

Output

{  "data": {Present when the query ran    "pools": [      {        "id": "0x000024feb293b6c6c3a80a95f1f830a8746400b9"No matching entities, not an error      },      {        "id": "0x0000d36ab86d213c14d93cd5ae78615a20596505"      },      {        "id": "0x00013bffe4c38c1372a450fac78b01cb4f554781"      },      {        "id": "0x0001fcbba8eb491c3ccfeddc5a5caba1a98c4c28"      },      {        "id": "0x00024b66a38a676c0eae59126c1367ad141afa79"      }    ]  }}

Request

These clients send the request envelope above through an Endpoint Alias.

Prerequisites

  1. Set GRAPHOPS_API_KEY to your GraphOps API key.

  2. Replace <ALIAS> with your Endpoint Alias.

CLI · curl

curl --fail-with-body --silent --show-error "https://subgraphs.graphops.xyz/v1/alias/<ALIAS>" \
  -H "Authorization: Bearer ${GRAPHOPS_API_KEY}" \
  -H "Content-Type: application/json" \
  --data '{
    "query": "query Pools($first: Int!) { pools(first: $first) { id token0 { symbol } token1 { symbol } } _meta { block { number hash } } }",
    "variables": { "first": 5 },
    "operationName": "Pools"
  }'

Output

{  "data": {Present when the query ran    "pools": [      {        "id": "0x000024feb293b6c6c3a80a95f1f830a8746400b9",No matching entities, not an error        "token0": {          "symbol": "TRUMP"        },        "token1": {          "symbol": "WETH"        }      },      {        "id": "0x0000d36ab86d213c14d93cd5ae78615a20596505",        "token0": {          "symbol": "RALPH"        },        "token1": {          "symbol": "WETH"        }      },      {        "id": "0x00013bffe4c38c1372a450fac78b01cb4f554781",        "token0": {          "symbol": "Pectra"        },        "token1": {          "symbol": "WETH"        }      },      {        "id": "0x0001fcbba8eb491c3ccfeddc5a5caba1a98c4c28",        "token0": {          "symbol": "BCZ"        },        "token1": {          "symbol": "WETH"        }      },      {        "id": "0x00024b66a38a676c0eae59126c1367ad141afa79",        "token0": {          "symbol": "WETH"        },        "token1": {          "symbol": "TI"        }      }    ],    "_meta": {      "block": {        "number": 26285619,Indexed block behind the result        "hash": "0x09fffa722f278b60998290f6534850d5b2248e083ada05d332aa684f24f8302e"      }    }  }}

Response

Successful GraphQL responses include data. An empty list is a valid result when no entities match:

JSON

{
  "query": "query EmptyPools { pools(first: 10, where: { id_gt: \"0xffffffffffffffffffffffffffffffffffffffff\" }, orderBy: id) { id } _meta { block { number } } }"
}

Output

{  "data": {    "pools": [],A successful query with no matching pools    "_meta": {      "block": {        "number": 26285631Historical block served: 26,285,631      }    }  }}

Responses can include errors even when the HTTP request succeeds. Check for errors on every response:

JSON

{
  "query": "query InvalidField { notARealField }"
}

Output

{  "errors": [Can arrive with HTTP 200    {      "message": "Cannot query field \"notARealField\" on type \"Query\".",Fix the query; retrying will not help      "locations": [        {          "line": 1,          "column": 22        }      ]    }  ]}

Response headers

HeaderValuePresent when
X-Deployment-CIDThe Deployment CID that served the request, for example QmRYcnVddpADmnZz812rc1WDE3n2TRsuP5PcGsMxZjaZMMEvery response returned by a deployment, on all three endpoint patterns, including responses with GraphQL errors or a non-2xx status

X-Deployment-CID tells you which deployment answered without changing your query. It matches _meta.deployment for the same request. An Endpoint Alias or Graph Network Subgraph ID can serve a different deployment over time: for example, after a promotion, while a new version is still being indexed, or when an Endpoint Alias falls back to a previous version. Record the header with each response when you need to know which version produced a result.

  • The header is absent when GraphOps rejects the request before it reaches a deployment, such as an invalid API key or an unknown Endpoint Alias.
  • For a Deployment CID endpoint, the value is the CID in the endpoint path.
  • Browser clients can read the header: responses list it in Access-Control-Expose-Headers.
  • Header names are case-insensitive; some HTTP clients report it as x-deployment-cid.

Error responses

GraphOps error responses carry a code; look it up in the gateway errors or API key errors reference.

Code or statusMeaningTypical response
400Invalid HTTP request, invalid JSON, or malformed GraphQL document.Fix request encoding or query syntax.
401Missing or invalid API key.Check Authentication.
403The key is valid, but its limits do not include the Subgraph you called, the organization has no credits left, the key does not cover the route, or GraphOps support paused the organization or disabled the key.Check the response code: allow the Subgraph in the key's limits, top up credits, check the endpoint, or contact support. See Troubleshooting.
404Deployment CID, Graph Network Subgraph ID, or Endpoint Alias was not found.Confirm the identifier in the platform UI.
413The request body is too large.Send a smaller query or fewer variables.
429Organization exceeded query rate limits.Back off and reduce request rate.
502The indexing service returned an invalid or oversized response, or the request to it failed.Retry; for large results, reduce the query selection or page size.
503The service is temporarily unavailable.Retry with backoff.
504The indexing service did not respond in time.Retry, or reduce the query's work.
GraphQL errorsSchema, validation, resolver, or indexing issue.Inspect the error message and _meta.

Next steps

Last updated