Grist sql API

Sql endpoint to query data from documents.

Operations 2

GET /docs/{docId}/sql Run an SQL query against a document #
POST /docs/{docId}/sql Run an SQL query against a document, with options or parameters #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/grist-sql-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

grist-sql-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  description: 'An API for manipulating Grist sites, workspaces, and documents.


    # Authentication

    <SecurityDefinitions />

    '
  version: 1.0.1
  title: Grist attachments Sql API
servers:
- url: https://{gristhost}/api
  variables:
    subdomain:
      description: The team name, or `docs` for personal areas
      default: docs
security:
- ApiKey: []
tags:
- name: sql
  description: Sql endpoint to query data from documents.
paths:
  /docs/{docId}/sql:
    get:
      operationId: runSqlGet
      tags:
      - sql
      summary: Run an SQL query against a document
      description: 'Execute a read-only SQL SELECT query against the document''s SQLite database.

        This is a simplified endpoint for basic queries. For queries with parameters

        or custom timeouts, use the POST endpoint instead.

        '
      parameters:
      - $ref: '#/components/parameters/docIdPathParam'
      - in: query
        name: q
        schema:
          type: string
          description: The SQL query to run. This GET endpoint is a simplified version of the corresponding POST endpoint, without support for parameters or options. See the POST endpoint for details of what's allowed in the SQL query string.
      responses:
        200:
          description: The result set for the query.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SqlResultSet'
    post:
      operationId: runSql
      tags:
      - sql
      summary: Run an SQL query against a document, with options or parameters
      description: 'Execute a read-only SQL SELECT query with support for parameterized queries

        and custom timeouts. All Grist documents are SQLite databases, and queries

        are executed directly against SQLite with security restrictions.

        '
      parameters:
      - $ref: '#/components/parameters/docIdPathParam'
      requestBody:
        description: Query options
        content:
          application/json:
            schema:
              type: object
              required:
              - sql
              properties:
                sql:
                  type: string
                  description: The SQL query to run. Must be a single SELECT statement, with no trailing semicolon. WITH clauses are permitted. All Grist documents are currently SQLite databases, and the SQL query is interpreted and run by SQLite, with various defensive measures. Statements that would modify the database are not supported.
                  example: select * from Pets where popularity >= ?
                args:
                  type: array
                  items:
                    oneOf:
                    - type: number
                    - type: string
                  description: Parameters for the query.
                  example:
                  - 50
                timeout:
                  type: number
                  description: Timeout after which operations on the document will be interrupted. Specified in milliseconds. Defaults to 1000 (1 second). This default is controlled by an optional environment variable read by the Grist app, GRIST_SQL_TIMEOUT_MSEC. The default cannot be exceeded, only reduced.
                  example: 500
      responses:
        200:
          description: The result set for the query.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SqlResultSet'
components:
  schemas:
    SqlResultSet:
      type: object
      required:
      - statement
      - records
      properties:
        statement:
          type: string
          description: A copy of the SQL statement.
          example: select * from Pets ...
        records:
          type: array
          items:
            type: object
            required:
            - fields
            properties:
              fields:
                type: object
          example:
          - fields:
              id: 1
              pet: cat
              popularity: 67
          - fields:
              id: 2
              pet: dog
              popularity: 95
  parameters:
    docIdPathParam:
      in: path
      name: docId
      schema:
        type: string
      description: A string id (UUID)
      required: true
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: 'Authorization: Bearer XXXXXXXXXXX'
      description: Access to the Grist API is controlled by an Authorization header, which should contain the word 'Bearer', followed by a space, followed by your API key.