SDK

Use the TypeScript SDK to interact with EmuView collections, auth, files, and real-time from any JS runtime.

#SDK

The EmuView SDK is a TypeScript client that wraps every REST API endpoint into typed method calls. It has zero dependencies and works in any JavaScript runtime — browsers, Node.js, Deno, and Cloudflare Workers.

#What you can do

Feature SDK method HTTP equivalent
List records sdk.collection('posts').list({...}) GET /api/v1/collections/posts/records
Create a record sdk.collection('posts').create({...}) POST /api/v1/collections/posts/records
Update a record sdk.collection('posts').update(id, {...}) PATCH /api/v1/collections/posts/records/:id
Delete a record sdk.collection('posts').delete(id) DELETE /api/v1/collections/posts/records/:id
Sign in sdk.auth.signIn({...}) POST /api/auth/sign-in/email
Upload a file sdk.files.upload(file, {...}) Three-step presigned URL flow
Subscribe to changes sdk.collection('posts').subscribe({...}) GET /api/v1/collections/posts/stream (SSE)
Run an automation flow sdk.automate.executeFlow(id, {...}) POST /api/v1/automate/flows/:id/execute
Read your notifications sdk.messages.inbox() GET /api/v1/messages/inbox
Check a delivery sdk.messages.get(id) GET /api/v1/messages/:id

#Quick start

import { EmuView } from '@emuview/sdk';

const sdk = new EmuView({
	url: 'https://your-api.example.com',
	auth: { apiKey: 'sk-your-api-key' }
});

// List published products
const results = await sdk.collection('products').list({
	filter: { status: 'published' },
	sortBy: '-created_at',
	limit: 25
});

console.log(`Found ${results.total} products`);

#Key concepts

Concept What it means
SDK singleton Create one SvelteSync instance and reuse it across your app
Collection handle sdk.collection('name') returns an object with CRUD methods for that collection
Auth state The SDK stores session tokens automatically after signIn(). Future calls include the token
Error handling The SDK throws ApiError with code, status, message, and details properties

#SDK vs raw fetch

The SDK is optional. Every SDK method maps to a REST endpoint, and you can use fetch directly for any operation. The SDK provides:

  • Type-safe method signatures
  • Automatic session token management
  • Convenience methods (e.g., upload() wraps the three-step file upload flow)
  • Structured error objects (ApiError)

#Guides in this section