API Documentation

Scratch has 2 endpoints: one to query data and another to insert. The base URL for the API is:
There are multiple ways to authenticate with your API key:
  1. Use the X-API-KEY header
  2. Add ?api_key=... as a query param

Querying Data

You can run SQL queries on your data using /query?q=YOUR SQL QUERY. This will return data as JSON. We also support returning data as an HTML table by adding ?format=html to the query.

curl 'https://api.scratchdb.com/query?q=select * from events' \
     -H "X-API-KEY: your_api_key"

Inserting Data

You can post a JSON document or JSON array to insert data. We automatically create tables and columns based on your JSON. We also batch data and insert it asynchrously, so you can stream data into the system without worrying about database performance.

curl -X POST https://api.scratchdb.com/data \
     -H "X-API-KEY: demo" \
     -H "X-SCRATCHDB-TABLE: events" \
     -d '{"user": "jay", "event": "click"}'