OpenThink Cloud

Query with SQL

Run SQLite over the tables of a project from REST, HTML pages and Think Service.

SQL in OpenThink Cloud uses SQLite's dialect. Tables and columns are addressed by their display names in double quotes, and "_id" is the row ID.

sql
SELECT "Status", COUNT(*) AS n
FROM "Tasks"
WHERE "Due" < ?
GROUP BY "Status"

From REST

bash
curl -X POST https://openthink.app/api/v1/sql \
  -H "Authorization: Bearer $THK" -H "Content-Type: application/json" \
  -d '{ "sql": "SELECT \"Title\" FROM \"Tasks\" WHERE \"Status\" = ?", "params": ["Todo"] }'

SELECT returns { columns, rows }. Writes need a read-and-write key and return inserted, updated and deleted.

From an HTML page

js
const res = await think.executeSql('SELECT * FROM "Tasks" WHERE "Status" = ?', ["Todo"])

The page reads and writes as the person viewing it, so their role and the table's policy apply. When a table the page has read changes, the page receives a think:data event and can query again.

From Think Service

js
const rows = await c.var.think.store.sql('SELECT * FROM "Tasks" WHERE "Status" = ?', ["Todo"])
const mine = await c.var.think.store.asViewer().sql('SELECT * FROM "Tasks"')

Restrictions

  • Changing a table's structure (creating, altering or dropping tables) with SQL is refused. Change columns in OpenThink or over MCP.
  • A statement that writes to several tables does not run in one transaction across them.
  • Queries are limited to 100,000 characters.

Last updated 2026-12-03 UTC. Something wrong or missing? Send feedback.