Misar IO Docs

TypeScript / JavaScript

Official JS/TS SDK for MisarSocial — schedule posts, generate AI content, manage drafts, and track trends.

Installation

pnpm add @misar/social-sdk
# or
npm install @misar/social-sdk

Requires Node.js 18+ or any runtime with native fetch.

Configuration

import { MisarSocialClient } from "@misar/social-sdk";

const client = new MisarSocialClient({
  apiKey: process.env.MISARSOCIAL_API_KEY!,
  baseUrl: "https://api.misar.io/social", // optional override
  timeout: 30_000,                         // optional, default 30 s
});

Add the API key to your environment:

MISARSOCIAL_API_KEY=mss_your_key_here

Available Methods

MethodDescription
client.posts.list(params?)List paginated posts with optional status filter
client.posts.get(id)Get a single post by ID
client.posts.edit(id, patch)Edit content, schedule time, or first comment
client.posts.cancel(id)Cancel a pending or queued post by ID
client.posts.cancelByBody(postId)Cancel using request body (legacy)
client.drafts.list()List draft and pending-review variants
client.drafts.bulkAction(action, ids)Approve or reject multiple drafts
client.schedule(request)Schedule a post to a connected account
client.connections.list()List active connected social accounts
client.generate(request)Generate AI post variants
client.generate.enhance(request)Enhance existing text
client.generate.hashtags(request)Generate hashtags for text
client.generate.optimize(request)Optimize text for a platform
client.stats.dashboard()Get dashboard overview stats
client.trendpulse.trends()Get latest trend snapshots
client.trendpulse.pipeline(snapshotIds)Generate drafts from trend snapshots
client.contentripple.usage()Get monthly repurpose usage
client.contentripple.repurpose(request)Repurpose a URL or text into post variants

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.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/social",
});

console.log(post.id, post.status); // queued

Generate and schedule

// Step 1: generate variants
const { variants } = await client.generate({
  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.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`);
const { trends, source } = await client.trendpulse.trends();
console.log(`Loaded ${trends.length} trends from ${source}`);

// Generate content from the top 3 trends
const topIds = trends.slice(0, 3).map((t) => t.id);
const { queued } = await client.trendpulse.pipeline(topIds);
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 { MisarSocialAPIError } from "@misar/social-sdk";

try {
  await client.schedule({ /* ... */ });
} catch (err) {
  if (err instanceof MisarSocialAPIError) {
    console.error(err.statusCode, err.message);
    if (err.statusCode === 422) {
      console.error("Safety gate:", err.reason);
    }
    if (err.statusCode === 402) {
      console.error("Plan limit reached. Upgrade required.");
    }
  }
}