Call the SQL API

You send a SQL statement to /api/sql/v1. Named bindings use :name.

Read rows

GET https://core.orbitype.com/api/sql/v1?sql=SELECT * FROM posts
X-API-KEY: YOUR_API_KEY

Response:

[
  { "id": 1, "title": "Alpha" },
  { "id": 2, "title": "Bravo" }
]

Filter

GET https://core.orbitype.com/api/sql/v1?sql=SELECT * FROM posts WHERE id = :id&bindings[id]=2
X-API-KEY: YOUR_API_KEY

Insert

POST https://core.orbitype.com/api/sql/v1
X-API-KEY: YOUR_API_KEY
Content-Type: application/json

{
  "sql": "INSERT INTO posts (title) VALUES (:title) RETURNING *",
  "bindings": { "title": "Delta" }
}

Response:

[ { "id": 4, "title": "Delta" } ]

Update and delete

POST https://core.orbitype.com/api/sql/v1

{
  "sql": "UPDATE posts SET title = :title WHERE id = :id RETURNING *",
  "bindings": { "id": 4, "title": "New title" }
}
{
  "sql": "DELETE FROM posts WHERE id = :id RETURNING *",
  "bindings": { "id": 4 }
}

sql is required. bindings is an object of names used in the statement. A missing table returns a database error in the response body.