ugcinc 2.23.0 → 2.24.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
@@ -81,6 +81,15 @@ For complete API documentation, including all endpoints, parameters, and example
81
81
  - Delete API keys
82
82
  - Edit API key names
83
83
 
84
+ ### Media
85
+ - Get all media (user_media + social_audio combined) with filters (ids, tag)
86
+ - Get social audio with filters (ids, tag)
87
+ - Create media from URLs (for files already uploaded to blob storage)
88
+ - Create social audio from TikTok video or music URLs
89
+ - Update media tags
90
+ - Delete media (also removes files from blob storage)
91
+ - Get upload handler URL for client-side uploads with @vercel/blob
92
+
84
93
  ### Render
85
94
  - Render videos from editor configurations (supports video, audio, text, image segments)
86
95
  - Render static images from editor configurations (supports text and image segments only)
@@ -479,6 +488,142 @@ if (statusResponse.ok && statusResponse.data.status === 'completed') {
479
488
  }
480
489
  ```
481
490
 
491
+ **Get media with filters:**
492
+ ```typescript
493
+ // Get all media (user_media + social_audio combined)
494
+ const response = await client.media.getMedia();
495
+
496
+ // Get media by specific IDs
497
+ const response = await client.media.getMedia({
498
+ ids: ['media-uuid-1', 'media-uuid-2']
499
+ });
500
+
501
+ // Get media by tag
502
+ const response = await client.media.getMedia({
503
+ tag: 'product-shots'
504
+ });
505
+
506
+ if (response.ok) {
507
+ response.data.forEach(item => {
508
+ console.log(`${item.id}: ${item.name} (${item.media_type})`);
509
+ // media_type is 'user_media' or 'social_audio'
510
+ });
511
+ }
512
+ ```
513
+
514
+ **Get social audio:**
515
+ ```typescript
516
+ // Get all social audio
517
+ const response = await client.media.getSocialAudio();
518
+
519
+ // Get social audio by IDs
520
+ const response = await client.media.getSocialAudio({
521
+ ids: ['audio-uuid-1']
522
+ });
523
+
524
+ // Get social audio by tag
525
+ const response = await client.media.getSocialAudio({
526
+ tag: 'trending-sounds'
527
+ });
528
+
529
+ if (response.ok) {
530
+ response.data.forEach(audio => {
531
+ console.log(`${audio.name}: ${audio.audio_url}`);
532
+ console.log(`Preview: ${audio.preview_url}`);
533
+ console.log(`TikTok link: ${audio.social_audio_link}`);
534
+ });
535
+ }
536
+ ```
537
+
538
+ **Create media from URLs:**
539
+ ```typescript
540
+ // Create media records from URLs (files already in blob storage)
541
+ const response = await client.media.create({
542
+ urls: [
543
+ 'https://your-blob-storage.com/video1.mp4',
544
+ 'https://your-blob-storage.com/image1.jpg'
545
+ ],
546
+ tag: 'campaign-assets'
547
+ });
548
+
549
+ if (response.ok) {
550
+ console.log(`Created ${response.data.data.length} media items`);
551
+ response.data.data.forEach(item => {
552
+ console.log(` - ${item.name}: ${item.url}`);
553
+ });
554
+ }
555
+ ```
556
+
557
+ **Create social audio from TikTok:**
558
+ ```typescript
559
+ // Import audio from a TikTok video URL
560
+ const response = await client.media.createSocialAudio({
561
+ url: 'https://www.tiktok.com/@username/video/1234567890',
562
+ tag: 'viral-sounds'
563
+ });
564
+
565
+ // Or import from a TikTok music/sound URL
566
+ const response = await client.media.createSocialAudio({
567
+ url: 'https://www.tiktok.com/music/original-sound-1234567890',
568
+ tag: 'trending'
569
+ });
570
+
571
+ if (response.ok) {
572
+ const audio = response.data;
573
+ console.log(`Imported: ${audio.name}`);
574
+ console.log(`Audio URL: ${audio.audio_url}`);
575
+ console.log(`Preview image: ${audio.preview_url}`);
576
+ console.log(`Original TikTok post: ${audio.social_post_link}`);
577
+ }
578
+ ```
579
+
580
+ **Update media tag:**
581
+ ```typescript
582
+ const response = await client.media.updateTag({
583
+ id: 'media-uuid',
584
+ tag: 'new-tag-name'
585
+ });
586
+
587
+ if (response.ok) {
588
+ console.log(`Updated tag for ${response.data.name}`);
589
+ }
590
+ ```
591
+
592
+ **Delete media:**
593
+ ```typescript
594
+ // Delete one or more media items (also removes files from blob storage)
595
+ const response = await client.media.delete({
596
+ ids: ['media-uuid-1', 'media-uuid-2']
597
+ });
598
+
599
+ if (response.ok) {
600
+ console.log(`Deleted: ${response.data.deleted.join(', ')}`);
601
+ if (response.data.failed?.length) {
602
+ console.log('Failed to delete:', response.data.failed);
603
+ }
604
+ }
605
+ ```
606
+
607
+ **Client-side uploads with @vercel/blob:**
608
+ ```typescript
609
+ import { upload } from '@vercel/blob/client';
610
+
611
+ // Get the upload handler URL
612
+ const uploadUrl = client.media.getUploadHandlerUrl();
613
+
614
+ // Upload file directly from browser
615
+ const blob = await upload(file.name, file, {
616
+ access: 'public',
617
+ handleUploadUrl: uploadUrl
618
+ });
619
+
620
+ // Then create the media record
621
+ const response = await client.media.create({
622
+ urls: [blob.url],
623
+ tag: 'user-uploads'
624
+ });
625
+ ```
626
+
482
627
  **Statistics:**
483
628
  ```typescript
484
629
  // Get latest stats (one record per account/post)
@@ -536,7 +681,16 @@ if (refreshResult.ok) {
536
681
  This package is written in TypeScript and provides full type definitions:
537
682
 
538
683
  ```typescript
539
- import type { Account, Post, Task, ApiKey, ApiResponse } from 'ugcinc';
684
+ import type {
685
+ Account,
686
+ Post,
687
+ Task,
688
+ ApiKey,
689
+ Media,
690
+ UserMedia,
691
+ SocialAudio,
692
+ ApiResponse
693
+ } from 'ugcinc';
540
694
  ```
541
695
 
542
696
  ## License
package/dist/media.d.ts CHANGED
@@ -1,14 +1,20 @@
1
1
  import { BaseClient } from './base';
2
- import type { Media, UserMedia, SocialAudio, GetMediaParams, UploadMediaResponse, UpdateMediaTagParams, DeleteMediaParams, DeleteMediaResponse, CreateSocialAudioParams, CreateMediaFromUrlParams, ApiResponse } from './types';
2
+ import type { Media, UserMedia, SocialAudio, GetMediaParams, GetSocialAudioParams, UploadMediaResponse, UpdateMediaTagParams, DeleteMediaParams, DeleteMediaResponse, CreateSocialAudioParams, CreateMediaFromUrlParams, ApiResponse } from './types';
3
3
  /**
4
4
  * Client for managing media files
5
5
  */
6
6
  export declare class MediaClient extends BaseClient {
7
7
  /**
8
- * Get all media for the organization
8
+ * Get media for the organization
9
9
  * Returns both user_media and social_audio combined
10
+ * Can filter by ids or tag
10
11
  */
11
12
  getMedia(params?: GetMediaParams): Promise<ApiResponse<Media[]>>;
13
+ /**
14
+ * Get social audio for the organization
15
+ * Can filter by ids or tag
16
+ */
17
+ getSocialAudio(params?: GetSocialAudioParams): Promise<ApiResponse<SocialAudio[]>>;
12
18
  /**
13
19
  * Create media from URL(s)
14
20
  * Creates media records from files already uploaded to blob storage
@@ -27,7 +33,6 @@ export declare class MediaClient extends BaseClient {
27
33
  updateTag(params: UpdateMediaTagParams): Promise<ApiResponse<UserMedia | SocialAudio>>;
28
34
  /**
29
35
  * Delete one or more media items
30
- * Supports both single id and bulk ids
31
36
  * Also deletes the files from blob storage
32
37
  */
33
38
  delete(params: DeleteMediaParams): Promise<ApiResponse<DeleteMediaResponse>>;
@@ -36,13 +41,4 @@ export declare class MediaClient extends BaseClient {
36
41
  * Extracts audio and cover image from TikTok video or music URL
37
42
  */
38
43
  createSocialAudio(params: CreateSocialAudioParams): Promise<ApiResponse<SocialAudio>>;
39
- /**
40
- * Get a media item by ID
41
- * Returns either user_media or social_audio based on what's found
42
- */
43
- getById(id: string): Promise<ApiResponse<Media>>;
44
- /**
45
- * Get a social audio by ID
46
- */
47
- getSocialAudioById(id: string): Promise<ApiResponse<SocialAudio>>;
48
44
  }
package/dist/media.js CHANGED
@@ -7,12 +7,20 @@ const base_1 = require("./base");
7
7
  */
8
8
  class MediaClient extends base_1.BaseClient {
9
9
  /**
10
- * Get all media for the organization
10
+ * Get media for the organization
11
11
  * Returns both user_media and social_audio combined
12
+ * Can filter by ids or tag
12
13
  */
13
14
  async getMedia(params) {
14
15
  return this.post('/media', params ?? {});
15
16
  }
17
+ /**
18
+ * Get social audio for the organization
19
+ * Can filter by ids or tag
20
+ */
21
+ async getSocialAudio(params) {
22
+ return this.post('/media/social-audio', params ?? {});
23
+ }
16
24
  /**
17
25
  * Create media from URL(s)
18
26
  * Creates media records from files already uploaded to blob storage
@@ -41,7 +49,6 @@ class MediaClient extends base_1.BaseClient {
41
49
  }
42
50
  /**
43
51
  * Delete one or more media items
44
- * Supports both single id and bulk ids
45
52
  * Also deletes the files from blob storage
46
53
  */
47
54
  async delete(params) {
@@ -52,20 +59,7 @@ class MediaClient extends base_1.BaseClient {
52
59
  * Extracts audio and cover image from TikTok video or music URL
53
60
  */
54
61
  async createSocialAudio(params) {
55
- return this.post('/media/social-audio', params);
56
- }
57
- /**
58
- * Get a media item by ID
59
- * Returns either user_media or social_audio based on what's found
60
- */
61
- async getById(id) {
62
- return this.post(`/media/${id}`, {});
63
- }
64
- /**
65
- * Get a social audio by ID
66
- */
67
- async getSocialAudioById(id) {
68
- return this.post(`/media/social-audio/${id}`, {});
62
+ return this.post('/media/social-audio/upload', params);
69
63
  }
70
64
  }
71
65
  exports.MediaClient = MediaClient;
package/dist/types.d.ts CHANGED
@@ -668,6 +668,11 @@ export interface SocialAudio {
668
668
  }
669
669
  export type Media = UserMedia | SocialAudio;
670
670
  export interface GetMediaParams {
671
+ ids?: string[];
672
+ tag?: string;
673
+ }
674
+ export interface GetSocialAudioParams {
675
+ ids?: string[];
671
676
  tag?: string;
672
677
  }
673
678
  export interface UploadMediaParams {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "2.23.0",
3
+ "version": "2.24.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",