Overview

GraphQL is a query language for APIs and a runtime for executing those queries by using a type system you define for your data. It is used to abstract away having to write SQL as it enables clients to request exactly the data they need, often in a single request, which can be more efficient and easier to manage than constructing multiple SQL queries.

For more information on what GraphQL is and how you can use it, see this page.

This is a suite of APIs (both REST and GraphQL) for interacting with the SxT platform via GraphQL. You can use these APIs to query your own tables in Space and Time as well as all indexed blockchain data.

🚧

Before calling the GraphQL APIs, make sure you've authenticated to Space and Time.

GraphQL API

We provide a single Execute GraphQL API endpoint that you can use to perform queries against any existing GraphQL schemas. If you need to manage existing schemas or discover new schemas, use our REST APIs (see the below section).

Once you have a GraphQL schema you'd like to use, simply write up your GraphQL query like you would normally. Make sure to specify the schema name in the header and the input query will be validated against the schema you reference. In addition, any queries against permissioned tables will need to be authorized with biscuits (just like if you queried them via the SQL API) - so specify biscuits in the request body where necessary.

REST APIs

Some of the provided APIs in this section are actually REST APIs that can be used to manage and discover GraphQL schemas.

To find out what schemas exist: simply call the Discover GraphQL schemas API. You can search for both public and subscription schemas.

To look at a GraphQL schema: use the Retrieve GraphQL schema API.

To create a new GraphQL schema:: use the Create GraphQL schema API. You'll need an existing database schema, but the GraphQL schema will be automatically generated on your behalf - all you need to do is provide a name for the GraphQL schema, a scope for visibility (e.g., choose PUBLIC if you want to include public tables only), and the database schema identifier!

If you need to regenerate a GraphQL schema: use the Update GraphQL schema API. You might need to use this if you add or remove a table (i.e., change your data model).

If you need to delete a GraphQL schema: use the Delete GraphQL schema API.