Skip to content

Querying the database through Check API

Daniela Feitosa edited this page May 21, 2021 · 13 revisions

Please note that this page is a work in progress, with some content and links missing

Before starting with queries, read about Authentication and authorization on Check API


Check API data can be retrieved using GraphQL, a query language that returns only the data requested by the client and provides a full description of API data model. For those who are not familiar with GraphQL, this link can give an overview about how to query a GraphQL server: https://graphql.org/learn/queries/

Querying Check GraphQL

Using a command line tool, the format is:

curl -X POST \
     -H 'X-Check-Token: TOKEN' \
     -H 'Content-Type: application/json' \
     -H 'X-Check-Team: <your_team_slug>' \
     --data '<query>' \
     "https://check-api.checkmedia.org/api/graphql"

Including the same query example as above:

curl -X POST \
     -H 'X-Check-Token: TOKEN' \
     -H 'Content-Type: application/json' \
     -H 'X-Check-Team: <your_team_slug>' \
     --data '{ "query": "query { about { name } }" }' \
     "https://check-api.checkmedia.org/api/graphql"

GraphQL web interface

Check API has a web interface where users can perform GraphQL queries and mutations and see their responses.

If you are running Check locally an API key with the token dev is created by default. This token allows you to manage everything in your workspace.

To have access to the GraphQL interface:

  1. Open http://localhost:3000/graphiql
  2. Paste the token in "API Key" at the top of the page, then click "Set API Key"

After authenticating you can use the web interface to query Check API and manage all the content your token allows you to access.

In the left pane you can add the queries and mutations using the autocomplete function. Just start typing and it will list some suggestions according to the data model. To start using, copy and paste the query below:

query {
  about {
    name
  }
}

Clicking on the "play" button you'll get the response in the right pane. The response to the query above should be

{
  "data": {
    "about": {
      "name": "Check"
    }
  }
}

By clicking on "Docs" at the top right of the page you can see the documentation and browse the schema and its description. All the Types, Queries and Mutations are listed there. Use it as reference when describing a query.

Additional reading: