Skip to content

@kite-01/sdk

@kite-01/sdk calls your Kite server from your backend. Every operation in the API Reference is a typed method, generated from the server’s OpenAPI spec, and every request is signed for you.

Terminal window
npm install @kite-01/sdk

It runs on Node 20+, Bun, Deno and edge runtimes, signing with Web Crypto. It refuses to run in a browser: it holds secret keys.

With an API key:

import { Kite } from "@kite-01/sdk";
export const kite = new Kite({
baseUrl: "https://pay.example.com",
auth: {
apiKeyId: process.env.KITE_API_KEY_ID!,
privateKey: process.env.KITE_PRIVATE_KEY!,
},
});

Or with the root key, optionally acting as one app:

const admin = new Kite({
baseUrl: "https://pay.example.com",
auth: { rootKey: process.env.KITE_ROOT_KEY!, appId },
});

fetch can be passed in too, for tests or custom agents.

Operations are grouped as kite.<group>.<action>, named after the API’s operation IDs: kite.paymentLinks.create, kite.transfers.get, kite.customers.upsert and so on. Path parameters go in path, query parameters in query and the JSON body in body. Each call returns { data, request, response }.

const { data: link } = await kite.paymentLinks.create({
body: {
title: "Team starter pack",
currency: "USD",
amount: "129",
lineItems: [
{ name: "Team seat", price: "39", quantity: 3 },
{ name: "Onboarding call", price: "12", quantity: 1 },
],
reference: order.id,
meta: { cart: cart.id },
},
});
const { data: page } = await kite.transfers.list({
query: { status: "Settled", page: 1 },
});
const { data: transfer } = await kite.transfers.get({
path: { id: transferId },
});

Types for every request and response are exported too:

import type { PaymentLink, TransferDetails } from "@kite-01/sdk";

A failed call throws a KiteError with the HTTP status, Kite’s error code and its message. If no response came back, status is undefined and code is NetworkError.

import { KiteError } from "@kite-01/sdk";
try {
await kite.paymentLinks.create({ body });
} catch (error) {
if (error instanceof KiteError && error.code === "Conflict") {
// a link with this reference already exists
}
throw error;
}

Common codes: Unauthorized (401), Forbidden (403), NotFound (404), Conflict and PreconditionFailed (409), ValidationError (422).

The SDK also verifies webhook deliveries; see Webhooks.

import { verifyWebhook } from "@kite-01/sdk";

The SDK’s version follows its own releases. Each is generated from a Kite server spec; if your server is older than the SDK, a method for an endpoint your server doesn’t have returns 404. Your server’s API reference shows the endpoints it has.