SDKs
TypeScript / JavaScript
Official JS/TS SDK for MisarPost — schedule posts, generate AI content, manage drafts, and track trends.
Installation
pnpm add @misar/post-sdk
# or
npm install @misar/post-sdkRequires Node.js 18+ or any runtime with native fetch.
Configuration
import { MisarPostClient } from "@misar/post-sdk";
// The API key is the first positional argument; options are the second.
const client = new MisarPostClient(process.env.MISARPOST_API_KEY!, {
baseURL: "https://api.misar.io/post", // optional override
timeoutMs: 30_000, // optional, default 30 s
maxRetries: 2, // optional
});Add the API key to your environment:
MISARPOST_API_KEY=msk_your_key_hereAvailable Methods
| Method | Description |
|---|---|
client.connections.list() | List active connected social accounts |
client.connections.stats() | Get dashboard overview stats |
client.posts.list(params?) | List paginated posts with optional status filter |
client.posts.update(id, body) | Edit content, schedule time, or first comment |
client.posts.cancel(id) | Cancel a pending or queued post by ID |
client.posts.schedule(params) | Schedule a post to a connected account |
client.drafts.list() | List draft and pending-review variants |
client.drafts.bulkAction(action, ids) | Approve or reject multiple drafts |
client.generate.posts(params) | Generate AI post variants |
client.generate.enhance(params) | Turn a raw topic into a content brief |
client.generate.plan(params) | Generate hooks, time slots, and hashtags |
client.generate.optimize(params?) | Get optimization insights from recent performance |
client.generate.hashtags(params) | Generate a tiered hashtag strategy |
client.analytics.calendar(params?) | List scheduled posts for the content calendar |
client.analytics.trends() | Get latest trend snapshots |
client.analytics.queueTrendDrafts(params) | Generate drafts from trend snapshots |
client.contentripple.usage() | Get monthly repurpose usage |
client.contentripple.repurpose(params) | Repurpose a URL or text into post variants |
client.contentripple.updateVariant(params) | Edit a generated content variant |
client.contentripple.schedule(params) | Schedule a content variant to an account |
Examples
List queued posts
const { posts, total, totalPages } = await client.posts.list({
status: "queued",
page: 1,
});
console.log(`${total} queued posts across ${totalPages} pages`);Schedule a post
const post = await client.posts.schedule({
connectedAccountId: "550e8400-e29b-41d4-a716-446655440000",
platform: "twitter",
contentText: "Excited to share our new TypeScript SDK! #OpenSource",
scheduledAt: "2026-05-22T10:00:00+05:30",
firstComment: "Full docs at docs.misar.io/post",
});
console.log(post.id, post.status); // queuedGenerate and schedule
// Step 1: generate variants
const { variants } = await client.generate.posts({
topic: "Our new feature: real-time collaboration",
platforms: ["twitter", "linkedin"],
tone: "professional",
count: 3,
});
// Step 2: pick a variant and schedule it
const twitterVariants = variants.find((v) => v.platform === "twitter");
const chosen = twitterVariants?.variants[0];
if (chosen) {
await client.posts.schedule({
connectedAccountId: "550e8400-...",
platform: "twitter",
contentText: `${chosen.caption} ${chosen.hashtags.map((h) => `#${h}`).join(" ")}`,
scheduledAt: "2026-05-23T09:00:00Z",
});
}Bulk approve drafts
const { drafts } = await client.drafts.list();
const draftIds = drafts.map((d) => d.id);
const { updated } = await client.drafts.bulkAction("approve", draftIds);
console.log(`Approved ${updated} drafts`);Get trending topics
const { trends, source } = await client.analytics.trends();
console.log(`Loaded ${trends.length} trends from ${source}`);
// Generate content from the top 3 trends
const snapshotIds = trends.slice(0, 3).map((t) => t.id);
const { queued } = await client.analytics.queueTrendDrafts({ snapshotIds });
console.log(`Created ${queued.length} draft variants from trends`);Repurpose a URL
const { source, variants } = await client.contentripple.repurpose({
sourceType: "url",
sourceUrl: "https://yoursite.com/blog/new-feature",
platforms: ["twitter", "linkedin", "instagram"],
tone: "casual",
});
console.log(`Repurposed into ${variants.length} platform variants`);Error Handling
import { MisarPostError, MisarPostNetworkError } from "@misar/post-sdk";
try {
await client.posts.schedule({ /* ... */ });
} catch (err) {
if (err instanceof MisarPostError) {
console.error(err.status, err.message);
if (err.status === 422) {
console.error("Post blocked by safety rules:", err.message);
}
if (err.status === 402) {
console.error("Plan limit reached. Upgrade required.");
}
} else if (err instanceof MisarPostNetworkError) {
console.error("Network error reaching MisarPost:", err.message);
}
}MisarPostError exposes status (the HTTP status code) and message. Transport-level failures (timeouts, DNS, connection resets) throw MisarPostNetworkError instead.