Skip to content

@faqapp/core

The TypeScript SDK. Wraps every v1 endpoint with a typed client. Runs in Node, Bun, Deno, edge, browser.

Updated 2026-05-19

bun add @faqapp/core

@faqapp/core is a single dependency-free TypeScript client. It uses fetch (native everywhere modern), Zod-style response shapes, and one factory function.

Create a client

import { createFAQClient } from "@faqapp/core";

const faq = createFAQClient({
  apiKey: process.env.FAQAPP_API_KEY!,
  organizationSlug: "acme",
  // Optional overrides:
  // baseUrl: "https://api.thefaq.app",
  // fetch: customFetch,
});

apiKey can be a string or a function returning string | Promise<string> — useful for refreshing JWTs per request (as the dashboard does with its 15-min HS256 token).

Resources

Every resource follows the same shape: list, get, create, update, delete. Pagination on lists via limit and cursor.

// Questions
await faq.questions.list({ limit: 20 });
await faq.questions.get("q_8X3F");
await faq.questions.create({ title: "How do I rotate keys?", answer: "..." });
await faq.questions.update("q_8X3F", { answer: "Updated answer" });
await faq.questions.delete("q_8X3F");

// Categories
await faq.categories.list();
await faq.categories.create({ name: "Billing", slug: "billing" });

// API keys
await faq.apiKeys.list();
await faq.apiKeys.create({ scope: "read" });

// Translations
await faq.translations.list("q_8X3F");
await faq.translations.create("q_8X3F", { language: "tr", title: "...", answer: "..." });

Errors

The SDK throws on non-2xx. The error has status, code, message, and details:

try {
  await faq.questions.get("does-not-exist");
} catch (err) {
  if (err.code === "question_not_found") {
    // handle 404 specifically
  }
  throw err;
}

Response envelope

Every successful response is { data, meta? }:

const { data, meta } = await faq.questions.list({ limit: 50 });
// data: Question[]
// meta.pagination: { limit: 50, cursor: "..." | null, hasMore: true }

TypeScript

Types are inferred from the OpenAPI spec at build time. No any. Importable resource types:

import type {
  Question,
  Category,
  ApiKey,
  Translation,
  Organization
} from "@faqapp/core";

React?

For React hooks + SSR helpers, use @faqapp/react. It wraps @faqapp/core and adds useFaq, FAQClientProvider, and prefetch utilities.