JavaScript SDK
The JavaScript SDK provides a typed client for all SaaS Maker API endpoints.
Installation
Section titled “Installation”npm install @saas-maker/sdkimport { SaaSMakerClient } from '@saas-maker/sdk';
const client = new SaaSMakerClient({ apiKey: 'pk_your_api_key', baseUrl: 'https://saasmaker-api.sarthakagrawal927.workers.dev',});Feedback
Section titled “Feedback”// Submit feedbackawait client.feedback.submit({ title: 'Add dark mode', description: 'Would love a dark mode option', type: 'feature', submitter_email: 'user@example.com',});
// List feedbackconst { data, total } = await client.feedback.list({ type: 'feature', sort: 'upvotes', page: 1,});Waitlist
Section titled “Waitlist”// Add to waitlistconst entry = await client.waitlist.signup({ email: 'user@example.com', name: 'Jane Doe',});
console.log(`Position: #${entry.position}`);Testimonials
Section titled “Testimonials”// Submit a testimonialawait 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 testimonialsconst testimonials = await client.testimonials.list();Changelog
Section titled “Changelog”// List published entriesconst entries = await client.changelog.list();Knowledge Base
Section titled “Knowledge Base”// Create an indexconst index = await client.indexes.create({ name: 'help-docs', embedding_model: '@cf/baai/bge-base-en-v1.5',});
// Upload a documentawait client.indexes.ingest(index.id, { content: 'Your document text here...', metadata: { source: 'docs' },});
// Searchconst { results } = await client.indexes.search(index.id, { query: 'how do I get started?', top_k: 5,});Analytics
Section titled “Analytics”// Track an eventawait client.analytics.track({ name: 'page_view', url: 'https://myapp.com/pricing',});Error handling
Section titled “Error handling”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"}