Skip to content

JavaScript SDK

The JavaScript SDK provides a typed client for all SaaS Maker API endpoints.

Terminal window
npm install @saas-maker/sdk
import { SaaSMakerClient } from '@saas-maker/sdk';
const client = new SaaSMakerClient({
apiKey: 'pk_your_api_key',
baseUrl: 'https://saasmaker-api.sarthakagrawal927.workers.dev',
});
// Submit feedback
await client.feedback.submit({
title: 'Add dark mode',
description: 'Would love a dark mode option',
type: 'feature',
submitter_email: 'user@example.com',
});
// List feedback
const { data, total } = await client.feedback.list({
type: 'feature',
sort: 'upvotes',
page: 1,
});
// Add to waitlist
const entry = await client.waitlist.signup({
email: 'user@example.com',
name: 'Jane Doe',
});
console.log(`Position: #${entry.position}`);
// Submit a testimonial
await client.testimonials.submit({
author_name: 'Jane Doe',
author_email: 'jane@example.com',
content: 'SaaS Maker saved us weeks.',
rating: 5,
author_title: 'CTO at Acme',
});
// List approved testimonials
const testimonials = await client.testimonials.list();
// List published entries
const entries = await client.changelog.list();
// Create an index
const index = await client.indexes.create({
name: 'help-docs',
embedding_model: '@cf/baai/bge-base-en-v1.5',
});
// Upload a document
await client.indexes.ingest(index.id, {
content: 'Your document text here...',
metadata: { source: 'docs' },
});
// Search
const { results } = await client.indexes.search(index.id, {
query: 'how do I get started?',
top_k: 5,
});
// Track an event
await client.analytics.track({
name: 'page_view',
url: 'https://myapp.com/pricing',
});

All methods throw on non-2xx responses. Errors include the message field from the API:

try {
await client.feedback.submit({ ... });
} catch (err) {
console.error(err.message); // "Title is required"
}