ugcinc 2.24.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.
Files changed (2) hide show
  1. package/README.md +155 -1
  2. package/package.json +1 -1
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "2.24.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",