class

Spacetime::HTTPClient

Inherits Reference < Object

Complete HTTP REST API client for SpacetimeDB (/v1/identity and /v1/database).

Constructors

new(host : String = "http://localhost:3000", token : String | Nil = nil, timeout : Time::Span = 15.seconds, custom_handler : RequestHandler | Nil = nil)
Source
new(host : String = "http://localhost:3000", token : String | Nil = nil, timeout : Time::Span = 15.seconds, &block : String, String, HTTP::Headers, String | Nil -> Tuple(Int32, String))
Source

Instance methods

add_database_name(name_or_identity : String, new_name : String) : Nil

POST /v1/database/:name_or_identity/names — Adds a new name alias to a database.

Source
base_url
Source
call_reducer(name_or_identity : String, reducer : String, args_json : String = "[]") : String

POST /v1/database/:name_or_identity/call/:reducer — Invokes a reducer over HTTP using SATS-JSON arguments.

Source
call_reducer_bsatn(name_or_identity : String, reducer : String, args_bsatn : Bytes) : String

POST /v1/database/:name_or_identity/call/:reducer — Invokes a reducer over HTTP using BSATN binary arguments.

Source
create_identity

POST /v1/identity — Generates a new SpacetimeDB Identity and JWT token.

Source
create_websocket_token

POST /v1/identity/websocket-token — Generates a short-lived JWT for WebSocket URLs.

Source
custom_handler
Source
custom_handler=(custom_handler : RequestHandler | Nil)
Source
delete_database(name_or_identity : String) : Nil

DELETE /v1/database/:name_or_identity — Deletes/drops a database.

Source
get_database(name_or_identity : String) : JSON::Any

GET /v1/database/:name_or_identity — Retrieves JSON metadata about a database.

Source
get_database_identity(name_or_identity : String) : Identity

GET /v1/database/:name_or_identity/identity — Resolves a database name to its Identity.

Source
get_database_names(name_or_identity : String) : Array(String)

GET /v1/database/:name_or_identity/names — Lists all human-readable names for a database.

Source
list_databases(identity : Identity | String) : Array(Identity)

GET /v1/identity/:identity/databases — Lists all database identities owned by identity.

Source
logs(name_or_identity : String, num_lines : Int32 | Nil = nil) : String

GET /v1/database/:name_or_identity/logs — Fetches operational logs for a database.

Source
public_key

GET /v1/identity/public-key — Retrieves the host's PEM certificate chain for verifying tokens.

Source
publish_database(name_or_identity : String, wasm_bytes : Bytes, clear : Bool = false) : JSON::Any

PUT /v1/database/:name_or_identity — Publishes or updates a compiled WASM module binary.

Source
schema(name_or_identity : String, version : Int32 = 9) : Schema::ModuleSchema

GET /v1/database/:name_or_identity/schema?version=9 — Retrieves the parsed Schema::ModuleSchema.

Source
sql(name_or_identity : String, query : String | SQL) : Array(SqlStmtResult)

POST /v1/database/:name_or_identity/sql — Evaluates one or more SQL queries and returns typed SqlStmtResults.

Source
timeout
Source
timeout=(timeout : Time::Span)
Source
token
Source
token=(token : String | Nil)
Source
verify_identity(identity : Identity | String) : Bool

GET /v1/identity/:identity/verify — Verifies that the current bearer token matches identity.

Source

Nested types