Preview. This site is still being built. Features, prices and terms may change, and nothing here is a binding offer. Read the preview notice

Preview. Still being built; nothing here is a binding offer. Details

SDK

@kodkila/sdk is a typed fetch client for every route of the API. Paths, parameters, bodies and results are all checked by TypeScript.

Package
@kodkila/sdk 0.1.0
Download
kodkila-sdk-0.1.0.tgz
SHA-256
c8a9300cfb7b0ff98f4cc319662e3d49ea165736fd727c68d77d450ee8019ab5
Runtime dependencies
None. It uses the platform’s fetch.
Licence
Use is covered by the Developer Terms

Install

The package isn’t on the npm registry yet. Install it from this site:

Terminal
npm install https://kodkila.com/sdk/kodkila-sdk-0.1.0.tgz

It ships as TypeScript source, so your bundler compiles it with your app. In Next.js, add it to transpilePackages. In a Node script, run your code with tsx and set "type": "module". For type checking, use "moduleResolution": "bundler".

next.config.ts
const nextConfig = { transpilePackages: ["@kodkila/sdk"] };
export default nextConfig;

Create one client

lib/api.ts
import { createKodkilaClient } from "@kodkila/sdk";

export const api = createKodkilaClient({
  baseUrl: "https://api.intersink.com/v1",
  // In a browser, cookies are sent (credentials: "include" is the default).
  // In an app or on a server, hand over the access token instead:
  // getAccessToken: () => tokenFromSecureStorage(),
  // Headers sent on every request, such as your app key:
  // headers: { "X-App-Key": "kk_app_live_…" },
});

Always pass baseUrl. The client’s built-in default points at a production host that isn’t live yet. Use one client for the whole app, so there is one place for auth and errors.

Call a route

Write paths exactly as the OpenAPI document does, with the /api prefix. The client drops it when the base URL ends in /v1, and returns what the API put in data.

TypeScript
await api.post("/api/auth/request-otp", { body: { email } });

const products = await api.get("/api/products", {
  params: { query: { page: 1, limit: 20 } },
});

// Retry-safe writes: one Idempotency-Key per user action
await api.post("/api/orders", { body, idempotencyKey: crypto.randomUUID() });

// Uploads: pass FormData and let the runtime set the boundary
await api.post("/api/drive/files/upload", { body: formData });

Handle errors

TypeScript
import { ApiError } from "@kodkila/sdk";

try {
  await api.post("/api/auth/login-app", { body: { email, otp } });
} catch (e) {
  if (e instanceof ApiError) {
    e.statusCode; // HTTP status, 0 for a network failure
    e.code;       // the errorCode, such as "INVALID_CODE"
    e.message;    // the server's message
    e.errors;     // validation messages, or null
    e.requestId;  // quote it when you contact support
  }
}

The client throws ApiError for any status outside 2xx and for any body with success: false.

Types

TypeScript
import type { Schema, paths } from "@kodkila/sdk";

type LoginBody = Schema<"LoginOtpDto">; // { email: string; otp: string; ... }

Feature flags

The SDK includes a small helper that loads the flags for the current person and keeps them for the time the API allows:

TypeScript
import { createFeatureFlags } from "@kodkila/sdk";

const flags = createFeatureFlags(api, { appKey: "kk_app_live_…" });
await flags.load();
if (flags.isEnabled("checkout.new-flow")) {
  // show the new checkout
}

Without the SDK

Every route is plain HTTPS and JSON, so any language works. The API reference lists each route, and the OpenAPI file works with code generators.