Skip to main content
Turso Databases can be accessed via HTTP. The API enables developers to perform SQL operations using SQL over HTTP, retrieve server version information, and monitor the health status.
It’s recommended you use a native SDK.

Base URL

Simply replace your database URL protocol (turso:// for Turso databases, libsql:// for libSQL databases) with https://:
You can obtain your database base URL from the Turso CLI:

Authentication

Turso uses Bearer authentication, and requires your API token to be passed with all protected requests in the Authorization header:

Endpoints

Your database has the endpoints available below:

POST /v2/pipeline

You can use the /v2/pipeline endpoint to query a database. The endpoint accepts a series of operations to perform against a database connection. The supported operation types are:
  • execute: execute a statement on the connection.
  • close: close the connection.

Simple query


Connections are left open until they timeout, unless you close them explicitly in the request (as shown above). Every request made on a connection bumps the timeout. You should close the connection when it’s no longer needed.

Parameter binding

Queries with bound parameters come in two types:
  1. Positional query parameters, bound by their position in the parameter list, and prefixed ?. If the query uses positional parameters, the values should be provided as an array to the args field.

  1. Named bound parameters, where the parameter is referred to by a name and is prefixed with a :, a @ or a $. If the query uses named parameters, then the named_args field of the query should be an array of objects mapping parameters to their values.

The name property of each named_args can match the prefix or omit the prefix. They were omitted in the example above, but both versions are valid.The type field within each arg corresponds to the column datatype and can be one of the following: null, integer, float, text, or blob.
If using the blob type, replace the value property with base64 and encode the argument into base64 before sending the request.
In JSON, the value is a String to avoid losing precision, because some JSON implementations treat all numbers as 64-bit floats.

Interactive query

Sometimes, it may be desirable to perform multiple operation on the same connection, in multiple roundtrips. We can do this by not closing the connection right away:
We can see that we have received a baton back. This is because we haven’t closed the connection. We can now use this baton to perform more queries on the same connection:
Body
Note that both transactions and connections have timeouts. Transaction have a 5 seconds window to complete, while connections get closed after 10 seconds of idle time.

Response types

The response contains the following fields: The results array contains the results for each of the requests made in the pipeline. Each result has the following fields:

GET /version

To obtain the current version of the server running your database you can use the /version endpoint:

GET /health

To check the health of your database, you can use the /health endpoint which returns an empty body with an HTTP status:

GET /dump

You can dump the database using the /dump endpoint:
If you’re using multi-db schemas, or vector databases, you will see statements that represent internally managed tables.

Schema Migration Status

Turso provides a managed multi-tenant schema system — Multi-DB Schemas. This feature allows you to create a single database that shares its schema automatically with any related child databases. Changes to the parent database automatically propogate to the related databases. The /v1/jobs endpoint lets you monitor the status of schema migrations.
Currently not available on AWS for Free, Developer and Scaler plans.

GET /v1/jobs

Returns a summary of all migration jobs for a schema:

Response Fields

number
Current version of the schema.
array
List of migration jobs

GET /v1/jobs/:id

Returns detailed information about a specific migration job.

Path Parameters

number
required
The ID of the migration job.

Response Fields

number
Unique ID of the migration job.
string
Overall status of the job. Possible values are the same as in the /v1/jobs endpoint.
string
Error message if the job failed, null otherwise.
array
List of migration statuses for the individual databases.

Listen to changes

You can listen to changes committed to your database using the /beta/listen endpoint:
This is currently in technical preview. Join us in Discord to report any issues.
Currently not available on AWS for Free, Developer and Scaler plans.
Your database group must be using the version v0.24.18 or greater — turso group update <group-name> --version latest

GET /beta/listen

Request

Query Parameters

string
required
The name of the table to listen to.
string
required
The name of the action to listen to — insert, update, or delete.