TypeScript SDK
@eminidatabase/sdk is the
official TypeScript client for the Astrabase API. Every method is a thin
wrapper around one API call — no hidden caching, no retries, no client-side
business logic — so it stays trivially easy to reason about and to keep in sync
with the API.
Install
npm install @eminidatabase/sdk
Usage
import { PlatformClient } from "@eminidatabase/sdk";
const client = new PlatformClient(); // defaults to https://api.astrabase.app/api/v1
await client.login("[email protected]", "a-strong-password");
const org = await client.createOrganization("Acme Inc.", "acme");
const project = await client.createProject(org.id, "Shop", "shop");
const accepted = await client.createDatabase(org.id, project.id, "production", "eu-west");
await client.waitForJob(accepted.job_id);
const database = await client.getDatabase(org.id, project.id, accepted.database.id);
console.log(database.status); // "running"
const connection = await client.getConnection(org.id, project.id, database.id);
console.log(connection.connection_string);
Pass a base URL explicitly to target a self-managed or staging instance:
const client = new PlatformClient("https://apidatabase.your-instance.example/api/v1");
Authentication
login() stores the returned token on the client instance and attaches it to
every subsequent request. You can also construct a client with a token you
already have (e.g. an API key, or a token restored
from storage):
const client = new PlatformClient(undefined, existingToken);
Error handling
Every non-2xx response throws an ApiError with the backend's real status code
and detail message:
import { ApiError } from "@eminidatabase/sdk";
try {
await client.createDatabase(org.id, project.id, "prod", "eu-west");
} catch (err) {
if (err instanceof ApiError) {
console.error(err.status, err.detail);
}
}
Types
Every response type is generated from the backend's own OpenAPI schema, so
DatabaseResponse, OrganizationResponse, WebhookResponse, and so on are all
importable and always match the live API surface exactly:
import type { DatabaseResponse, MembershipRole } from "@eminidatabase/sdk";
Source
The SDK is part of the Astrabase repository — MIT licensed.