@rekaz-io/platform-api
v0.2.1
Published
Official TypeScript SDK for the Rekaz merchant Platform API
Downloads
845
Readme
Rekaz Platform API SDK
TypeScript SDK for building merchant applications and integrations with Rekaz.
Installation
pnpm add @rekaz-io/platform-apiRequires Node.js 18 or later when used in Node.js. The package provides ES modules and TypeScript declarations.
Getting started
import { createPlatformApiClient, isRekazProblemDetails } from "@rekaz-io/platform-api";
const rekaz = createPlatformApiClient({ accessToken: process.env.REKAZ_API_TOKEN! });
const { data, error } = await rekaz.orders.list({
query: { limit: 20 },
});
if (error) {
throw new Error(isRekazProblemDetails(error) ? error.detail : "The request failed.");
}
console.log(data?.items);Authentication and configuration
Use an API access token with the capabilities required by your integration. Keep merchant credentials on your server.
accessToken accepts a token string or a function returning a token, including an
async function. The provider is called for each request, so it can supply refreshed
credentials.
The default API URL is https://api.rekaz.io. Client options also accept baseUrl,
headers, and a custom fetch implementation.
Pagination
List operations that support cursor pagination accept query.limit and
query.cursor. Pass the response’s nextCursor unchanged to fetch the next page,
keeping the same filters and sort order. A null cursor marks the end of the list.
Set query.includeTotal to true when you need the total count.
Error handling
Requests return data, error, request, and response fields by default. Check
error before using data. Pass throwOnError: true to an operation to throw on
failure instead. Network failures can also occur without an API response.
The root package exports isRekazProblemDetails for inspecting wire errors. Import
REKAZ_ERRORS and isRekazErrorCode from @rekaz-io/platform-api/catalog only
when you need the complete error catalog. The same subpath exports
REKAZ_OPERATIONS for capability, principal, and idempotency metadata.
Idempotency
Operations that require an Idempotency-Key document it in their request headers.
Use the exported createIdempotencyKey() helper to generate a key for each new
operation, and reuse that key when retrying the same request.
License
See LICENSE for usage terms.
