Late Node.js Library

The official Node.js library for the Late API - schedule social media posts across Instagram, TikTok, YouTube, LinkedIn, X/Twitter, Facebook, Pinterest, Threads, and more.
Installation
npm install @getlatedev/node
Usage
import Late from '@getlatedev/node';
const late = new Late({
apiKey: process.env['LATE_API_KEY'],
});
async function main() {
const post = await late.posts.create({
body: {
content: 'Hello from the Late SDK! 🚀',
platforms: [
{ platform: 'twitter', accountId: 'acc_xxx' },
{ platform: 'linkedin', accountId: 'acc_yyy' },
],
publishNow: true,
},
});
console.log(post.data);
}
main();
Configuration
The client can be configured with the following options:
const late = new Late({
apiKey: 'sk_...',
baseURL: 'https://getlate.dev/api',
timeout: 60000,
defaultHeaders: {
'X-Custom-Header': 'value',
},
});
Examples
Schedule a Post
const post = await late.posts.create({
body: {
content: 'Scheduled post from the SDK',
platforms: [{ platform: 'instagram', accountId: 'acc_xxx' }],
scheduledFor: new Date('2025-02-01T10:00:00Z').toISOString(),
},
});
Multi-Platform with Platform-Specific Content
const post = await late.posts.create({
body: {
content: 'Default content for all platforms',
platforms: [
{
platform: 'twitter',
accountId: 'acc_twitter',
platformSpecificContent: 'Shorter content for X #hashtags',
},
{
platform: 'linkedin',
accountId: 'acc_linkedin',
platformSpecificContent: 'Professional content for LinkedIn',
},
],
publishNow: true,
},
});
List Posts
const { data } = await late.posts.list({
query: {
status: 'scheduled',
limit: 20,
},
});
for (const post of data.posts) {
console.log(post.content, post.scheduledFor);
}
Upload Media
const { data: presign } = await late.media.getPresignedUrl({
body: {
filename: 'image.jpg',
contentType: 'image/jpeg',
},
});
await fetch(presign.uploadUrl, {
method: 'PUT',
body: imageBuffer,
headers: { 'Content-Type': 'image/jpeg' },
});
await late.posts.create({
body: {
content: 'Post with image',
mediaUrls: [presign.publicUrl],
platforms: [{ platform: 'instagram', accountId: 'acc_xxx' }],
publishNow: true,
},
});
Get Analytics
const { data: analytics } = await late.analytics.get({
query: { postId: 'post_xxx' },
});
console.log('Impressions:', analytics.analytics.impressions);
console.log('Engagement:', analytics.analytics.engagementRate);
List Connected Accounts
const { data } = await late.accounts.list();
for (const account of data.accounts) {
console.log(`${account.platform}: @${account.username}`);
}
Configure Webhooks
await late.webhooks.updateSettings({
body: {
url: 'https://your-app.com/webhooks/late',
events: ['post.published', 'post.failed', 'account.disconnected'],
secret: 'your-webhook-secret',
},
});
Error Handling
import Late, { LateApiError, RateLimitError, ValidationError } from '@getlatedev/node';
const late = new Late();
try {
await late.posts.create({ body: { ... } });
} catch (error) {
if (error instanceof RateLimitError) {
console.log(`Rate limited. Retry in ${error.getSecondsUntilReset()} seconds`);
} else if (error instanceof ValidationError) {
console.log('Validation errors:', error.fields);
} else if (error instanceof LateApiError) {
console.log(`API error ${error.statusCode}: ${error.message}`);
}
}
API Reference
Posts
posts.list(params) | List posts |
posts.create(params) | Create a post |
posts.get(params) | Get a post |
posts.update(params) | Update a post |
posts.delete(params) | Delete a post |
posts.retry(params) | Retry a failed post |
posts.bulkUpload(params) | Upload multiple posts |
Accounts
accounts.list() | List connected accounts |
accounts.update(params) | Update an account |
accounts.delete(params) | Disconnect an account |
accounts.getFollowerStats() | Get follower statistics |
accounts.getAllHealth() | Get health for all accounts |
Analytics
analytics.get(params) | Get post analytics |
analytics.getYouTubeDailyViews(params) | Get YouTube daily views |
analytics.getLinkedInAggregate(params) | Get LinkedIn org analytics |
See the API documentation for all available methods.
Requirements
- Node.js 18 or later
- An API key from Late
License
Apache-2.0