Dart SDK - Installation#

rafikidb is a typed client for the RafikiDB API: data, auth, realtime, storage, environment variables, secrets, webhooks, edge functions and payments.

  • Pure Dart - works in Flutter, Dart servers and CLI apps
  • Typed Envelope<T> responses and RafikiDBError failures
  • WebSocket (Centrifugo) + SSE realtime with auto-reconnect
  • Pluggable session persistence (FileSessionStore or your own)

Install#

dart pub add rafikidb

# or, in a Flutter app
flutter pub add rafikidb
Bash

Initialize#

import 'package:rafikidb/rafikidb.dart';

final db = RafikiDB(
  projectId: '5c73dab0-...',
  apiKey: 'raf_live_...',
  baseUrl: 'https://api.rafikidb.com/api/v1', // optional
  persistSession: true, // optional: survive restarts
);
DART
OptionTypeDescription
projectIdStringRequired. Used by auth/realtime URLs
apiKeyStringRequired. Sent as X-AFRIBASE-API-Key
baseUrlStringDefault http://localhost:8080/api/v1
accessTokenString?Optional platform JWT
persistSessionboolPersist the project-user session (file store by default)
sessionStoreSessionStore?Custom persistence backend (e.g. shared_preferences)
httpClienthttp.Client?Custom HTTP client

Responses#

Every method returns the API envelope unchanged:

final rows = await db.from('profiles').select('id').limit(10).execute();
rows.success; // true
rows.message; // "Request was successful"
rows.data;    // List<Map<String, dynamic>>?
rows.errors;  // List<String>?
DART

Failures throw RafikiDBError:

try {
  await db.from('profiles').insert({});
} on RafikiDBError catch (error) {
  error.message; // "Nationality is required"
  error.status;  // 400
  error.code;    // RafikiDBErrorCode.invalidInput
  error.errors;  // ["Nationality is required"]
}
DART

Next: Data.