@posty5/social-publisher-post 3.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,957 +1,928 @@
1
- # @posty5/social-publisher-post
2
-
3
- Official Posty5 SDK for managing social media publishing posts. Publish videos to YouTube Shorts, TikTok, Facebook Reels, and Instagram Reels with a unified, developer-friendly API.
4
-
5
- ---
6
-
7
- ## 🌟 What is Posty5?
8
-
9
- **Posty5** is a comprehensive suite of free online tools designed to enhance your digital marketing and social media presence. With over 4+ powerful tools and counting, Posty5 provides everything you need to:
10
-
11
- - 🔗 **Shorten URLs** - Create memorable, trackable short links
12
- - 📱 **Generate QR Codes** - Transform URLs, WiFi credentials, contact cards, and more into scannable codes
13
- - 🌐 **Host HTML Pages** - Deploy static HTML pages with dynamic variables and form submission handling
14
- - 📢 **Automate Social Media** - Schedule and manage social media posts across multiple platforms
15
- - 📊 **Track Performance** - Monitor and analyze your digital marketing efforts
16
-
17
- Posty5 empowers businesses, marketers, and developers to streamline their online workflows—all from a unified control panel.
18
-
19
- **Learn more:** [https://posty5.com](https://posty5.com)
20
-
21
- ---
22
-
23
- ## 📦 About This Package
24
-
25
- `@posty5/social-publisher-post` is the **post management client** for the Posty5 Social Media Publisher. This package enables you to programmatically publish short-form videos to multiple social media platforms simultaneously from a single API call.
26
-
27
- ### What are Social Publisher Posts?
28
-
29
- Posts represent video publishing jobs that distribute your content across YouTube Shorts, TikTok, Facebook Reels, and Instagram Reels. Each post handles the entire publishing workflow: video upload, platform-specific configuration, scheduling, and status tracking.
30
-
31
- ### Key Capabilities
32
-
33
- - **Multi-Platform Publishing** - Publish to YouTube, TikTok, Facebook, and Instagram in one API call
34
- - **Flexible Video Sources** - Upload files, provide URLs, or repost from other platforms (auto-detected)
35
- - **Smart Thumbnail Handling** - Upload files or provide URLs for thumbnail images
36
- - **Platform-Specific Configuration** - Customize titles, descriptions, captions, tags, and privacy settings per platform
37
- - **Schedule Publishing** - Publish immediately or schedule for optimal engagement times
38
- - **Repost Detection** - Automatically detect and repost from Facebook, TikTok, and YouTube Shorts URLs
39
- - **Post Status Tracking** - Monitor publishing progress and platform-specific status
40
- - **Tag & Reference System** - Organize posts using custom tags and reference IDs
41
- - **Pagination & Filtering** - Search posts by workspace, status, tag, or reference ID
42
-
43
- ### Why Use This Package?
44
-
45
- - **Time Saving**: Publish to 4 platforms with a single API call instead of managing each separately
46
- - **Automated Workflow**: Integrate multi-platform publishing into your content pipeline
47
- - **Content Repurposing**: Automatically repost viral content from other platforms
48
- - **Consistent Branding**: Apply platform-optimized metadata while maintaining brand voice
49
- - **Progress Tracking**: Monitor post status and handle errors programmatically
50
-
51
- ### Supported Platforms
52
-
53
- | Platform | Content Type | Custom Thumbnails | Max File Size |
54
- | --------- | ------------ | ----------------- | ------------- |
55
- | YouTube | Shorts | ✅ Yes | 2 GB |
56
- | TikTok | Videos | ❌ No | 2 GB |
57
- | Facebook | Reels | ❌ No | 2 GB |
58
- | Instagram | Reels | ❌ No | 2 GB |
59
-
60
- ---
61
-
62
- ## 📥 Installation
63
-
64
- Install via npm:
65
-
66
- ```bash
67
- npm install @posty5/social-publisher-post @posty5/core
68
- ```
69
-
70
- ---
71
-
72
- ## 🚀 Quick Start
73
-
74
- ```typescript
75
- import { HttpClient } from "@posty5/core";
76
- import { SocialPublisherPostClient } from "@posty5/social-publisher-post";
77
-
78
- // Initialize the HTTP client with your API key
79
- const httpClient = new HttpClient({
80
- apiKey: "your-api-key", // Get from studio.posty5.com/account/settings?tab=APIKeys
81
- debug: true, // Optional: Enable debug logging
82
- });
83
-
84
- // Create post client
85
- const client = new SocialPublisherPostClient(httpClient);
86
-
87
- // Publish video to YouTube Shorts
88
- const postId = await client.publishShortVideo({
89
- workspaceId: "workspace-123", // Your workspace ID
90
- video: videoFile, // File object or URL string
91
- thumbnail: thumbFile, // Optional: File or URL
92
- platforms: ["youtube"], // Target platforms
93
- youtube: {
94
- title: "My First YouTube Short",
95
- description: "Published using Posty5 SDK",
96
- tags: ["shorts", "video", "tutorial"],
97
- },
98
- });
99
-
100
- console.log("Post created:", postId);
101
-
102
- // Check post status
103
- const status = await client.getStatus(postId);
104
- console.log("Publishing status:", status.currentStatus);
105
- console.log("YouTube:", status.youtube?.postInfo.currentStatus);
106
- ```
107
-
108
- ---
109
-
110
- ## 📚 API Reference & Examples
111
-
112
- ### publishShortVideo()
113
-
114
- Publish a short video to one or more social media platforms. This is the main method for creating publishing posts. It automatically detects video source type (File upload, URL, or platform-specific repost URL) and handles all upload logic.
115
-
116
- **Parameters:**
117
-
118
- - `options` (IPublishOptions): Publishing configuration
119
- - `workspaceId` (string, required): Workspace ID containing connected social accounts
120
- - `video` (File | string, required): Video source - File object, direct URL, or platform URL (Facebook/TikTok/YouTube)
121
- - `thumbnail` (File | string, optional): Thumbnail image - File object or URL string
122
- - `platforms` (Array<'youtube' | 'tiktok' | 'facebook' | 'instagram'>, required): Target platforms
123
- - `youtube` (IYouTubeConfig, optional): YouTube configuration - required if 'youtube' in platforms
124
- - `tiktok` (ITikTokConfig, optional): TikTok configuration - required if 'tiktok' in platforms
125
- - `facebook` (IFacebookPageConfig, optional): Facebook configuration - required if 'facebook' in platforms
126
- - `instagram` (IInstagramConfig, optional): Instagram configuration - required if 'instagram' in platforms
127
- - `schedule` ('now' | Date, optional): Publish immediately (default) or schedule for specific date/time
128
- - `tag` (string, optional): Custom tag for filtering
129
- - `refId` (string, optional): Your internal reference ID
130
-
131
- **Returns:** `Promise<string>` - Created post ID
132
-
133
- **Example - Upload Video File:**
134
-
135
- ```typescript
136
- import * as fs from "fs";
137
-
138
- // Read video and thumbnail files
139
- const videoFile = fs.readFileSync("./video.mp4");
140
- const thumbFile = fs.readFileSync("./thumbnail.jpg");
141
-
142
- // Create File objects
143
- const video = new File([videoFile], "video.mp4", { type: "video/mp4" });
144
- const thumbnail = new File([thumbFile], "thumb.jpg", { type: "image/jpeg" });
145
-
146
- // Publish to YouTube only
147
- const postId = await client.publishShortVideo({
148
- workspaceId: "workspace-123",
149
- video: video,
150
- thumbnail: thumbnail,
151
- platforms: ["youtube"],
152
- youtube: {
153
- title: "Product Launch Video",
154
- description: "Introducing our new product line for 2024",
155
- tags: ["product", "launch", "2024"],
156
- madeForKids: false,
157
- },
158
- tag: "product-launch", // Custom tag for filtering
159
- refId: "PROD-LAUNCH-001", // Your internal reference
160
- });
161
-
162
- console.log("Published to YouTube:", postId);
163
- ```
164
-
165
- **Example - Video URL with Thumbnail URL:**
166
-
167
- ```typescript
168
- // Publish using URLs (no file upload needed)
169
- const postId = await client.publishShortVideo({
170
- workspaceId: "workspace-123",
171
- video: "https://cdn.example.com/videos/promo.mp4", // Direct video URL
172
- thumbnail: "https://cdn.example.com/images/thumb.jpg", // Direct thumbnail URL
173
- platforms: ["youtube", "tiktok"],
174
- youtube: {
175
- title: "Summer Sale Announcement",
176
- description: "Check out our summer collection",
177
- tags: ["sale", "summer", "fashion"],
178
- },
179
- tiktok: {
180
- caption: "Summer sale is here! 🔥 #SummerSale #Fashion",
181
- privacy_level: "public",
182
- disable_duet: false,
183
- disable_stitch: false,
184
- disable_comment: false,
185
- },
186
- });
187
-
188
- console.log("Published to YouTube and TikTok:", postId);
189
- ```
190
-
191
- **Example - Multi-Platform Publishing:**
192
-
193
- ```typescript
194
- // Publish to all 4 platforms simultaneously
195
- const postId = await client.publishShortVideo({
196
- workspaceId: "workspace-123",
197
- video: videoFile,
198
- thumbnail: thumbFile,
199
- platforms: ["youtube", "tiktok", "facebook", "instagram"],
200
-
201
- // YouTube configuration
202
- youtube: {
203
- title: "How to Use Our Product",
204
- description: "Step-by-step tutorial for beginners",
205
- tags: ["tutorial", "howto", "guide"],
206
- },
207
-
208
- // TikTok configuration
209
- tiktok: {
210
- caption: "Easy tutorial! Try it yourself 🎯 #Tutorial #LearnTikTok",
211
- privacy_level: "public",
212
- disable_duet: false,
213
- disable_stitch: false,
214
- disable_comment: false,
215
- },
216
-
217
- // Facebook configuration
218
- facebook: {
219
- title: "Product Tutorial",
220
- description: "Learn how to use our product in under 60 seconds",
221
- },
222
-
223
- // Instagram configuration
224
- instagram: {
225
- description: "Quick product tutorial 📱 #ProductTutorial",
226
- share_to_feed: true,
227
- },
228
- });
229
-
230
- console.log("Published to all platforms:", postId);
231
- ```
232
-
233
- **Example - Repost from TikTok:**
234
-
235
- ```typescript
236
- // Automatically detect and repost from TikTok
237
- const postId = await client.publishShortVideo({
238
- workspaceId: "workspace-123",
239
- video: "https://www.tiktok.com/@username/video/1234567890", // TikTok URL
240
- platforms: ["youtube"], // Repost to YouTube
241
- youtube: {
242
- title: "Viral TikTok Repost",
243
- description: "Sharing this viral moment from TikTok",
244
- tags: ["tiktok", "viral", "repost"],
245
- },
246
- });
247
-
248
- console.log("Reposted from TikTok to YouTube:", postId);
249
- ```
250
-
251
- **Example - Repost from YouTube Shorts:**
252
-
253
- ```typescript
254
- // Repost YouTube Shorts to TikTok
255
- const postId = await client.publishShortVideo({
256
- workspaceId: "workspace-123",
257
- video: "https://www.youtube.com/shorts/abc123", // YouTube Shorts URL
258
- platforms: ["tiktok"],
259
- tiktok: {
260
- caption: "Check out this YouTube Short! #YouTubeShorts",
261
- privacy_level: "public",
262
- disable_duet: false,
263
- disable_stitch: false,
264
- disable_comment: false,
265
- },
266
- });
267
-
268
- console.log("Reposted from YouTube to TikTok:", postId);
269
- ```
270
-
271
- **Example - Repost from Facebook:**
272
-
273
- ```typescript
274
- // Repost Facebook video to other platforms
275
- const postId = await client.publishShortVideo({
276
- workspaceId: "workspace-123",
277
- video: "https://www.facebook.com/reel/1234567890", // Facebook Reel URL
278
- platforms: ["youtube", "tiktok"],
279
- youtube: {
280
- title: "Facebook Viral Moment",
281
- description: "Reposting this viral moment from Facebook",
282
- tags: ["facebook", "viral", "repost"],
283
- },
284
- tiktok: {
285
- caption: "Viral moment from Facebook! #Viral",
286
- privacy_level: "public",
287
- disable_duet: false,
288
- disable_stitch: false,
289
- disable_comment: false,
290
- },
291
- });
292
-
293
- console.log("Reposted from Facebook:", postId);
294
- ```
295
-
296
- **Example - Scheduled Publishing:**
297
-
298
- ```typescript
299
- // Schedule video for future publication
300
- const publishDate = new Date("2024-12-25T12:00:00Z"); // Christmas at noon
301
-
302
- const postId = await client.publishShortVideo({
303
- workspaceId: "workspace-123",
304
- video: videoFile,
305
- platforms: ["youtube", "tiktok"],
306
- schedule: publishDate, // Schedule for specific date/time
307
- youtube: {
308
- title: "Merry Christmas! 🎄",
309
- description: "Holiday greetings from our team",
310
- tags: ["christmas", "holiday", "greetings"],
311
- },
312
- tiktok: {
313
- caption: "Merry Christmas everyone! 🎅🎄 #Christmas",
314
- privacy_level: "public",
315
- disable_duet: false,
316
- disable_stitch: false,
317
- disable_comment: false,
318
- },
319
- });
320
-
321
- console.log("Scheduled for", publishDate, "- Post ID:", postId);
322
- ```
323
-
324
- ---
325
-
326
- ### list()
327
-
328
- Search and retrieve publishing posts with pagination and filtering options.
329
-
330
- **Parameters:**
331
-
332
- - `params` (IListParams, optional): Search and filter options
333
- - `workspaceId` (string, optional): Filter by workspace ID
334
- - `currentStatus` (string, optional): Filter by post status ('pending', 'processing', 'done', 'error', etc.)
335
- - `tag` (string, optional): Filter by custom tag
336
- - `refId` (string, optional): Filter by reference ID
337
- - `pagination` (IPaginationParams, optional): Pagination settings
338
- - `page` (number): Page number (default: 1)
339
- - `pageSize` (number): Items per page (default: 10)
340
-
341
- **Returns:** `Promise<ISearchSocialPublisherPostResponse>` - Paginated post list
342
-
343
- **Response Structure:**
344
-
345
- ```typescript
346
- {
347
- items: Array<{
348
- _id: string; // Post ID
349
- numbering: string; // Post number (e.g., "T-12345")
350
- caption: string; // Post caption/title
351
- createdAt: Date; // Creation timestamp
352
- currentStatus: string; // Overall post status
353
- isAllowYoutube: boolean; // YouTube enabled
354
- isAllowFacebookPage: boolean; // Facebook enabled
355
- isAllowInstagram: boolean; // Instagram enabled
356
- isAllowTiktok: boolean; // TikTok enabled
357
- workspaceName: string; // Workspace name
358
- scheduleType: "schedule" | "now"; // Schedule type
359
- scheduleScheduledAt: Date | null; // Scheduled date
360
- scheduleExecutedAt: Date | null; // Execution date
361
- refId: string; // Reference ID
362
- tag: string; // Custom tag
363
- apiKeyName: string; // API key name
364
- }>;
365
- pagination: {
366
- page: number; // Current page
367
- pageSize: number; // Items per page
368
- totalCount: number; // Total posts
369
- totalPages: number; // Total pages
370
- }
371
- }
372
- ```
373
-
374
- **Example:**
375
-
376
- ```typescript
377
- // Get all posts with pagination
378
- const posts = await client.list(
379
- {},
380
- {
381
- page: 1,
382
- pageSize: 20,
383
- },
384
- );
385
-
386
- console.log(`Total posts: ${posts.pagination.totalCount}`);
387
- console.log(`Showing page ${posts.pagination.page} of ${posts.pagination.totalPages}`);
388
-
389
- // Display posts
390
- posts.items.forEach((post) => {
391
- console.log(`${post.numbering}: ${post.caption}`);
392
- console.log(` Status: ${post.currentStatus}`);
393
- console.log(
394
- ` Platforms: ${[post.isAllowYoutube && "YouTube", post.isAllowTiktok && "TikTok", post.isAllowFacebookPage && "Facebook", post.isAllowInstagram && "Instagram"].filter(Boolean).join(", ")}`,
395
- );
396
- });
397
-
398
- // Filter by workspace
399
- const workspacePosts = await client.list(
400
- {
401
- workspaceId: "workspace-123",
402
- },
403
- {
404
- page: 1,
405
- pageSize: 50,
406
- },
407
- );
408
-
409
- console.log(`Workspace has ${workspacePosts.items.length} posts`);
410
-
411
- // Filter by status
412
- const pendingPosts = await client.list(
413
- {
414
- currentStatus: "pending",
415
- },
416
- {
417
- page: 1,
418
- pageSize: 10,
419
- },
420
- );
421
-
422
- console.log(`Pending posts: ${pendingPosts.pagination.totalCount}`);
423
-
424
- // Filter by tag
425
- const campaignPosts = await client.list(
426
- {
427
- tag: "summer-campaign",
428
- },
429
- {
430
- page: 1,
431
- pageSize: 100,
432
- },
433
- );
434
-
435
- console.log(`Campaign posts: ${campaignPosts.items.length}`);
436
-
437
- // Filter by reference ID
438
- const specificPost = await client.list(
439
- {
440
- refId: "PROD-001",
441
- },
442
- {
443
- page: 1,
444
- pageSize: 1,
445
- },
446
- );
447
-
448
- if (specificPost.items.length > 0) {
449
- console.log("Found post:", specificPost.items[0].caption);
450
- }
451
- ```
452
-
453
- ---
454
-
455
- ### getStatus()
456
-
457
- Retrieve detailed status information for a specific publishing post, including platform-specific progress and post URLs.
458
-
459
- **Parameters:**
460
-
461
- - `id` (string): Post ID
462
-
463
- **Returns:** `Promise<ISocialPublisherPostStatusResponse>` - Detailed post status
464
-
465
- **Response Structure:**
466
-
467
- ```typescript
468
- {
469
- _id: string; // Post ID
470
- numbering: string; // Post number
471
- caption: string; // Post caption
472
- currentStatus: string; // Overall status
473
- createdAt: Date; // Creation time
474
- startedAt: Date; // Start time
475
-
476
- // Platform-specific details
477
- youtube?: {
478
- tags: string[];
479
- postInfo: {
480
- isAllow: boolean; // Platform enabled
481
- currentStatus: string; // Platform status
482
- videoURL: string; // Published video URL
483
- socialPublisherAccount: { // Account details
484
- name: string;
485
- thumbnail: string;
486
- platformAccountId: string;
487
- };
488
- };
489
- };
490
-
491
- tiktok?: { /* Similar structure */ };
492
- facebook?: { /* Similar structure */ };
493
- instagram?: { /* Similar structure */ };
494
-
495
- // Workspace info
496
- workspace: {
497
- _id: string;
498
- name: string;
499
- description: string;
500
- };
501
-
502
- // Schedule info
503
- schedule: {
504
- type: 'schedule' | 'now';
505
- scheduledAt: Date;
506
- executedAt: Date;
507
- };
508
- }
509
- ```
510
-
511
- **Example:**
512
-
513
- ```typescript
514
- // Get post status
515
- const status = await client.getStatus("post-id-here");
516
-
517
- console.log("Post:", status.numbering);
518
- console.log("Overall Status:", status.currentStatus);
519
- console.log("Created:", status.createdAt);
520
-
521
- // Check YouTube status
522
- if (status.youtube) {
523
- console.log("\nYouTube:");
524
- console.log(" Status:", status.youtube.postInfo.currentStatus);
525
- console.log(" Channel:", status.youtube.postInfo.socialPublisherAccount.name);
526
-
527
- if (status.youtube.postInfo.videoURL) {
528
- console.log(" Video URL:", status.youtube.postInfo.videoURL);
529
- }
530
- }
531
-
532
- // Check TikTok status
533
- if (status.tiktok) {
534
- console.log("\nTikTok:");
535
- console.log(" Status:", status.tiktok.postInfo.currentStatus);
536
- console.log(" Account:", status.tiktok.postInfo.socialPublisherAccount.name);
537
-
538
- if (status.tiktok.postInfo.videoURL) {
539
- console.log(" Video URL:", status.tiktok.postInfo.videoURL);
540
- }
541
- }
542
-
543
- // Check Facebook status
544
- if (status.facebook) {
545
- console.log("\nFacebook:");
546
- console.log(" Status:", status.facebook.postInfo.currentStatus);
547
- console.log(" Page:", status.facebook.postInfo.socialPublisherAccount.name);
548
- }
549
-
550
- // Check Instagram status
551
- if (status.instagram) {
552
- console.log("\nInstagram:");
553
- console.log(" Status:", status.instagram.postInfo.currentStatus);
554
- console.log(" Account:", status.instagram.postInfo.socialPublisherAccount.name);
555
- }
556
-
557
- // Handle errors
558
- if (status.currentStatus === "error") {
559
- console.error("Post failed!");
560
-
561
- // Check which platforms failed
562
- const failures = [];
563
- if (status.youtube?.postInfo.currentStatus === "error") failures.push("YouTube");
564
- if (status.tiktok?.postInfo.currentStatus === "error") failures.push("TikTok");
565
- if (status.facebook?.postInfo.currentStatus === "error") failures.push("Facebook");
566
- if (status.instagram?.postInfo.currentStatus === "error") failures.push("Instagram");
567
-
568
- console.error("Failed platforms:", failures.join(", "));
569
- }
570
-
571
- // Monitor post progress
572
- async function waitForCompletion(postId: string, maxWaitMs = 300000) {
573
- const startTime = Date.now();
574
-
575
- while (Date.now() - startTime < maxWaitMs) {
576
- const status = await client.getStatus(postId);
577
-
578
- console.log(`Status: ${status.currentStatus}`);
579
-
580
- if (status.currentStatus === "done") {
581
- console.log("✓ Publishing complete!");
582
- return status;
583
- }
584
-
585
- if (status.currentStatus === "error") {
586
- throw new Error("Publishing failed");
587
- }
588
-
589
- // Wait 5 seconds before checking again
590
- await new Promise((resolve) => setTimeout(resolve, 5000));
591
- }
592
-
593
- throw new Error("Timeout waiting for post completion");
594
- }
595
-
596
- const finalStatus = await waitForCompletion("post-id");
597
- console.log("All platforms published successfully");
598
- ```
599
-
600
- ---
601
-
602
- ### getDefaultSettings()
603
-
604
- Retrieve default configuration settings for social media publishing, including platform limits and default values.
605
-
606
- **Parameters:** None
607
-
608
- **Returns:** `Promise<IDefaultSettingsResponse>` - Default settings configuration
609
-
610
- **Example:**
611
-
612
- ```typescript
613
- // Get default settings
614
- const settings = await client.getDefaultSettings();
615
-
616
- console.log("Default Settings:", settings);
617
-
618
- // Use defaults in your application
619
- console.log("Max video size:", client.maxVideoUploadSizeBytes, "bytes");
620
- console.log("Max thumbnail size:", client.maxImageUploadSizeBytes, "bytes");
621
- ```
622
-
623
- ---
624
-
625
- ### getNextAndPrevious()
626
-
627
- Get the IDs of the next and previous posts for navigation purposes.
628
-
629
- **Parameters:**
630
-
631
- - `id` (string): Current post ID
632
-
633
- **Returns:** `Promise<ISocialPublisherPostNextPreviousResponse>` - Next and previous post IDs
634
-
635
- **Response Structure:**
636
-
637
- ```typescript
638
- {
639
- nextId?: string; // Next post ID (if exists)
640
- previousId?: string; // Previous post ID (if exists)
641
- }
642
- ```
643
-
644
- **Example:**
645
-
646
- ```typescript
647
- // Get navigation IDs
648
- const navigation = await client.getNextAndPrevious("current-post-id");
649
-
650
- if (navigation.nextId) {
651
- console.log("Next post:", navigation.nextId);
652
-
653
- // Navigate to next post
654
- const nextPost = await client.getStatus(navigation.nextId);
655
- console.log("Next post caption:", nextPost.caption);
656
- }
657
-
658
- if (navigation.previousId) {
659
- console.log("Previous post:", navigation.previousId);
660
-
661
- // Navigate to previous post
662
- const prevPost = await client.getStatus(navigation.previousId);
663
- console.log("Previous post caption:", prevPost.caption);
664
- }
665
-
666
- // Build post navigation
667
- async function navigateForward(startPostId: string, count: number) {
668
- const posts = [];
669
- let currentId = startPostId;
670
-
671
- for (let i = 0; i < count; i++) {
672
- const status = await client.getStatus(currentId);
673
- posts.push(status);
674
-
675
- const nav = await client.getNextAndPrevious(currentId);
676
- if (!nav.nextId) break;
677
-
678
- currentId = nav.nextId;
679
- }
680
-
681
- return posts;
682
- }
683
-
684
- const next5Posts = await navigateForward("post-id", 5);
685
- console.log(`Retrieved ${next5Posts.length} posts`);
686
- ```
687
-
688
- ---
689
-
690
- ## 🔄 Complete Workflow Example
691
-
692
- ```typescript
693
- import { HttpClient } from "@posty5/core";
694
- import { SocialPublisherPostClient } from "@posty5/social-publisher-post";
695
- import * as fs from "fs";
696
-
697
- // Initialize client
698
- const httpClient = new HttpClient({
699
- apiKey: process.env.POSTY5_API_KEY!,
700
- debug: false,
701
- });
702
-
703
- const client = new SocialPublisherPostClient(httpClient);
704
-
705
- async function publishVideoWorkflow() {
706
- try {
707
- // 1. Prepare video and thumbnail
708
- console.log("Preparing media files...");
709
- const videoBuffer = fs.readFileSync("./content/video.mp4");
710
- const thumbBuffer = fs.readFileSync("./content/thumbnail.jpg");
711
-
712
- const video = new File([videoBuffer], "video.mp4", { type: "video/mp4" });
713
- const thumbnail = new File([thumbBuffer], "thumb.jpg", { type: "image/jpeg" });
714
-
715
- // 2. Publish to multiple platforms
716
- console.log("Publishing video...");
717
- const postId = await client.publishShortVideo({
718
- workspaceId: "workspace-123",
719
- video: video,
720
- thumbnail: thumbnail,
721
- platforms: ["youtube", "tiktok"],
722
- youtube: {
723
- title: "Product Demo 2024",
724
- description: "Check out our latest product features",
725
- tags: ["product", "demo", "2024"],
726
- },
727
- tiktok: {
728
- caption: "New product alert! 🚀 #Product #Tech",
729
- privacy_level: "public",
730
- disable_duet: false,
731
- disable_stitch: false,
732
- disable_comment: false,
733
- },
734
- tag: "product-demo",
735
- refId: "DEMO-2024-001",
736
- });
737
-
738
- console.log("✓ Post created:", postId);
739
-
740
- // 3. Monitor publishing progress
741
- console.log("\nMonitoring progress...");
742
- let attempts = 0;
743
- const maxAttempts = 60; // 5 minutes (5 second intervals)
744
-
745
- while (attempts < maxAttempts) {
746
- const status = await client.getStatus(postId);
747
-
748
- console.log(` Status: ${status.currentStatus}`);
749
-
750
- // Check individual platforms
751
- if (status.youtube) {
752
- console.log(` YouTube: ${status.youtube.postInfo.currentStatus}`);
753
- }
754
- if (status.tiktok) {
755
- console.log(` TikTok: ${status.tiktok.postInfo.currentStatus}`);
756
- }
757
-
758
- // Check if completed
759
- if (status.currentStatus === "done") {
760
- console.log("\n✓ Publishing complete!");
761
-
762
- // Get video URLs
763
- if (status.youtube?.postInfo.videoURL) {
764
- console.log(" YouTube URL:", status.youtube.postInfo.videoURL);
765
- }
766
- if (status.tiktok?.postInfo.videoURL) {
767
- console.log(" TikTok URL:", status.tiktok.postInfo.videoURL);
768
- }
769
-
770
- return status;
771
- }
772
-
773
- // Check for errors
774
- if (status.currentStatus === "error") {
775
- console.error("\n✗ Publishing failed");
776
- throw new Error("Post failed");
777
- }
778
-
779
- // Wait before checking again
780
- await new Promise((resolve) => setTimeout(resolve, 5000));
781
- attempts++;
782
- }
783
-
784
- throw new Error("Timeout: Post did not complete within 5 minutes");
785
- } catch (error) {
786
- console.error("Error:", error.message);
787
- throw error;
788
- }
789
- }
790
-
791
- // Run the workflow
792
- publishVideoWorkflow()
793
- .then(() => console.log("\nWorkflow completed successfully"))
794
- .catch((err) => console.error("\nWorkflow failed:", err));
795
- ```
796
-
797
- ---
798
-
799
- ## 📘 TypeScript Support
800
-
801
- Full TypeScript support with exported interfaces:
802
-
803
- ```typescript
804
- import {
805
- // Client
806
- SocialPublisherPostClient,
807
-
808
- // Publishing options
809
- IPublishOptions,
810
-
811
- // Platform configurations
812
- IYouTubeConfig,
813
- ITikTokConfig,
814
- IFacebookPageConfig,
815
- IInstagramConfig,
816
-
817
- // Schedule configuration
818
- IScheduleConfig,
819
-
820
- // Search parameters
821
- IListParams,
822
-
823
- // Response interfaces
824
- ISocialPublisherPostStatusResponse,
825
- ISearchSocialPublisherPostResponse,
826
- ISocialPublisherPostNextPreviousResponse,
827
- IDefaultSettingsResponse,
828
-
829
- // Response types
830
- ISocialPublisherPostResponse,
831
- ISocialPublisherWorkspace,
832
- ISocialPublisherAccount,
833
-
834
- // Status types
835
- SocialPublisherPostStatusType, // 'pending' | 'processing' | 'done' | 'error' | ...
836
- SocialPublisherPostSourceType, // 'video-file' | 'video-url' | 'facebook-video' | ...
837
- SocialPublisherAccountStatusType, // 'active' | 'inactive' | 'authenticationExpired'
838
- } from "@posty5/social-publisher-post";
839
- ```
840
-
841
- ### Platform Configuration Types
842
-
843
- **YouTube Configuration:**
844
-
845
- ```typescript
846
- interface IYouTubeConfig {
847
- title: string; // Video title (required)
848
- description: string; // Video description (required)
849
- tags: string[]; // Video tags (required)
850
- madeForKids?: boolean; // Mark as made for kids (optional)
851
- defaultLanguage?: string; // Default language code (optional)
852
- defaultAudioLanguage?: string; // Audio language code (optional)
853
- categoryId?: string; // YouTube category ID (optional)
854
- localizationLanguages?: string[]; // Localization languages (optional)
855
- }
856
- ```
857
-
858
- **TikTok Configuration:**
859
-
860
- ```typescript
861
- interface ITikTokConfig {
862
- caption: string; // Video caption (required)
863
- privacy_level: string; // 'public' | 'SELF_ONLY' | 'MUTUAL_FOLLOW_FRIENDS' (required)
864
- disable_duet: boolean; // Disable duet feature (required)
865
- disable_stitch: boolean; // Disable stitch feature (required)
866
- disable_comment: boolean; // Disable comments (required)
867
- }
868
- ```
869
-
870
- **Facebook Configuration:**
871
-
872
- ```typescript
873
- interface IFacebookPageConfig {
874
- description: string; // Post description (required)
875
- title?: string; // Post title (optional)
876
- }
877
- ```
878
-
879
- **Instagram Configuration:**
880
-
881
- ```typescript
882
- interface IInstagramConfig {
883
- description: string; // Post description (required)
884
- share_to_feed?: boolean; // Share to feed (optional)
885
- is_published_to_both_feed_and_story?: boolean; // Publish to both (optional)
886
- }
887
- ```
888
-
889
- ---
890
-
891
- ## 📦 Related Packages
892
-
893
- This SDK ecosystem contains the following tool packages:
894
-
895
- | Package | Description | Version | GitHub | NPM |
896
- | --- | --- | --- | --- | --- |
897
- | @posty5/short-link | URL shortener client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-short-link) | [📦 NPM](https://www.npmjs.com/package/@posty5/short-link) |
898
- | @posty5/qr-code | QR code generator client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-qr-code) | [📦 NPM](https://www.npmjs.com/package/@posty5/qr-code) |
899
- | @posty5/html-hosting | HTML hosting client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-html-hosting) | [📦 NPM](https://www.npmjs.com/package/@posty5/html-hosting) |
900
- | @posty5/html-hosting-variables | HTML hosting variables client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-html-hosting-variables) | [📦 NPM](https://www.npmjs.com/package/@posty5/html-hosting-variables) |
901
- | @posty5/html-hosting-form-submission | Form submission client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-html-hosting-form-submission) | [📦 NPM](https://www.npmjs.com/package/@posty5/html-hosting-form-submission) |
902
- | @posty5/social-publisher-workspace | Social publisher workspace client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-social-publisher-workspace) | [📦 NPM](https://www.npmjs.com/package/@posty5/social-publisher-workspace) |
903
- | @posty5/social-publisher-post | Social publisher post client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-social-publisher-post) | [📦 NPM](https://www.npmjs.com/package/@posty5/social-publisher-post) |
904
-
905
- ---
906
-
907
- ## 💻 Node.js Compatibility
908
-
909
- - **Node.js**: >= 16.0.0
910
- - **Module Systems**: ESM and CommonJS
911
- - **TypeScript**: Full type definitions included
912
-
913
- ---
914
-
915
- ## 🆘 Support
916
-
917
- We're here to help you succeed with Posty5!
918
-
919
- ### Get Help
920
-
921
- - **Documentation**: [https://guide.posty5.com](https://guide.posty5.com)
922
- - **Contact Us**: [https://posty5.com/contact-us](https://posty5.com/contact-us)
923
- - **GitHub Issues**: [Report bugs or request features](https://github.com/Posty5/npm-sdk/issues)
924
- - **API Status**: Check API status and uptime at [https://status.posty5.com](https://status.posty5.com)
925
-
926
- ### Common Issues
927
-
928
- 1. **Authentication Errors**
929
- - Ensure your API key is valid and active
930
- - Get your API key from [studio.posty5.com/account/settings?tab=APIKeys](studio.posty5.com/account/settings?tab=APIKeys)
931
-
932
- 2. **Network Errors**
933
- - Check your internet connection
934
- - Verify firewall settings allow connections to `api.posty5.com`
935
-
936
- 3. **Rate Limiting**
937
- - The SDK includes automatic retry logic
938
- - Check your API plan limits in the dashboard
939
-
940
- ---
941
-
942
- ## 📄 License
943
-
944
- MIT License - see [LICENSE](./LICENSE) file for details.
945
-
946
- ---
947
-
948
- ## 🔗 Useful Links
949
-
950
- - **Website**: [https://posty5.com](https://posty5.com)
951
- - **Dashboard**: [studio.posty5.com/account/settings?tab=APIKeys](studio.posty5.com/account/settings?tab=APIKeys)
952
- - **API Documentation**: [https://docs.posty5.com](https://docs.posty5.com)
953
- - **GitHub**: [https://github.com/Posty5/npm-sdk](https://github.com/Posty5/npm-sdk)
954
-
955
- ---
956
-
957
- Made with ❤️ by the Posty5 team
1
+ # @posty5/social-publisher-post
2
+
3
+ Official Posty5 SDK for managing social media publishing posts. Prepare creator-owned videos for YouTube Shorts, TikTok, Facebook Reels, and Instagram Reels with a unified, developer-friendly API.
4
+
5
+ ---
6
+
7
+ ## 🌟 What is Posty5?
8
+
9
+ **Posty5** is a comprehensive suite of free online tools designed to enhance your digital marketing and social media presence. With over 4+ powerful tools and counting, Posty5 provides everything you need to:
10
+
11
+ - 🔗 **Shorten URLs** - Create memorable, trackable short links
12
+ - 📱 **Generate QR Codes** - Transform URLs, WiFi credentials, contact cards, and more into scannable codes
13
+ - 🌐 **Host HTML Pages** - Deploy static HTML pages with dynamic variables and form submission handling
14
+ - 📢 **Social Publishing** - Prepare and manage creator-controlled social media posts across connected platforms
15
+ - 📊 **Track Performance** - Monitor and analyze your digital marketing efforts
16
+
17
+ Posty5 empowers businesses, marketers, and developers to streamline their online workflows—all from a unified control panel.
18
+
19
+ **Learn more:** [https://posty5.com](https://posty5.com)
20
+
21
+ ---
22
+
23
+ ## 📦 About This Package
24
+
25
+ `@posty5/social-publisher-post` is the **post management client** for the Posty5 Social Media Publisher. Use it with videos you created or have the rights to publish. TikTok Direct Post requires the creator-controlled Posty5 review flow before submission.
26
+
27
+ ### What are Social Publisher Posts?
28
+
29
+ Posts represent video publishing jobs for connected YouTube, TikTok, Facebook, and Instagram accounts. Each post handles video upload, platform-specific configuration, scheduling, and status tracking.
30
+
31
+ ### Key Capabilities
32
+
33
+ - **Multi-Platform Preparation** - Prepare posts for connected YouTube, TikTok, Facebook, and Instagram accounts
34
+ - **Authorized Video Sources** - Upload files or provide direct video file URLs for content you created or have rights to publish
35
+ - **Smart Thumbnail Handling** - Upload files or provide URLs for thumbnail images
36
+ - **Platform-Specific Configuration** - Customize titles, descriptions, captions, tags, and privacy settings per platform
37
+ - **Schedule Publishing** - Publish immediately or schedule for optimal engagement times
38
+ - **TikTok Direct Post Review** - TikTok publishing requires manual privacy selection, disclosure options when needed, and explicit creator confirmation in Posty5
39
+ - **Post Status Tracking** - Monitor publishing progress and platform-specific status
40
+ - **Tag & Reference System** - Organize posts using custom tags and reference IDs
41
+ - **Pagination & Filtering** - Search posts by workspace, status, tag, or reference ID
42
+
43
+ ### Why Use This Package?
44
+
45
+ - **Time Saving**: Prepare platform-specific settings from one integration while keeping TikTok publishing creator-controlled
46
+ - **Reviewed Workflow**: Integrate publishing status and configuration while preserving the Posty5 TikTok review and confirmation flow
47
+ - **Rights-Aware Publishing**: Use original videos or content you have permission to publish
48
+ - **Consistent Branding**: Apply platform-optimized metadata while maintaining brand voice
49
+ - **Progress Tracking**: Monitor post status and handle errors programmatically
50
+
51
+ ### Supported Platforms
52
+
53
+ | Platform | Content Type | Custom Thumbnails | Max File Size |
54
+ | --------- | ------------ | ----------------- | ------------- |
55
+ | YouTube | Shorts | ✅ Yes | 2 GB |
56
+ | TikTok | Videos | ❌ No | 2 GB |
57
+ | Facebook | Reels | ❌ No | 2 GB |
58
+ | Instagram | Reels | ❌ No | 2 GB |
59
+
60
+ ---
61
+
62
+ ## 📥 Installation
63
+
64
+ Install via npm:
65
+
66
+ ```bash
67
+ npm install @posty5/social-publisher-post @posty5/core
68
+ ```
69
+
70
+ ---
71
+
72
+ ## 🚀 Quick Start
73
+
74
+ ```typescript
75
+ import { HttpClient } from "@posty5/core";
76
+ import { SocialPublisherPostClient } from "@posty5/social-publisher-post";
77
+
78
+ // Initialize the HTTP client with your API key
79
+ const httpClient = new HttpClient({
80
+ apiKey: "your-api-key", // Get from studio.posty5.com/account/settings?tab=APIKeys
81
+ debug: true, // Optional: Enable debug logging
82
+ });
83
+
84
+ // Create post client
85
+ const client = new SocialPublisherPostClient(httpClient);
86
+
87
+ // Publish video to YouTube Shorts
88
+ const postId = await client.publishShortVideo({
89
+ workspaceId: "workspace-123", // Your workspace ID
90
+ video: videoFile, // File object or URL string
91
+ thumbnail: thumbFile, // Optional: File or URL
92
+ youtube: {
93
+ title: "My First YouTube Short",
94
+ description: "Published using Posty5 SDK",
95
+ tags: ["shorts", "video", "tutorial"],
96
+ },
97
+ });
98
+
99
+ console.log("Post created:", postId);
100
+
101
+ // Check post status
102
+ const status = await client.getStatus(postId);
103
+ console.log("Publishing status:", status.currentStatus);
104
+ console.log("YouTube:", status.youtube?.postInfo.currentStatus);
105
+ ```
106
+
107
+ ---
108
+
109
+ ## 📚 API Reference & Examples
110
+
111
+ ### publishShortVideo()
112
+
113
+ Publish a short video to one or more connected social media accounts. Use file uploads or direct video file URLs for content you created or have the rights to publish. TikTok Direct Post must go through the Posty5 creator review and confirmation flow.
114
+
115
+ **Parameters:**
116
+
117
+ - `options` (IPublishOptions): Publishing configuration
118
+ - `workspaceId` (string, required): Workspace ID containing connected social accounts
119
+ - `video` (File | string, required): Video source - File object or direct video file URL only.
120
+ - `thumbnail` (File | string, optional): Thumbnail image - File object or URL string
121
+ - `youtube` (IYouTubeConfig, optional): YouTube configuration — **required** if the workspace has a YouTube account connected
122
+ - `tiktok` (ITikTokConfig, optional): TikTok configuration — **required** if the workspace has a TikTok account connected
123
+ - `facebook` (IFacebookPageConfig, optional): Facebook configuration — **required** if the workspace has a Facebook Page connected
124
+ - `instagram` (IInstagramConfig, optional): Instagram configuration — **required** if the workspace has an Instagram account connected
125
+ - `schedule` ('now' | Date, optional): Publish immediately (default) or schedule for specific date/time
126
+ - `tag` (string, optional): Custom tag for filtering
127
+ - `refId` (string, optional): Your internal reference ID
128
+
129
+ > **Where publish targets come from.** The workspace's connected accounts are
130
+ > the single source of truth — connect / disconnect accounts on the workspace
131
+ > page in the Posty5 dashboard to choose which platforms a post lands on. The
132
+ > SDK forwards whichever config blocks you supply; the server matches them
133
+ > against the workspace.
134
+
135
+ **Returns:** `Promise<string>` - Created post ID
136
+
137
+ **Example - Upload Video File:**
138
+
139
+ ```typescript
140
+ import * as fs from "fs";
141
+
142
+ // Read video and thumbnail files
143
+ const videoFile = fs.readFileSync("./video.mp4");
144
+ const thumbFile = fs.readFileSync("./thumbnail.jpg");
145
+
146
+ // Create File objects
147
+ const video = new File([videoFile], "video.mp4", { type: "video/mp4" });
148
+ const thumbnail = new File([thumbFile], "thumb.jpg", { type: "image/jpeg" });
149
+
150
+ // Publish to YouTube only
151
+ const postId = await client.publishShortVideo({
152
+ workspaceId: "workspace-123",
153
+ video: video,
154
+ thumbnail: thumbnail,
155
+ youtube: {
156
+ title: "Product Launch Video",
157
+ description: "Introducing our new product line for 2024",
158
+ tags: ["product", "launch", "2024"],
159
+ madeForKids: false,
160
+ },
161
+ tag: "product-launch", // Custom tag for filtering
162
+ refId: "PROD-LAUNCH-001", // Your internal reference
163
+ });
164
+
165
+ console.log("Published to YouTube:", postId);
166
+ ```
167
+
168
+ **Example - Video URL with Thumbnail URL:**
169
+
170
+ ```typescript
171
+ // Publish using URLs (no file upload needed)
172
+ const postId = await client.publishShortVideo({
173
+ workspaceId: "workspace-123",
174
+ video: "https://cdn.example.com/videos/promo.mp4", // Direct video URL
175
+ thumbnail: "https://cdn.example.com/images/thumb.jpg", // Direct thumbnail URL
176
+ youtube: {
177
+ title: "Summer Sale Announcement",
178
+ description: "Check out our summer collection",
179
+ tags: ["sale", "summer", "fashion"],
180
+ },
181
+ tiktok: {
182
+ caption: "Summer sale is here! 🔥 #SummerSale #Fashion",
183
+ privacy_level: "public",
184
+ disable_duet: false,
185
+ disable_stitch: false,
186
+ disable_comment: false,
187
+ },
188
+ });
189
+
190
+ console.log("Published to YouTube and TikTok:", postId);
191
+ ```
192
+
193
+ **Example - Auto-Comment After Publish (Pro plan, +1 credit):**
194
+
195
+ ```typescript
196
+ // Publish a video and queue a comment for each platform.
197
+ // TikTok comments are not supported — the platform will always
198
+ // report `commentInfo.currentStatus === "notSupported"`.
199
+ const postId = await client.publishShortVideo({
200
+ workspaceId: "workspace-123",
201
+ video: videoFile,
202
+ youtube: { title: "Launch day", description: "We shipped!", tags: ["launch"] },
203
+ facebook: { description: "We shipped!" },
204
+ instagram: { description: "We shipped! 🚀" },
205
+ comment: {
206
+ text: "Drop your favourite feature below 👇",
207
+ postToFacebook: true,
208
+ postToInstagram: true,
209
+ postToYoutube: true,
210
+ // postToTiktok defaults to false — TikTok does not support API comments
211
+ },
212
+ });
213
+
214
+ // Later, poll status to see how each comment landed:
215
+ const status = await client.getStatus(postId);
216
+ console.log("YouTube comment:", status.youtube?.commentInfo?.currentStatus);
217
+ console.log("Facebook comment URL:", status.facebook?.commentInfo?.commentURL);
218
+ console.log("TikTok comment:", status.tiktok?.commentInfo?.currentStatus); // "notSupported"
219
+ ```
220
+
221
+ **Example - Multi-Platform Publishing:**
222
+
223
+ ```typescript
224
+ // Publish to all 4 platforms simultaneously
225
+ const postId = await client.publishShortVideo({
226
+ workspaceId: "workspace-123",
227
+ video: videoFile,
228
+ thumbnail: thumbFile,
229
+
230
+ // YouTube configuration
231
+ youtube: {
232
+ title: "How to Use Our Product",
233
+ description: "Step-by-step tutorial for beginners",
234
+ tags: ["tutorial", "howto", "guide"],
235
+ },
236
+
237
+ // TikTok configuration
238
+ tiktok: {
239
+ caption: "Easy tutorial! Try it yourself 🎯 #Tutorial #LearnTikTok",
240
+ privacy_level: "public",
241
+ disable_duet: false,
242
+ disable_stitch: false,
243
+ disable_comment: false,
244
+ },
245
+
246
+ // Facebook configuration
247
+ facebook: {
248
+ title: "Product Tutorial",
249
+ description: "Learn how to use our product in under 60 seconds",
250
+ },
251
+
252
+ // Instagram configuration
253
+ instagram: {
254
+ description: "Quick product tutorial 📱 #ProductTutorial",
255
+ share_to_feed: true,
256
+ },
257
+ });
258
+
259
+ console.log("Published to all platforms:", postId);
260
+ ```
261
+
262
+ > **TikTok Direct Post note:** This SDK supports file uploads and direct video file URLs only. TikTok publishing in Posty5 is creator-controlled: the connected account owner reviews the video, confirms the TikTok nickname, edits caption text, manually selects privacy and interaction settings, completes disclosure options when required, and explicitly confirms publishing before submission.
263
+
264
+ **Example - Scheduled Publishing:**
265
+
266
+ ```typescript
267
+ // Schedule video for future publication
268
+ const publishDate = new Date("2024-12-25T12:00:00Z"); // Christmas at noon
269
+
270
+ const postId = await client.publishShortVideo({
271
+ workspaceId: "workspace-123",
272
+ video: videoFile,
273
+ schedule: publishDate, // Schedule for specific date/time
274
+ youtube: {
275
+ title: "Merry Christmas! 🎄",
276
+ description: "Holiday greetings from our team",
277
+ tags: ["christmas", "holiday", "greetings"],
278
+ },
279
+ tiktok: {
280
+ caption: "Merry Christmas everyone! 🎅🎄 #Christmas",
281
+ privacy_level: "public",
282
+ disable_duet: false,
283
+ disable_stitch: false,
284
+ disable_comment: false,
285
+ },
286
+ });
287
+
288
+ console.log("Scheduled for", publishDate, "- Post ID:", postId);
289
+ ```
290
+
291
+ ---
292
+
293
+ ### list()
294
+
295
+ Search and retrieve publishing posts with pagination and filtering options.
296
+
297
+ **Parameters:**
298
+
299
+ - `params` (IListParams, optional): Search and filter options
300
+ - `workspaceId` (string, optional): Filter by workspace ID
301
+ - `currentStatus` (string, optional): Filter by post status ('pending', 'processing', 'done', 'error', etc.)
302
+ - `tag` (string, optional): Filter by custom tag
303
+ - `refId` (string, optional): Filter by reference ID
304
+ - `pagination` (IPaginationParams, optional): Pagination settings
305
+ - `page` (number): Page number (default: 1)
306
+ - `pageSize` (number): Items per page (default: 10)
307
+
308
+ **Returns:** `Promise<ISearchSocialPublisherPostResponse>` - Paginated post list
309
+
310
+ **Response Structure:**
311
+
312
+ ```typescript
313
+ {
314
+ items: Array<{
315
+ _id: string; // Post ID
316
+ numbering: string; // Post number (e.g., "T-12345")
317
+ caption: string; // Post caption/title
318
+ createdAt: Date; // Creation timestamp
319
+ currentStatus: string; // Overall post status
320
+ isAllowYoutube: boolean; // YouTube enabled
321
+ isAllowFacebookPage: boolean; // Facebook enabled
322
+ isAllowInstagram: boolean; // Instagram enabled
323
+ isAllowTiktok: boolean; // TikTok enabled
324
+ workspaceName: string; // Workspace name
325
+ scheduleType: "schedule" | "now"; // Schedule type
326
+ scheduleScheduledAt: Date | null; // Scheduled date
327
+ scheduleExecutedAt: Date | null; // Execution date
328
+ refId: string; // Reference ID
329
+ tag: string; // Custom tag
330
+ apiKeyName: string; // API key name
331
+ }>;
332
+ pagination: {
333
+ page: number; // Current page
334
+ pageSize: number; // Items per page
335
+ totalCount: number; // Total posts
336
+ totalPages: number; // Total pages
337
+ }
338
+ }
339
+ ```
340
+
341
+ **Example:**
342
+
343
+ ```typescript
344
+ // Get all posts with pagination
345
+ const posts = await client.list(
346
+ {},
347
+ {
348
+ page: 1,
349
+ pageSize: 20,
350
+ },
351
+ );
352
+
353
+ console.log(`Total posts: ${posts.pagination.totalCount}`);
354
+ console.log(`Showing page ${posts.pagination.page} of ${posts.pagination.totalPages}`);
355
+
356
+ // Display posts
357
+ posts.items.forEach((post) => {
358
+ console.log(`${post.numbering}: ${post.caption}`);
359
+ console.log(` Status: ${post.currentStatus}`);
360
+ console.log(
361
+ ` Platforms: ${[post.isAllowYoutube && "YouTube", post.isAllowTiktok && "TikTok", post.isAllowFacebookPage && "Facebook", post.isAllowInstagram && "Instagram"].filter(Boolean).join(", ")}`,
362
+ );
363
+ });
364
+
365
+ // Filter by workspace
366
+ const workspacePosts = await client.list(
367
+ {
368
+ workspaceId: "workspace-123",
369
+ },
370
+ {
371
+ page: 1,
372
+ pageSize: 50,
373
+ },
374
+ );
375
+
376
+ console.log(`Workspace has ${workspacePosts.items.length} posts`);
377
+
378
+ // Filter by status
379
+ const pendingPosts = await client.list(
380
+ {
381
+ currentStatus: "pending",
382
+ },
383
+ {
384
+ page: 1,
385
+ pageSize: 10,
386
+ },
387
+ );
388
+
389
+ console.log(`Pending posts: ${pendingPosts.pagination.totalCount}`);
390
+
391
+ // Filter by tag
392
+ const campaignPosts = await client.list(
393
+ {
394
+ tag: "summer-campaign",
395
+ },
396
+ {
397
+ page: 1,
398
+ pageSize: 100,
399
+ },
400
+ );
401
+
402
+ console.log(`Campaign posts: ${campaignPosts.items.length}`);
403
+
404
+ // Filter by reference ID
405
+ const specificPost = await client.list(
406
+ {
407
+ refId: "PROD-001",
408
+ },
409
+ {
410
+ page: 1,
411
+ pageSize: 1,
412
+ },
413
+ );
414
+
415
+ if (specificPost.items.length > 0) {
416
+ console.log("Found post:", specificPost.items[0].caption);
417
+ }
418
+ ```
419
+
420
+ ---
421
+
422
+ ### getStatus()
423
+
424
+ Retrieve detailed status information for a specific publishing post, including platform-specific progress and post URLs.
425
+
426
+ **Parameters:**
427
+
428
+ - `id` (string): Post ID
429
+
430
+ **Returns:** `Promise<ISocialPublisherPostStatusResponse>` - Detailed post status
431
+
432
+ **Response Structure:**
433
+
434
+ ```typescript
435
+ {
436
+ _id: string; // Post ID
437
+ numbering: string; // Post number
438
+ caption: string; // Post caption
439
+ currentStatus: string; // Overall status
440
+ createdAt: Date; // Creation time
441
+ startedAt: Date; // Start time
442
+
443
+ // Platform-specific details
444
+ youtube?: {
445
+ tags: string[];
446
+ postInfo: {
447
+ isAllow: boolean; // Platform enabled
448
+ currentStatus: string; // Platform status
449
+ videoURL: string; // Published video URL
450
+ socialPublisherAccount: { // Account details
451
+ name: string;
452
+ thumbnail: string;
453
+ platformAccountId: string;
454
+ };
455
+ };
456
+ };
457
+
458
+ tiktok?: { /* Similar structure */ };
459
+ facebook?: { /* Similar structure */ };
460
+ instagram?: { /* Similar structure */ };
461
+
462
+ // Workspace info
463
+ workspace: {
464
+ _id: string;
465
+ name: string;
466
+ description: string;
467
+ };
468
+
469
+ // Schedule info
470
+ schedule: {
471
+ type: 'schedule' | 'now';
472
+ scheduledAt: Date;
473
+ executedAt: Date;
474
+ };
475
+ }
476
+ ```
477
+
478
+ **Example:**
479
+
480
+ ```typescript
481
+ // Get post status
482
+ const status = await client.getStatus("post-id-here");
483
+
484
+ console.log("Post:", status.numbering);
485
+ console.log("Overall Status:", status.currentStatus);
486
+ console.log("Created:", status.createdAt);
487
+
488
+ // Check YouTube status
489
+ if (status.youtube) {
490
+ console.log("\nYouTube:");
491
+ console.log(" Status:", status.youtube.postInfo.currentStatus);
492
+ console.log(" Channel:", status.youtube.postInfo.socialPublisherAccount.name);
493
+
494
+ if (status.youtube.postInfo.videoURL) {
495
+ console.log(" Video URL:", status.youtube.postInfo.videoURL);
496
+ }
497
+ }
498
+
499
+ // Check TikTok status
500
+ if (status.tiktok) {
501
+ console.log("\nTikTok:");
502
+ console.log(" Status:", status.tiktok.postInfo.currentStatus);
503
+ console.log(" Account:", status.tiktok.postInfo.socialPublisherAccount.name);
504
+
505
+ if (status.tiktok.postInfo.videoURL) {
506
+ console.log(" Video URL:", status.tiktok.postInfo.videoURL);
507
+ }
508
+ }
509
+
510
+ // Check Facebook status
511
+ if (status.facebook) {
512
+ console.log("\nFacebook:");
513
+ console.log(" Status:", status.facebook.postInfo.currentStatus);
514
+ console.log(" Page:", status.facebook.postInfo.socialPublisherAccount.name);
515
+ }
516
+
517
+ // Check Instagram status
518
+ if (status.instagram) {
519
+ console.log("\nInstagram:");
520
+ console.log(" Status:", status.instagram.postInfo.currentStatus);
521
+ console.log(" Account:", status.instagram.postInfo.socialPublisherAccount.name);
522
+ }
523
+
524
+ // Handle errors
525
+ if (status.currentStatus === "error") {
526
+ console.error("Post failed!");
527
+
528
+ // Check which platforms failed
529
+ const failures = [];
530
+ if (status.youtube?.postInfo.currentStatus === "error") failures.push("YouTube");
531
+ if (status.tiktok?.postInfo.currentStatus === "error") failures.push("TikTok");
532
+ if (status.facebook?.postInfo.currentStatus === "error") failures.push("Facebook");
533
+ if (status.instagram?.postInfo.currentStatus === "error") failures.push("Instagram");
534
+
535
+ console.error("Failed platforms:", failures.join(", "));
536
+ }
537
+
538
+ // Monitor post progress
539
+ async function waitForCompletion(postId: string, maxWaitMs = 300000) {
540
+ const startTime = Date.now();
541
+
542
+ while (Date.now() - startTime < maxWaitMs) {
543
+ const status = await client.getStatus(postId);
544
+
545
+ console.log(`Status: ${status.currentStatus}`);
546
+
547
+ if (status.currentStatus === "done") {
548
+ console.log("✓ Publishing complete!");
549
+ return status;
550
+ }
551
+
552
+ if (status.currentStatus === "error") {
553
+ throw new Error("Publishing failed");
554
+ }
555
+
556
+ // Wait 5 seconds before checking again
557
+ await new Promise((resolve) => setTimeout(resolve, 5000));
558
+ }
559
+
560
+ throw new Error("Timeout waiting for post completion");
561
+ }
562
+
563
+ const finalStatus = await waitForCompletion("post-id");
564
+ console.log("All platforms published successfully");
565
+ ```
566
+
567
+ ---
568
+
569
+ ### getDefaultSettings()
570
+
571
+ Retrieve default configuration settings for social media publishing, including platform limits and default values.
572
+
573
+ **Parameters:** None
574
+
575
+ **Returns:** `Promise<IDefaultSettingsResponse>` - Default settings configuration
576
+
577
+ **Example:**
578
+
579
+ ```typescript
580
+ // Get default settings
581
+ const settings = await client.getDefaultSettings();
582
+
583
+ console.log("Default Settings:", settings);
584
+
585
+ // Use defaults in your application
586
+ console.log("Max video size:", client.maxVideoUploadSizeBytes, "bytes");
587
+ console.log("Max thumbnail size:", client.maxImageUploadSizeBytes, "bytes");
588
+ ```
589
+
590
+ ---
591
+
592
+ ### getNextAndPrevious()
593
+
594
+ Get the IDs of the next and previous posts for navigation purposes.
595
+
596
+ **Parameters:**
597
+
598
+ - `id` (string): Current post ID
599
+
600
+ **Returns:** `Promise<ISocialPublisherPostNextPreviousResponse>` - Next and previous post IDs
601
+
602
+ **Response Structure:**
603
+
604
+ ```typescript
605
+ {
606
+ nextId?: string; // Next post ID (if exists)
607
+ previousId?: string; // Previous post ID (if exists)
608
+ }
609
+ ```
610
+
611
+ **Example:**
612
+
613
+ ```typescript
614
+ // Get navigation IDs
615
+ const navigation = await client.getNextAndPrevious("current-post-id");
616
+
617
+ if (navigation.nextId) {
618
+ console.log("Next post:", navigation.nextId);
619
+
620
+ // Navigate to next post
621
+ const nextPost = await client.getStatus(navigation.nextId);
622
+ console.log("Next post caption:", nextPost.caption);
623
+ }
624
+
625
+ if (navigation.previousId) {
626
+ console.log("Previous post:", navigation.previousId);
627
+
628
+ // Navigate to previous post
629
+ const prevPost = await client.getStatus(navigation.previousId);
630
+ console.log("Previous post caption:", prevPost.caption);
631
+ }
632
+
633
+ // Build post navigation
634
+ async function navigateForward(startPostId: string, count: number) {
635
+ const posts = [];
636
+ let currentId = startPostId;
637
+
638
+ for (let i = 0; i < count; i++) {
639
+ const status = await client.getStatus(currentId);
640
+ posts.push(status);
641
+
642
+ const nav = await client.getNextAndPrevious(currentId);
643
+ if (!nav.nextId) break;
644
+
645
+ currentId = nav.nextId;
646
+ }
647
+
648
+ return posts;
649
+ }
650
+
651
+ const next5Posts = await navigateForward("post-id", 5);
652
+ console.log(`Retrieved ${next5Posts.length} posts`);
653
+ ```
654
+
655
+ ---
656
+
657
+ ## 🔄 Complete Workflow Example
658
+
659
+ ```typescript
660
+ import { HttpClient } from "@posty5/core";
661
+ import { SocialPublisherPostClient } from "@posty5/social-publisher-post";
662
+ import * as fs from "fs";
663
+
664
+ // Initialize client
665
+ const httpClient = new HttpClient({
666
+ apiKey: process.env.POSTY5_API_KEY!,
667
+ debug: false,
668
+ });
669
+
670
+ const client = new SocialPublisherPostClient(httpClient);
671
+
672
+ async function publishVideoWorkflow() {
673
+ try {
674
+ // 1. Prepare video and thumbnail
675
+ console.log("Preparing media files...");
676
+ const videoBuffer = fs.readFileSync("./content/video.mp4");
677
+ const thumbBuffer = fs.readFileSync("./content/thumbnail.jpg");
678
+
679
+ const video = new File([videoBuffer], "video.mp4", { type: "video/mp4" });
680
+ const thumbnail = new File([thumbBuffer], "thumb.jpg", { type: "image/jpeg" });
681
+
682
+ // 2. Publish to multiple platforms
683
+ console.log("Publishing video...");
684
+ const postId = await client.publishShortVideo({
685
+ workspaceId: "workspace-123",
686
+ video: video,
687
+ thumbnail: thumbnail,
688
+ youtube: {
689
+ title: "Product Demo 2024",
690
+ description: "Check out our latest product features",
691
+ tags: ["product", "demo", "2024"],
692
+ },
693
+ tiktok: {
694
+ caption: "New product alert! 🚀 #Product #Tech",
695
+ privacy_level: "public",
696
+ disable_duet: false,
697
+ disable_stitch: false,
698
+ disable_comment: false,
699
+ },
700
+ tag: "product-demo",
701
+ refId: "DEMO-2024-001",
702
+ });
703
+
704
+ console.log("✓ Post created:", postId);
705
+
706
+ // 3. Monitor publishing progress
707
+ console.log("\nMonitoring progress...");
708
+ let attempts = 0;
709
+ const maxAttempts = 60; // 5 minutes (5 second intervals)
710
+
711
+ while (attempts < maxAttempts) {
712
+ const status = await client.getStatus(postId);
713
+
714
+ console.log(` Status: ${status.currentStatus}`);
715
+
716
+ // Check individual platforms
717
+ if (status.youtube) {
718
+ console.log(` YouTube: ${status.youtube.postInfo.currentStatus}`);
719
+ }
720
+ if (status.tiktok) {
721
+ console.log(` TikTok: ${status.tiktok.postInfo.currentStatus}`);
722
+ }
723
+
724
+ // Check if completed
725
+ if (status.currentStatus === "done") {
726
+ console.log("\n✓ Publishing complete!");
727
+
728
+ // Get video URLs
729
+ if (status.youtube?.postInfo.videoURL) {
730
+ console.log(" YouTube URL:", status.youtube.postInfo.videoURL);
731
+ }
732
+ if (status.tiktok?.postInfo.videoURL) {
733
+ console.log(" TikTok URL:", status.tiktok.postInfo.videoURL);
734
+ }
735
+
736
+ return status;
737
+ }
738
+
739
+ // Check for errors
740
+ if (status.currentStatus === "error") {
741
+ console.error("\n✗ Publishing failed");
742
+ throw new Error("Post failed");
743
+ }
744
+
745
+ // Wait before checking again
746
+ await new Promise((resolve) => setTimeout(resolve, 5000));
747
+ attempts++;
748
+ }
749
+
750
+ throw new Error("Timeout: Post did not complete within 5 minutes");
751
+ } catch (error) {
752
+ console.error("Error:", error.message);
753
+ throw error;
754
+ }
755
+ }
756
+
757
+ // Run the workflow
758
+ publishVideoWorkflow()
759
+ .then(() => console.log("\nWorkflow completed successfully"))
760
+ .catch((err) => console.error("\nWorkflow failed:", err));
761
+ ```
762
+
763
+ ---
764
+
765
+ ## 📘 TypeScript Support
766
+
767
+ Full TypeScript support with exported interfaces:
768
+
769
+ ```typescript
770
+ import {
771
+ // Client
772
+ SocialPublisherPostClient,
773
+
774
+ // Publishing options
775
+ IPublishOptions,
776
+
777
+ // Platform configurations
778
+ IYouTubeConfig,
779
+ ITikTokConfig,
780
+ IFacebookPageConfig,
781
+ IInstagramConfig,
782
+
783
+ // Schedule configuration
784
+ IScheduleConfig,
785
+
786
+ // Optional post-publish comment (Pro plan, +1 credit)
787
+ ICommentRequest,
788
+ ICommentInfoDTO,
789
+ CommentStatusType, // 'pending' | 'processing' | 'done' | 'error' | 'skipped' | 'notSupported'
790
+
791
+ // Search parameters
792
+ IListParams,
793
+
794
+ // Response interfaces
795
+ ISocialPublisherPostStatusResponse,
796
+ ISearchSocialPublisherPostResponse,
797
+ ISocialPublisherPostNextPreviousResponse,
798
+ IDefaultSettingsResponse,
799
+
800
+ // Response types
801
+ ISocialPublisherPostResponse,
802
+ ISocialPublisherWorkspace,
803
+ ISocialPublisherAccount,
804
+
805
+ // Status types
806
+ SocialPublisherPostStatusType, // 'pending' | 'processing' | 'done' | 'error' | ...
807
+ SocialPublisherPostSourceType, // 'video-file' | 'video-url'
808
+ SocialPublisherAccountStatusType, // 'active' | 'inactive' | 'authenticationExpired'
809
+ } from "@posty5/social-publisher-post";
810
+ ```
811
+
812
+ ### Platform Configuration Types
813
+
814
+ **YouTube Configuration:**
815
+
816
+ ```typescript
817
+ interface IYouTubeConfig {
818
+ title: string; // Video title (required)
819
+ description: string; // Video description (required)
820
+ tags: string[]; // Video tags (required)
821
+ madeForKids?: boolean; // Mark as made for kids (optional)
822
+ defaultLanguage?: string; // Default language code (optional)
823
+ defaultAudioLanguage?: string; // Audio language code (optional)
824
+ categoryId?: string; // YouTube category ID (optional)
825
+ localizationLanguages?: string[]; // Localization languages (optional)
826
+ }
827
+ ```
828
+
829
+ **TikTok Configuration:**
830
+
831
+ ```typescript
832
+ interface ITikTokConfig {
833
+ caption: string; // Video caption (required)
834
+ privacy_level: string; // 'public' | 'SELF_ONLY' | 'MUTUAL_FOLLOW_FRIENDS' (required)
835
+ disable_duet: boolean; // Disable duet feature (required)
836
+ disable_stitch: boolean; // Disable stitch feature (required)
837
+ disable_comment: boolean; // Disable comments (required)
838
+ }
839
+ ```
840
+
841
+ **Facebook Configuration:**
842
+
843
+ ```typescript
844
+ interface IFacebookPageConfig {
845
+ description: string; // Post description (required)
846
+ title?: string; // Post title (optional)
847
+ }
848
+ ```
849
+
850
+ **Instagram Configuration:**
851
+
852
+ ```typescript
853
+ interface IInstagramConfig {
854
+ description: string; // Post description (required)
855
+ share_to_feed?: boolean; // Share to feed (optional)
856
+ is_published_to_both_feed_and_story?: boolean; // Publish to both (optional)
857
+ }
858
+ ```
859
+
860
+ ---
861
+
862
+ ## 📦 Related Packages
863
+
864
+ This SDK ecosystem contains the following tool packages:
865
+
866
+ | Package | Description | Version | GitHub | NPM |
867
+ | --- | --- | --- | --- | --- |
868
+ | @posty5/short-link | URL shortener client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-short-link) | [📦 NPM](https://www.npmjs.com/package/@posty5/short-link) |
869
+ | @posty5/qr-code | QR code generator client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-qr-code) | [📦 NPM](https://www.npmjs.com/package/@posty5/qr-code) |
870
+ | @posty5/html-hosting | HTML hosting client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-html-hosting) | [📦 NPM](https://www.npmjs.com/package/@posty5/html-hosting) |
871
+ | @posty5/html-hosting-variables | HTML hosting variables client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-html-hosting-variables) | [📦 NPM](https://www.npmjs.com/package/@posty5/html-hosting-variables) |
872
+ | @posty5/html-hosting-form-submission | Form submission client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-html-hosting-form-submission) | [📦 NPM](https://www.npmjs.com/package/@posty5/html-hosting-form-submission) |
873
+ | @posty5/social-publisher-workspace | Social publisher workspace client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-social-publisher-workspace) | [📦 NPM](https://www.npmjs.com/package/@posty5/social-publisher-workspace) |
874
+ | @posty5/social-publisher-post | Social publisher post client | 1.0.2 | [📖 Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-social-publisher-post) | [📦 NPM](https://www.npmjs.com/package/@posty5/social-publisher-post) |
875
+
876
+ ---
877
+
878
+ ## 💻 Node.js Compatibility
879
+
880
+ - **Node.js**: >= 16.0.0
881
+ - **Module Systems**: ESM and CommonJS
882
+ - **TypeScript**: Full type definitions included
883
+
884
+ ---
885
+
886
+ ## 🆘 Support
887
+
888
+ We're here to help you succeed with Posty5!
889
+
890
+ ### Get Help
891
+
892
+ - **Documentation**: [https://guide.posty5.com](https://guide.posty5.com)
893
+ - **Contact Us**: [https://posty5.com/contact-us](https://posty5.com/contact-us)
894
+ - **GitHub Issues**: [Report bugs or request features](https://github.com/Posty5/npm-sdk/issues)
895
+ - **API Status**: Check API status and uptime at [https://status.posty5.com](https://status.posty5.com)
896
+
897
+ ### Common Issues
898
+
899
+ 1. **Authentication Errors**
900
+ - Ensure your API key is valid and active
901
+ - Get your API key from [studio.posty5.com/account/settings?tab=APIKeys](studio.posty5.com/account/settings?tab=APIKeys)
902
+
903
+ 2. **Network Errors**
904
+ - Check your internet connection
905
+ - Verify firewall settings allow connections to `api.posty5.com`
906
+
907
+ 3. **Rate Limiting**
908
+ - The SDK includes automatic retry logic
909
+ - Check your API plan limits in the dashboard
910
+
911
+ ---
912
+
913
+ ## 📄 License
914
+
915
+ MIT License - see [LICENSE](./LICENSE) file for details.
916
+
917
+ ---
918
+
919
+ ## 🔗 Useful Links
920
+
921
+ - **Website**: [https://posty5.com](https://posty5.com)
922
+ - **Dashboard**: [studio.posty5.com/account/settings?tab=APIKeys](studio.posty5.com/account/settings?tab=APIKeys)
923
+ - **API Documentation**: [https://docs.posty5.com](https://docs.posty5.com)
924
+ - **GitHub**: [https://github.com/Posty5/npm-sdk](https://github.com/Posty5/npm-sdk)
925
+
926
+ ---
927
+
928
+ Made with ❤️ by the Posty5 team