JavaScript SDK
Package: @kataflax/sdk. Talks only to the data API (/api/p/:projectId/...). It does not manage orgs, schemas, or hosting — use the admin SDK or the console for that.
Requires Node 18+ or a browser with fetch.
import { KataflaxClient, KataflaxException } from '@kataflax/sdk';
const client = new KataflaxClient({ baseUrl: 'https://api.tefily.com', projectId: 'YOUR_PROJECT_ID',});
const auth = await client.auth.login({ password: 'password',});console.log(`Logged in as ${auth.user['email']}`);
const posts = client.collection('posts');
const created = await posts.create({ title: 'Hello World', status: 'draft',});
const all = await posts.list({ page: 1, pageSize: 20 });
const post = await posts.get(created['_id'] as string);await posts.update(post['_id'] as string, { title: 'Updated title' });await posts.delete(post['_id'] as string);
client.close();Inject fetch in tests:
const client = new KataflaxClient({ baseUrl: 'https://api.tefily.com', projectId: 'YOUR_PROJECT_ID', fetch: mockFetch,});setToken injects a platform JWT or PAT (bypasses rules). Prefer project login in client apps.
See Query and Files for filters and uploads.
Errors
Section titled “Errors”try { await client.collection('posts').get('nonexistent');} catch (e) { if (e instanceof KataflaxException) { console.log(e.statusCode, e.message, e.errors); }}