It’s recommended you use a native SDK.
Base URL
Simply replace your database URL protocollibsql:// with https://:
Obtain HTTP URL using Turso CLI
Obtain HTTP URL using Turso CLI
Authentication
Turso uses Bearer authentication, and requires your API token to be passed with all protected requests in theAuthorization header:
Create token using Turso CLI
Create token using Turso CLI
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.
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: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 from Hrana contains the following fields:| Field | Type | Description |
|---|---|---|
baton | string | The baton is used to identify a connection with the server so that it can be reused. |
base_url | string | The base URL of the server that handled the request. This URL can be reused for subsequent requests to force routing to that server. |
results | array | The results for each of the requests made in the pipeline. |
results array contains the results for each of the requests made in the pipeline. Each result has the following fields:
| Field | Type | Description |
|---|---|---|
cols | array | The list of columns for the returned rows. |
rows | array | The rows returned for the query. |
affected_row_count | integer | The number of rows affected by the query. |
last_insert_rowid | integer | The ID of the last inserted row. |
replication_index | string | The replication timestamp at which this query was executed. |
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: