Skip to content

Developer guide

The typed JavaScript SDK: @rapbooster/sdk

@rapbooster/sdk is a typed JavaScript and TypeScript client generated from the RapBooster API contract. It has no dependencies, runs in browsers and Node 18+, and gives you createRapBooster with store, CRM enquiry, HRMS and workspace helpers, raw typed calls to any endpoint, and verifyWebhook for signed webhooks.

Guide

Step by step

Install

The package is not on npm yet. Check the rapbooster repo out beside yours and depend on it with link: (the path is relative to your repo root):

package.json

{
  "dependencies": {
    "@rapbooster/sdk": "link:../rapbooster/sdks/js"
  }
}

Create a client

key is a publishable key in a browser or app, or a secret key on your server. buyerToken (or rb.setBuyerToken) adds the buyer's X-Buyer-Token to Store API calls. Each call answers { data } or { error: { code, message, details } } with the response.

TypeScript

import { createRapBooster } from "@rapbooster/sdk";

const rb = createRapBooster({
  key: process.env.RAPBOOSTER_KEY!,
  baseUrl: "https://api.rapbooster.com",
});

await rb.store.products.get("bikaneri-bhujia-400g");
await rb.store.me.subscriptions.pause("5");
await rb.crm.enquiries.create({
  kind: "contact",
  name: "Asha",
  phone: "+919876543210",
  message: "Please call me back.",
  consent: true,
});
await rb.workspace.profile();

// Any endpoint of the contract, typed by path:
await rb.GET("/api/v1/public/v1/store/categories");

Types and downloads

Request bodies, queries and answers are typed from schema.d.ts, so a wrong field fails at compile time. The OpenAPI document, the Postman collection and a standard-library Python client are on the Developers page.