package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.elefork.com/v1/branches/example/sql"
payload := strings.NewReader("{ \"sql\": \"example\", \"database\": \"postgres\", \"role\": \"postgres\", \"max_rows\": 1000 }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.elefork.com/v1/branches/example/sql';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"sql":"example","database":"postgres","role":"postgres","max_rows":1000}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.elefork.com/v1/branches/example/sql \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "sql": "example", "database": "postgres", "role": "postgres", "max_rows": 1000 }'Runs a script (one or more statements, simple query protocol) as role in database, through
the gateway like any client: a paused branch is woken, and the session counts as activity.
Each request is its own session (no transaction spans requests); statements time out after
30 s. Postgres errors are returned as error with status 200, after the results of the
statements that ran before the failing one. Rows beyond max_rows per result, and bytes beyond
4 MiB in total, are dropped (truncated). Values are in Postgres text format; null is NULL.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Responses
Section titled “Responses”Results, one per statement
object
object
object
Rows returned or affected
object
1-based character offset in the script
Example generated
{ "results": [ { "columns": [ { "name": "example", "type": "example" } ], "rows": [ [ "example" ] ], "command_tag": "example", "row_count": 1, "truncated": true } ], "duration_ms": 1, "error": { "sqlstate": "example", "message": "example", "detail": "example", "hint": "example", "position": 1 }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Temporarily unavailable; retry after the Retry-After seconds. Codes:
database_unavailable (the metadata database is failing over) and
cube_admission (a compute node runs a sandbox shim below the
platform minimum, so creates, forks, checkpoints and resets are
refused until it is upgraded).
object
object
Example
{ "error": { "code": "not_found" }}