Official JavaScript and TypeScript client library for the Rasepi API.
Works with Node.js 18+, Deno, Bun, and modern browsers (uses native fetch).
npm install @rasepihq/rasepi-js
# or
yarn add @rasepihq/rasepi-js
# or
pnpm add @rasepihq/rasepi-jsimport { RasepiClient } from "@rasepihq/rasepi-js";
const client = new RasepiClient({
baseUrl: "https://api.rasepi.com",
accessToken: "your-access-token",
});
// List hubs
const hubs = await client.hubs.list();
console.log(hubs);
// Create an entry
const entry = await client.entries.create("hub-id", {
title: "Getting Started",
content: { type: "doc", content: [] },
expiresAt: "2026-12-31T00:00:00Z",
});// 1. Get the login URL
const loginUrl = client.auth.getLoginUrl("google", "https://yourapp.com/callback");
// 2. After provider callback, exchange the one-time code
const tokens = await client.auth.exchangeCode(code);
// 3. Create a new client with the tokens
const authedClient = new RasepiClient({
baseUrl: "https://api.rasepi.com",
accessToken: tokens.access_token,
refreshToken: tokens.refresh_token,
onTokenRefreshed: (access, refresh) => {
// Persist the new tokens
saveTokens(access, refresh);
},
});const client = new RasepiClient({
baseUrl: "http://localhost:5000",
devToken: "dev-token-{tenantId}:{userId}",
});- Zero dependencies — uses native
fetch(Node 18+) - Full TypeScript support — complete type definitions
- Automatic token refresh — handles 401 → refresh → retry
- Retry with backoff — retries 429 and 5xx errors
- Configurable timeout — default 30 seconds
| Resource | Description |
|---|---|
client.auth |
OAuth login, code exchange, token refresh |
client.hubs |
Hub CRUD, members |
client.entries |
Entry CRUD, permissions |
client.translations |
Block-level translations, stale detection |
client.analytics |
Hub/entry analytics, events, time spent |
client.ai |
AI search, conversations |
client.portal |
Public portal feed, topics, content |
client.sharing |
Share links management |
client.expiryTemplates |
Expiry template CRUD |
client.tags |
Hub tags |
client.categories |
Hub categories |
client.glossaries |
Hub glossary terms |
client.languages |
Available languages, hub language config |
client.plugins |
Plugin management and configuration |
client.users |
User management, preferences |
client.groups |
Group CRUD, members |
client.notifications |
Notification management |
client.freshness |
Content freshness scores, expiry tracking |
client.billing |
Subscription, usage, invoices |
// List translations for an entry
const translations = await client.translations.list("entry-id");
// Get stale blocks that need retranslation
const stale = await client.translations.getStaleBlocks("entry-id", "de");
// Mark translation as up to date
await client.translations.markUpToDate("entry-id", "de");// Get entries expiring within 30 days
const expiring = await client.freshness.getExpiring("hub-id", 30);
// Renew an entry
await client.freshness.renew("entry-id", {
newExpiresAt: "2027-06-30T00:00:00Z",
reason: "Content reviewed and updated",
});const results = await client.ai.search("hub-id", "deployment guide");
console.log(results);import { RasepiApiError } from "@rasepihq/rasepi-js";
try {
await client.hubs.get("non-existent-id");
} catch (error) {
if (error instanceof RasepiApiError) {
console.error(`API error ${error.statusCode}: ${error.message}`);
console.error("Response:", error.responseBody);
}
}const client = new RasepiClient({
baseUrl: "https://api.rasepi.com", // Required
accessToken: "...", // JWT access token
refreshToken: "...", // For automatic renewal
devToken: "...", // Dev-only token
timeout: 30000, // Request timeout (ms)
maxRetries: 3, // Retry attempts for 429/5xx
onTokenRefreshed: (access, refresh) => {
// Called when tokens are auto-refreshed
},
});MIT — see LICENSE.