@faqapp/core
The TypeScript SDK. Wraps the v1 API with a typed client. Runs in Node, Bun, Deno, edge runtimes, and the browser.
Updated 2026-10-11
bun add @faqapp/core
@faqapp/core is a TypeScript client built on fetch. It validates responses, retries transient failures with backoff, and throws typed errors.
Create a client
import { createFAQClient } from "@faqapp/core";
const faq = createFAQClient({
apiKey: process.env.FAQAPP_API_KEY,
organizationSlug: "acme"
});
With no options, the client reads FAQAPP_API_KEY and FAQAPP_ORG_SLUG from the environment. apiKey also accepts a function that returns string | Promise<string>, for credentials you refresh per request. Pass baseUrl or fetch to override the defaults.
Resources
Questions and categories are addressed by slug. Lists return a page you can await or iterate.
const { data: created } = await faq.questions.create({
question: "How do I rotate an API key?",
answer: "Create a new key, swap it in your environment, then revoke the old one.",
categorySlug: "security",
published: true
});
await faq.questions.get(created.slug);
await faq.questions.update(created.slug, { answer: "Updated answer" });
await faq.questions.list({ status: "published", limit: 20 });
await faq.questions.delete(created.slug);
await faq.categories.list();
await faq.categories.create({ name: "Billing", slug: "billing" });
const { data: key } = await faq.apiKeys.create({ name: "CI", scopes: ["read"] });
console.log(key.key);
await faq.apiKeys.list();
await faq.apiKeys.revoke(key.id);
await faq.translations.list("questions", "reset-password");
await faq.translations.create("questions", "reset-password", "tr", {
question: "Şifremi nasıl sıfırlarım?",
answer: "Ayarlar sayfasını açın."
});
await faq.translations.upsert("questions", "reset-password", "tr", { publishedAt: new Date().toISOString() });
const drafts = await faq.translations.drafts({ limit: 50 });
const firstDraft = drafts.data[0];
if (firstDraft) await faq.translations.publish(firstDraft.id);
const { data: answer } = await faq.answers.ask({ question: "What is included in the free plan?" });
console.log(answer.status, answer.answer, answer.sources.length);
answers.ask returns status ("answered" or "not_covered"), the answer text or null, and the sources it used.
Errors
The SDK throws on any non-2xx response. Match on the error class, then on code for detail:
import { FAQAPIError, FAQNotFoundError } from "@faqapp/core";
try {
await faq.questions.get("does-not-exist");
} catch (err) {
if (err instanceof FAQNotFoundError) {
console.log("No such question");
} else if (err instanceof FAQAPIError) {
console.error(err.status, err.code, err.message, err.requestId);
} else {
throw err;
}
}
See Errors for every class and code.
Pagination
Lists are page-numbered. Await a list for one page, or iterate it to walk every page:
const page = await faq.questions.list({ limit: 50 });
console.log(page.data.length, page.pagination.total, page.pagination.pages);
if (page.hasNextPage()) await page.getNextPage();
for await (const question of faq.questions.list({ limit: 100 }).iter()) {
console.log(question.slug);
}
TypeScript
Response types come from the OpenAPI spec. Import them by name:
import type { ApiKey, Category, Organization, Question, Translation } from "@faqapp/core";
export function heading(question: Question, category: Category | null): string {
return category ? `${category.name}: ${question.question}` : question.question;
}
export type Records = [ApiKey, Organization, Translation];
React
For React, use @faqapp/react. It wraps @faqapp/core with FAQClientProvider and client-side hooks for search, published FAQs, and questions.