Skip to content

Commit

Permalink
Merge pull request #555 from DaBigBlob/main
Browse files Browse the repository at this point in the history
make http api v0 docs consistent with libsql-server/src
  • Loading branch information
penberg committed Nov 7, 2023
2 parents 84e137f + 35032c3 commit ecf6dbb
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions libsql-server/docs/http_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,15 @@ Responses to queries can either succeed or fail. When they succeed a payload spe

In the case of a failure, a specific `Error` response is returned with the approriate HTTP status code. The `Error` response has the following structure:

```
```ts
type Error = {
error: {
message: string,
error_code: string,
}
error: string
}
```
The error code can later be used to link to the relevant documentation.

The general structure of a response is:
```
```ts
type Response<T> = T | Error;
```

Expand All @@ -57,7 +52,7 @@ The HTTP API is stateless, which means that interactive transactions are not pos

The body for the query request has the following format:

```
```ts
type QueryBody = {
statements: Array<Query>
}
Expand All @@ -71,20 +66,20 @@ Queries are either simple strings or `ParamQuery` that accept parameter bindings
##### Response Format
On success, a request to `POST /` returns a response with an HTTP 200 code and a JSON body with the following structure:
```
type BatchResponse = {
results: Array<QueryResult>,
}
```ts
type BatchResponse = Array<QueryResult>|Error

type QueryResult = {
columns: Array<string>,
rows: Array<Array<Value>>,
results: {
columns: Array<string>,
rows: Array<Array<Value>>
}
}

```

Each entry in the `results` array of the `BatchResponse` corresponds to a query in the request.
The `QueryResult` is either an error or a set of results.
Each `QueryResult` entry in the `BatchResponse` array corresponds to a query in the request.
The `BatchResponse` is either an `Error` or a set of `QueryResult`s.

The `Query` can either be a plain query string, such as `SELECT * FROM users` or `INSERT INTO users VALUES ("adhoc")`, or objects for queries with bound parameters.

Expand Down

0 comments on commit ecf6dbb

Please sign in to comment.