Node.js
Official Node.js and TypeScript SDK for the Zernio API. Install @zernio/node and publish to 14+ social platforms with fully typed requests and responses.
The official Node.js SDK for the Zernio API, with full TypeScript types for every request and response. Requires Node.js 18+.
- Package:
@zernio/nodeon npm - Source: github.com/zernio-dev/zernio-node
Install
npm install @zernio/nodeQuick start
import Zernio from '@zernio/node';
const zernio = new Zernio(); // Uses ZERNIO_API_KEY env var
// Publish to multiple platforms with one call
const { data } = await zernio.posts.createPost({
body: {
content: 'Hello world from Zernio!',
platforms: [
{ platform: 'twitter', accountId: 'acc_xxx' },
{ platform: 'linkedin', accountId: 'acc_yyy' },
{ platform: 'instagram', accountId: 'acc_zzz' },
],
publishNow: true,
},
});
console.log(`Published to ${data.post.platforms.length} platforms!`);Get your API key from the dashboard, or see Getting started for the full setup walkthrough.
Configuration
const zernio = new Zernio({
apiKey: 'your-api-key', // Defaults to process.env['ZERNIO_API_KEY']
baseURL: 'https://zernio.com/api',
timeout: 60000,
});Examples
Schedule a post
const { data } = await zernio.posts.createPost({
body: {
content: 'This post will go live tomorrow at 10am',
platforms: [{ platform: 'instagram', accountId: 'acc_xxx' }],
scheduledFor: '2025-02-01T10:00:00Z',
},
});Platform-specific content
Customize content per platform while posting to all at once:
const { data } = await zernio.posts.createPost({
body: {
content: 'Default content',
platforms: [
{
platform: 'twitter',
accountId: 'acc_twitter',
customContent: 'Short & punchy for X',
},
{
platform: 'linkedin',
accountId: 'acc_linkedin',
customContent: 'Professional tone for LinkedIn with more detail.',
},
],
publishNow: true,
},
});Upload media
// 1. Get presigned upload URL
const { data: presign } = await zernio.media.getMediaPresignedUrl({
body: { filename: 'video.mp4', contentType: 'video/mp4' },
});
// 2. Upload your file
await fetch(presign.uploadUrl, {
method: 'PUT',
body: videoBuffer,
headers: { 'Content-Type': 'video/mp4' },
});
// 3. Create post with media
const { data } = await zernio.posts.createPost({
body: {
content: 'Check out this video!',
mediaItems: [{ url: presign.publicUrl, type: 'video' }],
platforms: [
{ platform: 'tiktok', accountId: 'acc_xxx' },
{
platform: 'youtube',
accountId: 'acc_yyy',
platformSpecificData: { title: 'My Video' },
},
],
publishNow: true,
},
});See the media uploads guide for size limits and per-platform requirements.
Get analytics
const { data } = await zernio.analytics.getAnalytics({
query: { postId: 'post_xxx' },
});
console.log('Views:', data.analytics.views);
console.log('Likes:', data.analytics.likes);
console.log('Engagement Rate:', data.analytics.engagementRate);List connected accounts
const { data } = await zernio.accounts.listAccounts();
for (const account of data.accounts) {
console.log(`${account.platform}: @${account.username}`);
}Error handling
The SDK throws typed errors you can catch and branch on:
import Zernio, { ZernioApiError, RateLimitError, ValidationError } from '@zernio/node';
try {
await zernio.posts.createPost({ body: { /* ... */ } });
} catch (error) {
if (error instanceof RateLimitError) {
console.log(`Rate limited. Retry in ${error.getSecondsUntilReset()}s`);
} else if (error instanceof ValidationError) {
console.log('Invalid request:', error.fields);
} else if (error instanceof ZernioApiError) {
console.log(`Error ${error.statusCode}: ${error.message}`);
}
}See the error handling guide for the API's error codes and retry semantics.
Full reference
The SDK exposes every API namespace: posts, accounts, profiles, analytics, queue, media, webhooks, messages, comments, broadcasts, ads, phoneNumbers, whatsapp, workflows, and more. Each method maps 1:1 to an API Reference operation.