Calling the API

Once you've added a base and configured access to it, you'll want to call the base API from your app.

Authentication

AirQL uses OAuth to authenticate API requests. We recommend that you use an OAuth2 client implementation appropriate for your language (e.g. NextAuth.js, github.com/golang/oauth2, etc.) with the following configuration:

The access token returned by the token endpoint should be used as a bearer token in the Authorization header when calling the base API.

The base API endpoint

The GraphQL API for your base is accessible at https://api.airql.dev/base/BASE_ID where BASE_ID is the ID you see in Airtable URLs, e.g. appGSRaZVwoOoAbQB.

You can explore this API from the Playground tab in the AirQL UI. For more information about the shape of the base API and the playground, see GraphQL base API.

Here's an example of making a simple GraphQL query using curl. Note the that you'll need to replace YOUR_AUTH_TOKEN with a real OAuth token. The easiest way to get that is to look at the API calls made by the playground in your browser developer tools.

echo '{"query":"{ employees { records { name } } }"}' | \
  curl https://api.airql.dev/base/appGSRaZVwoOoAbQB \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN' \
  -H 'Content-Type: application/json' \
  -X POST -d @-

To make GraphQL API calls from a custom web app, we recommend using a library like graphql-request or github.com/shurcooL/graphql.

Last updated