ichibase library
The official client-side SDK for ichibase — Postgres, MongoDB, Auth, and Realtime from Flutter, Dart server, or CLI.
Anon key only:
import 'package:ichibase/ichibase.dart';
final ichi = Ichibase.createClient(
'https://<project>.ichibase.net',
'ich_pub_…',
);
final res = await ichi.from('posts').select('*');
Classes
- Auth
-
Auth surface — signup/login plus session helpers. The Ichibase client
owns the live session; this talks to
/auth/*and reports changes back through the supplied callbacks. - Functions
-
Invoke your deployed Edge Functions without writing a raw request. Sets the
apikey, attaches the signed-in user's token, JSON-encodes the body, and returns an IchibaseResponse. - Ichibase
- The single client a Flutter/Dart app uses. Anon key only.
- IchibaseError
-
A structured error returned by the ichibase API. Mirrors the TypeScript
IchibaseErrorshape. -
IchibaseResponse<
T> -
Every call resolves to one of these:
dataon success,erroron failure. Check ok orerror == null. - MemorySessionStore
- In-memory adapter (default) — the session is lost when the process ends.
- Mongo
-
MongoDB data client. The project key goes in the
apikeyheader; the signed-in user's token (set via asUser) goes inAuthorization: Bearer, so your Mongo policy sees both. - MongoCollection
-
Operations on one collection. Every call POSTs to
/mongo/v1/<op>/<collection>. Reads/writes are gated by your Mongo policy. - Postgrest
-
Entry point for the database REST API. Get one via
ichi.from(table). - PostgrestQueryBuilder
-
A chainable PostgREST query. Awaiting it sends the request, so
await ichi.from('posts').select('*').eq('published', true)just works. The resolved IchibaseResponse.data is aList<dynamic>of rows, a single row for single/maybeSingle, or{rows, count}when count is set. - RealtimeClient
- One WebSocket per client, multiplexing many subscriptions. Reconnects and re-subscribes automatically. Speaks the ichibase realtime wire protocol.
- Session
- A signed-in user's session.
- SessionStore
-
Pluggable persistence for the auth session. The SDK keeps the session in
memory (so token reads are synchronous) and mirrors it here so it survives a
restart. Flutter apps pass an adapter backed by
shared_preferencesorflutter_secure_storage; pure-Dart/tests get MemorySessionStore. - Subscription
- A live subscription. Call unsubscribe to stop; on a broadcast channel use send to publish and track to update presence.
Enums
Functions
-
createClient(
String url, String anonKey, {Client? httpClient, SessionStore? store, String storageKey = 'ichibase.session'}) → Ichibase -
Create a client. Mirrors the TypeScript
createClient(url, anonKey).