Turso (turso v0.1.1)
View SourceElixir client library for Turso Cloud Platform API.
Turso provides a distributed SQLite database platform. This library implements a complete client for the Turso Platform API, allowing you to manage databases, groups, organizations, and more.
Usage
# Initialize a client
client = Turso.init(api_token, organization: "my-org")
# Create a database
{:ok, database} = Turso.create_database(client, "my-app-db", group: "production")
# List databases
{:ok, databases} = Turso.list_databases(client)See the individual modules for detailed documentation:
Turso.Databases- Database managementTurso.Groups- Group managementTurso.Organizations- Organization informationTurso.Locations- Location discoveryTurso.Tokens- API token managementTurso.AuditLogs- Audit log access
Summary
Functions
Creates a new database. See Turso.Databases.create/3.
Creates a database token. See Turso.Databases.create_token/3.
Creates a new group. See Turso.Groups.create/3.
Deletes a database. See Turso.Databases.delete/2.
Initialize a new Turso client.
Lists all databases for the organization. See Turso.Databases.list/2.
Lists all groups. See Turso.Groups.list/2.
Lists all available locations. See Turso.Locations.list/1.
Lists all organizations. See Turso.Organizations.list/1.
Retrieves a specific database. See Turso.Databases.retrieve/2.
Types
@type api_result(success_type) :: {:ok, success_type} | {:error, Turso.Error.t()}
@type database() :: map()
@type group() :: map()
@type location() :: map()
@type organization() :: map()
@type t() :: %Turso{ api_token: String.t(), base_url: String.t(), organization: String.t() | nil, req: Req.Request.t() }
@type token() :: map()
Functions
@spec create_database(t(), String.t(), keyword()) :: api_result(map())
Creates a new database. See Turso.Databases.create/3.
@spec create_database_token(t(), String.t(), keyword()) :: api_result(map())
Creates a database token. See Turso.Databases.create_token/3.
@spec create_group(t(), String.t(), keyword()) :: api_result(map())
Creates a new group. See Turso.Groups.create/3.
@spec delete_database(t(), String.t()) :: api_result(map())
Deletes a database. See Turso.Databases.delete/2.
Initialize a new Turso client.
Creates a client struct with the provided API token and options. The client contains a pre-configured Req HTTP client for making API requests.
Options
:organization(String.t/0) - Default organization slug for API calls. Can be overridden per function.:base_url(String.t/0) - Base URL for Turso API requests. The default value is"https://api.turso.tech/v1".:receive_timeout(timeout/0) - HTTP receive timeout in milliseconds. The default value is30000.
Examples
client = Turso.init("your-api-token")
client = Turso.init("your-api-token", organization: "my-org")Returns
A Turso.t() client struct ready for API operations.
@spec list_databases(t()) :: api_result(map())
Lists all databases for the organization. See Turso.Databases.list/2.
@spec list_groups(t()) :: api_result(map())
Lists all groups. See Turso.Groups.list/2.
@spec list_locations(t()) :: api_result([map()])
Lists all available locations. See Turso.Locations.list/1.
@spec list_organizations(t()) :: api_result(map())
Lists all organizations. See Turso.Organizations.list/1.
@spec retrieve_database(t(), String.t()) :: api_result(map())
Retrieves a specific database. See Turso.Databases.retrieve/2.