ugcinc 1.0.0 → 1.0.1

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
@@ -5,14 +5,14 @@ Official TypeScript/JavaScript client for the UGC Inc API.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install ugcinc
8
+ npm i ugcinc
9
9
  ```
10
10
 
11
11
  ## Getting Started
12
12
 
13
13
  ### 1. Get Your API Key
14
14
 
15
- Contact UGC Inc to obtain your API key. You'll need this to authenticate all API requests.
15
+ Get your API key at **https://ugc.inc**. You'll need this to authenticate all API requests.
16
16
 
17
17
  ### 2. Initialize the Client
18
18
 
@@ -20,8 +20,7 @@ Contact UGC Inc to obtain your API key. You'll need this to authenticate all API
20
20
  import { UGCClient } from 'ugcinc';
21
21
 
22
22
  const client = new UGCClient({
23
- apiKey: 'your-api-key-here',
24
- baseUrl: 'https://api.ugcinc.com' // Optional, only needed if using a custom endpoint
23
+ apiKey: 'your-api-key-here'
25
24
  });
26
25
  ```
27
26
 
@@ -307,6 +306,521 @@ const client = new UGCClient({
307
306
  });
308
307
  ```
309
308
 
309
+ ---
310
+
311
+ ## Complete API Reference
312
+
313
+ ### Accounts API
314
+
315
+ #### `client.accounts.getAccounts(params?)`
316
+
317
+ Retrieve accounts with optional filters.
318
+
319
+ **Endpoint:** `POST /accounts`
320
+
321
+ **Parameters:**
322
+
323
+ | Parameter | Type | Required | Description |
324
+ |-----------|------|----------|-------------|
325
+ | `tag` | `string` | No | Filter by tag |
326
+ | `org_group` | `string` | No | Filter by organization group |
327
+ | `user_group` | `string` | No | Filter by user group |
328
+
329
+ **Returns:** `ApiResponse<Account[]>`
330
+
331
+ Returns an array of Account objects matching the specified filters. If no filters are provided, returns all accounts for your organization.
332
+
333
+ **Account Object:**
334
+
335
+ ```typescript
336
+ {
337
+ id: string; // Unique account identifier
338
+ type: string; // Account type ('tiktok' or 'instagram')
339
+ tag: string | null; // Custom tag for categorization
340
+ org_group: string | null; // Organization group identifier
341
+ user_group: string | null; // User group identifier
342
+ username: string | null; // Account username/handle
343
+ nick_name: string | null; // Account display name
344
+ pfp_url: string | null; // Profile picture URL
345
+ }
346
+ ```
347
+
348
+ | Field | Type | Description |
349
+ |-------|------|-------------|
350
+ | `id` | `string` | Unique account identifier |
351
+ | `type` | `string` | Account platform type (`'tiktok'` or `'instagram'`) |
352
+ | `tag` | `string \| null` | Custom tag for categorization |
353
+ | `org_group` | `string \| null` | Organization group identifier for grouping |
354
+ | `user_group` | `string \| null` | User group identifier for grouping |
355
+ | `username` | `string \| null` | Account username/handle on the platform |
356
+ | `nick_name` | `string \| null` | Display name shown on profile |
357
+ | `pfp_url` | `string \| null` | URL to account's profile picture |
358
+
359
+ **Example:**
360
+
361
+ ```typescript
362
+ const response = await client.accounts.getAccounts({
363
+ tag: 'influencer',
364
+ org_group: 'group1'
365
+ });
366
+ ```
367
+
368
+ ---
369
+
370
+ #### `client.accounts.getStats(params?)`
371
+
372
+ Get account statistics.
373
+
374
+ **Endpoint:** `POST /accounts/stats`
375
+
376
+ **Parameters:**
377
+
378
+ | Parameter | Type | Required | Description |
379
+ |-----------|------|----------|-------------|
380
+ | `accountIds` | `string[]` | No | Array of account IDs to get stats for |
381
+ | `startDate` | `string` | No | Start date (ISO 8601 format) |
382
+ | `endDate` | `string` | No | End date (ISO 8601 format) |
383
+ | `tag` | `string` | No | Filter by tag |
384
+ | `org_group` | `string` | No | Filter by organization group |
385
+ | `user_group` | `string` | No | Filter by user group |
386
+
387
+ **Returns:** `ApiResponse<AccountStat[]>`
388
+
389
+ Returns an array of AccountStat objects containing follower counts, views, likes, and other metrics for the specified accounts and date range.
390
+
391
+ **AccountStat Object:**
392
+
393
+ ```typescript
394
+ {
395
+ id: string; // Unique stat record identifier
396
+ account_id: string; // Associated account ID
397
+ followers: number | null; // Follower count
398
+ following: number | null; // Following count
399
+ views: number | null; // Total profile views
400
+ likes: number | null; // Total likes received
401
+ created_at: string; // Timestamp when stat was recorded
402
+ }
403
+ ```
404
+
405
+ | Field | Type | Description |
406
+ |-------|------|-------------|
407
+ | `id` | `string` | Unique identifier for this stat record |
408
+ | `account_id` | `string` | ID of the account these stats belong to |
409
+ | `followers` | `number \| null` | Total number of followers |
410
+ | `following` | `number \| null` | Total number of accounts being followed |
411
+ | `views` | `number \| null` | Total profile/content views |
412
+ | `likes` | `number \| null` | Total likes received across all content |
413
+ | `created_at` | `string` | ISO 8601 timestamp when this stat was recorded |
414
+
415
+ **Example:**
416
+
417
+ ```typescript
418
+ const response = await client.accounts.getStats({
419
+ accountIds: ['account-1', 'account-2'],
420
+ startDate: '2024-01-01T00:00:00Z',
421
+ endDate: '2024-12-31T23:59:59Z'
422
+ });
423
+ ```
424
+
425
+ ---
426
+
427
+ #### `client.accounts.getStatus(params)`
428
+
429
+ Get account status and pending tasks.
430
+
431
+ **Endpoint:** `POST /accounts/status`
432
+
433
+ **Parameters:**
434
+
435
+ | Parameter | Type | Required | Description |
436
+ |-----------|------|----------|-------------|
437
+ | `accountId` | `string` | **Yes** | Account ID to check status for |
438
+ | `includeCompleted` | `boolean` | No | Include completed tasks (default: false) |
439
+
440
+ **Returns:** `ApiResponse<AccountTask[]>`
441
+
442
+ Returns an array of AccountTask objects showing pending and (optionally) completed tasks for the specified account. Tasks include profile edits and other account-level operations.
443
+
444
+ **AccountTask Object:**
445
+
446
+ ```typescript
447
+ {
448
+ id: string; // Unique task identifier
449
+ account_id: string; // Associated account ID
450
+ type: string; // Task type
451
+ status: string; // Current task status
452
+ scheduled_time: string | null; // When task is scheduled to run
453
+ edit_profile_info: EditProfileInfo | null; // Profile update details (if type is 'edit_profile')
454
+ created_at: string; // When task was created
455
+ }
456
+ ```
457
+
458
+ | Field | Type | Description |
459
+ |-------|------|-------------|
460
+ | `id` | `string` | Unique identifier for this task |
461
+ | `account_id` | `string` | ID of the account this task belongs to |
462
+ | `type` | `string` | Task type (e.g., `'edit_profile'`, `'warmup_scroll'`) |
463
+ | `status` | `string` | Current task status (`'scheduled'`, `'pending'`, `'complete'`, `'failed'`) |
464
+ | `scheduled_time` | `string \| null` | ISO 8601 timestamp when task is scheduled to execute |
465
+ | `edit_profile_info` | `EditProfileInfo \| null` | Profile update information (only for `edit_profile` tasks) |
466
+ | `created_at` | `string` | ISO 8601 timestamp when task was created |
467
+
468
+ **Example:**
469
+
470
+ ```typescript
471
+ const response = await client.accounts.getStatus({
472
+ accountId: 'account-id',
473
+ includeCompleted: true
474
+ });
475
+ ```
476
+
477
+ ---
478
+
479
+ #### `client.accounts.updateInfo(params)`
480
+
481
+ Update account profile information.
482
+
483
+ **Endpoint:** `POST /accounts/update-info`
484
+
485
+ **Parameters:**
486
+
487
+ | Parameter | Type | Required | Description |
488
+ |-----------|------|----------|-------------|
489
+ | `accountId` | `string` | **Yes** | Account ID to update |
490
+ | `scheduledTime` | `string` | No | When to schedule the update (ISO 8601 format) |
491
+ | `avatarUrl` | `string` | No | New avatar/profile picture URL |
492
+ | `nickName` | `string` | No | New display name |
493
+ | `bio` | `string` | No | New bio text |
494
+ | `site` | `string` | No | New website URL |
495
+
496
+ **Returns:** `ApiResponse<{ message: string }>`
497
+
498
+ Returns a success message when the profile update task has been successfully created and queued. The actual profile update will be processed asynchronously.
499
+
500
+ **Response Object:**
501
+
502
+ ```typescript
503
+ {
504
+ message: string; // Success message (e.g., "Profile update task created successfully")
505
+ }
506
+ ```
507
+
508
+ **Example:**
509
+
510
+ ```typescript
511
+ const response = await client.accounts.updateInfo({
512
+ accountId: 'account-id',
513
+ nickName: 'Cool Creator',
514
+ bio: 'Content creator 🎥',
515
+ avatarUrl: 'https://storage.example.com/avatar.jpg'
516
+ });
517
+ ```
518
+
519
+ ---
520
+
521
+ ### Tasks API
522
+
523
+ #### `client.tasks.getTasks(params?)`
524
+
525
+ Retrieve tasks with optional filters.
526
+
527
+ **Endpoint:** `POST /tasks`
528
+
529
+ **Parameters:**
530
+
531
+ | Parameter | Type | Required | Description |
532
+ |-----------|------|----------|-------------|
533
+ | `accountIds` | `string[]` | No | Filter by account IDs |
534
+ | `startDate` | `string` | No | Start date (ISO 8601 format) |
535
+ | `endDate` | `string` | No | End date (ISO 8601 format) |
536
+ | `taskType` | `TaskType` | No | Filter by task type |
537
+
538
+ **TaskType:** `'warmup_scroll' | 'warmup_search_term' | 'warmup_search_profile' | 'edit_profile'`
539
+
540
+ **Returns:** `ApiResponse<Task[]>`
541
+
542
+ Returns an array of Task objects including warmup tasks (scrolling, searching) and profile edit tasks for the specified accounts and date range. Each task includes scheduling information and type-specific parameters.
543
+
544
+ **Task Object:**
545
+
546
+ ```typescript
547
+ {
548
+ id: string; // Unique task identifier
549
+ account_id: string; // Associated account ID
550
+ type: TaskType; // Task type
551
+ status: string; // Current status
552
+ scheduled_time: string | null; // When task is scheduled
553
+ duration: number | null; // Task duration in seconds
554
+ keywords: string[] | null; // Keywords for search tasks
555
+ edit_profile_info: EditProfileInfo | null; // Profile info for edit tasks
556
+ created_at: string; // Creation timestamp
557
+ }
558
+ ```
559
+
560
+ | Field | Type | Description |
561
+ |-------|------|-------------|
562
+ | `id` | `string` | Unique identifier for this task |
563
+ | `account_id` | `string` | ID of the account this task belongs to |
564
+ | `type` | `TaskType` | Task type: `'warmup_scroll'`, `'warmup_search_term'`, `'warmup_search_profile'`, or `'edit_profile'` |
565
+ | `status` | `string` | Current status: `'scheduled'`, `'pending'`, `'complete'`, or `'failed'` |
566
+ | `scheduled_time` | `string \| null` | ISO 8601 timestamp when task should execute |
567
+ | `duration` | `number \| null` | Task duration in seconds (for warmup tasks) |
568
+ | `keywords` | `string[] \| null` | Array of keywords (for search tasks) |
569
+ | `edit_profile_info` | `EditProfileInfo \| null` | Profile update details (for `edit_profile` tasks) |
570
+ | `created_at` | `string` | ISO 8601 timestamp when task was created |
571
+
572
+ **Example:**
573
+
574
+ ```typescript
575
+ const response = await client.tasks.getTasks({
576
+ accountIds: ['account-1', 'account-2'],
577
+ taskType: 'edit_profile',
578
+ startDate: '2024-01-01T00:00:00Z'
579
+ });
580
+ ```
581
+
582
+ ---
583
+
584
+ ### Posts API
585
+
586
+ #### `client.posts.getPosts(params?)`
587
+
588
+ Retrieve posts with optional filters.
589
+
590
+ **Endpoint:** `POST /post`
591
+
592
+ **Parameters:**
593
+
594
+ | Parameter | Type | Required | Description |
595
+ |-----------|------|----------|-------------|
596
+ | `accountIds` | `string[]` | No | Filter by account IDs |
597
+ | `startDate` | `string` | No | Start date (ISO 8601 format) |
598
+ | `endDate` | `string` | No | End date (ISO 8601 format) |
599
+
600
+ **Returns:** `ApiResponse<Post[]>`
601
+
602
+ Returns an array of Post objects (videos and slideshows) for the specified accounts and date range. Includes post status, URLs, captions, and associated media.
603
+
604
+ **Post Object:**
605
+
606
+ ```typescript
607
+ {
608
+ id: string; // Unique post identifier
609
+ account_id: string; // Account that posted this
610
+ type: 'video' | 'slideshow'; // Post type
611
+ status: string; // Current post status
612
+ post_url: string | null; // URL to the live post
613
+ caption: string | null; // Post caption/description
614
+ media_urls: string[] | null; // URLs to media files
615
+ music_post_id: string | null; // Associated music/audio ID
616
+ }
617
+ ```
618
+
619
+ | Field | Type | Description |
620
+ |-------|------|-------------|
621
+ | `id` | `string` | Unique identifier for this post |
622
+ | `account_id` | `string` | ID of the account that created this post |
623
+ | `type` | `'video' \| 'slideshow'` | Type of post content |
624
+ | `status` | `string` | Current status: `'scheduled'`, `'pending'`, `'complete'`, or `'failed'` |
625
+ | `post_url` | `string \| null` | URL to the live post on the platform (available after posting) |
626
+ | `caption` | `string \| null` | Post caption/description text (max 500 characters) |
627
+ | `media_urls` | `string[] \| null` | Array of URLs to video/image files used in the post |
628
+ | `music_post_id` | `string \| null` | ID of the music/audio track used in the post |
629
+
630
+ **Example:**
631
+
632
+ ```typescript
633
+ const response = await client.posts.getPosts({
634
+ accountIds: ['account-1'],
635
+ startDate: '2024-01-01T00:00:00Z',
636
+ endDate: '2024-12-31T23:59:59Z'
637
+ });
638
+ ```
639
+
640
+ ---
641
+
642
+ #### `client.posts.createSlideshow(params)`
643
+
644
+ Create a slideshow post from multiple images.
645
+
646
+ **Endpoint:** `POST /post/slideshow`
647
+
648
+ **Parameters:**
649
+
650
+ | Parameter | Type | Required | Description |
651
+ |-----------|------|----------|-------------|
652
+ | `accountId` | `string` | **Yes** | Account ID to post from |
653
+ | `imageUrls` | `string[]` | **Yes** | Array of image URLs (at least 1 required) |
654
+ | `caption` | `string` | No | Post caption (max 500 characters) |
655
+ | `musicPostId` | `string` | No | Music/audio post ID to use |
656
+ | `postTime` | `string` | No | When to schedule the post (ISO 8601) |
657
+ | `strict` | `boolean` | No | Strict mode (default: true) |
658
+
659
+ **Returns:** `ApiResponse<Post>`
660
+
661
+ Returns a Post object for the newly created slideshow. The post will be scheduled for publishing based on the `postTime` parameter (or immediately if not specified). The `status` field indicates whether it's scheduled, pending, or complete.
662
+
663
+ **Example:**
664
+
665
+ ```typescript
666
+ const response = await client.posts.createSlideshow({
667
+ accountId: 'account-id',
668
+ imageUrls: [
669
+ 'https://storage.example.com/img1.jpg',
670
+ 'https://storage.example.com/img2.jpg',
671
+ 'https://storage.example.com/img3.jpg'
672
+ ],
673
+ caption: 'Check out these photos! 📸',
674
+ postTime: '2024-12-25T12:00:00Z'
675
+ });
676
+ ```
677
+
678
+ ---
679
+
680
+ #### `client.posts.createVideo(params)`
681
+
682
+ Create a video post.
683
+
684
+ **Endpoint:** `POST /post/video`
685
+
686
+ **Parameters:**
687
+
688
+ | Parameter | Type | Required | Description |
689
+ |-----------|------|----------|-------------|
690
+ | `accountId` | `string` | **Yes** | Account ID to post from |
691
+ | `videoUrl` | `string` | **Yes** | Video file URL |
692
+ | `caption` | `string` | No | Post caption (max 500 characters) |
693
+ | `musicPostId` | `string` | No | Music/audio post ID to use |
694
+ | `postTime` | `string` | No | When to schedule the post (ISO 8601) |
695
+ | `strict` | `boolean` | No | Strict mode (default: true) |
696
+
697
+ **Returns:** `ApiResponse<Post>`
698
+
699
+ Returns a Post object for the newly created video post. The post will be scheduled for publishing based on the `postTime` parameter (or immediately if not specified). The `status` field indicates whether it's scheduled, pending, or complete.
700
+
701
+ **Example:**
702
+
703
+ ```typescript
704
+ const response = await client.posts.createVideo({
705
+ accountId: 'account-id',
706
+ videoUrl: 'https://storage.example.com/video.mp4',
707
+ caption: 'My awesome video! 🎥 #viral',
708
+ strict: false
709
+ });
710
+ ```
711
+
712
+ ---
713
+
714
+ #### `client.posts.getStats(params?)`
715
+
716
+ Get post statistics.
717
+
718
+ **Endpoint:** `POST /post/stats`
719
+
720
+ **Parameters:**
721
+
722
+ | Parameter | Type | Required | Description |
723
+ |-----------|------|----------|-------------|
724
+ | `postIds` | `string[]` | No | Array of post IDs to get stats for |
725
+ | `startDate` | `string` | No | Start date (ISO 8601 format) |
726
+ | `endDate` | `string` | No | End date (ISO 8601 format) |
727
+
728
+ **Returns:** `ApiResponse<PostStat[]>`
729
+
730
+ Returns an array of PostStat objects containing engagement metrics (views, likes, comments, shares, saves) for the specified posts and date range. Use this to track post performance over time.
731
+
732
+ **PostStat Object:**
733
+
734
+ ```typescript
735
+ {
736
+ id: string; // Unique stat record identifier
737
+ post_id: string; // Associated post ID
738
+ views: number | null; // View count
739
+ likes: number | null; // Like count
740
+ comments: number | null; // Comment count
741
+ shares: number | null; // Share count
742
+ saves: number | null; // Save/bookmark count
743
+ created_at: string; // When stat was recorded
744
+ }
745
+ ```
746
+
747
+ | Field | Type | Description |
748
+ |-------|------|-------------|
749
+ | `id` | `string` | Unique identifier for this stat record |
750
+ | `post_id` | `string` | ID of the post these stats belong to |
751
+ | `views` | `number \| null` | Total number of views the post received |
752
+ | `likes` | `number \| null` | Total number of likes the post received |
753
+ | `comments` | `number \| null` | Total number of comments on the post |
754
+ | `shares` | `number \| null` | Total number of times the post was shared |
755
+ | `saves` | `number \| null` | Total number of times the post was saved/bookmarked |
756
+ | `created_at` | `string` | ISO 8601 timestamp when this stat was recorded |
757
+
758
+ **Example:**
759
+
760
+ ```typescript
761
+ const response = await client.posts.getStats({
762
+ postIds: ['post-1', 'post-2', 'post-3'],
763
+ startDate: '2024-01-01T00:00:00Z'
764
+ });
765
+
766
+ if (response.ok) {
767
+ response.data.forEach(stat => {
768
+ console.log(`Post ${stat.post_id}:`);
769
+ console.log(` Views: ${stat.views}`);
770
+ console.log(` Likes: ${stat.likes}`);
771
+ console.log(` Engagement: ${(stat.likes ?? 0) + (stat.comments ?? 0)}`);
772
+ });
773
+ }
774
+ ```
775
+
776
+ ---
777
+
778
+ #### `client.posts.getStatus(params)`
779
+
780
+ Get the status of a specific post.
781
+
782
+ **Endpoint:** `POST /post/status`
783
+
784
+ **Parameters:**
785
+
786
+ | Parameter | Type | Required | Description |
787
+ |-----------|------|----------|-------------|
788
+ | `postId` | `string` | **Yes** | Post ID to check status for |
789
+
790
+ **Returns:** `ApiResponse<{ post_id: string; status: string }>`
791
+
792
+ Returns the current status of the specified post. Use this to check if a post has been successfully published or if there were any issues.
793
+
794
+ **Response Object:**
795
+
796
+ ```typescript
797
+ {
798
+ post_id: string; // ID of the post being checked
799
+ status: string; // Current status
800
+ }
801
+ ```
802
+
803
+ **Status Values:** `'scheduled' | 'pending' | 'complete' | 'failed'`
804
+
805
+ - `'scheduled'` - Post is scheduled to be published at a future time
806
+ - `'pending'` - Post is currently being processed/published
807
+ - `'complete'` - Post was successfully published
808
+ - `'failed'` - Post failed to publish (check error logs)
809
+
810
+ **Example:**
811
+
812
+ ```typescript
813
+ const response = await client.posts.getStatus({
814
+ postId: 'post-id'
815
+ });
816
+
817
+ if (response.ok) {
818
+ console.log(`Post status: ${response.data.status}`);
819
+ }
820
+ ```
821
+
822
+ ---
823
+
310
824
  ## License
311
825
 
312
826
  MIT
package/dist/base.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import type { ApiResponse } from './types';
2
2
  export interface ClientConfig {
3
3
  apiKey: string;
4
- baseUrl?: string;
5
4
  }
6
5
  export declare class BaseClient {
7
6
  protected apiKey: string;
8
- protected baseUrl: string;
7
+ private readonly baseUrl;
9
8
  constructor(config: ClientConfig);
10
9
  protected request<T>(endpoint: string, options?: RequestInit): Promise<ApiResponse<T>>;
11
10
  protected post<T>(endpoint: string, body?: unknown): Promise<ApiResponse<T>>;
package/dist/base.js CHANGED
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseClient = void 0;
4
4
  class BaseClient {
5
5
  constructor(config) {
6
+ this.baseUrl = 'https://api.ugc.inc';
6
7
  this.apiKey = config.apiKey;
7
- this.baseUrl = config.baseUrl ?? 'https://api.ugc.inc';
8
8
  }
9
9
  async request(endpoint, options = {}) {
10
10
  const url = `${this.baseUrl}${endpoint}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",