ugcinc 1.0.3 → 1.0.4

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
@@ -66,6 +66,24 @@ if (response.ok) {
66
66
  }
67
67
  ```
68
68
 
69
+ #### Refresh Account Statistics
70
+
71
+ Fetch live statistics from TikTok API and create new stat records.
72
+
73
+ ```typescript
74
+ const response = await client.accounts.refreshStats({
75
+ accountIds: ['account-id-1', 'account-id-2'],
76
+ tag: 'influencer'
77
+ });
78
+
79
+ if (response.ok) {
80
+ console.log(`Refreshed stats for ${response.data.length} accounts`);
81
+ response.data.forEach(stat => {
82
+ console.log(`Account ${stat.account_id}: ${stat.followers} followers`);
83
+ });
84
+ }
85
+ ```
86
+
69
87
  #### Get Account Status
70
88
 
71
89
  Get the status of tasks for a specific account.
@@ -200,6 +218,23 @@ if (response.ok) {
200
218
  }
201
219
  ```
202
220
 
221
+ #### Refresh Post Statistics
222
+
223
+ Fetch live statistics from TikTok API and create new stat records.
224
+
225
+ ```typescript
226
+ const response = await client.posts.refreshStats({
227
+ postIds: ['post-id-1', 'post-id-2']
228
+ });
229
+
230
+ if (response.ok) {
231
+ console.log(`Refreshed stats for ${response.data.length} posts`);
232
+ response.data.forEach(stat => {
233
+ console.log(`Post ${stat.post_id}: ${stat.views} views, ${stat.likes} likes`);
234
+ });
235
+ }
236
+ ```
237
+
203
238
  #### Get Post Status
204
239
 
205
240
  Get the status of a specific post.
@@ -424,6 +459,49 @@ const response = await client.accounts.getStats({
424
459
 
425
460
  ---
426
461
 
462
+ #### `client.accounts.refreshStats(params?)`
463
+
464
+ Refresh account statistics by fetching live data from TikTok API.
465
+
466
+ **Endpoint:** `POST /accounts/stats/refresh`
467
+
468
+ **Parameters:**
469
+
470
+ | Parameter | Type | Required | Description |
471
+ |-----------|------|----------|-------------|
472
+ | `accountIds` | `string[]` | No | Array of account IDs to refresh stats for |
473
+ | `tag` | `string` | No | Filter by tag |
474
+ | `org_group` | `string` | No | Filter by organization group |
475
+ | `user_group` | `string` | No | Filter by user group |
476
+
477
+ **Returns:** `ApiResponse<AccountStat[]>`
478
+
479
+ Returns an array of newly created AccountStat objects with live data from TikTok. This endpoint fetches fresh statistics directly from the TikTok API and creates new stat records in the database. Use this when you need up-to-date metrics instead of historical data.
480
+
481
+ **Key Differences from `getStats()`:**
482
+ - `refreshStats()` fetches **live data** from TikTok API and creates new records
483
+ - `getStats()` retrieves **historical data** from your database
484
+
485
+ **Example:**
486
+
487
+ ```typescript
488
+ const response = await client.accounts.refreshStats({
489
+ accountIds: ['account-1', 'account-2'],
490
+ tag: 'influencer'
491
+ });
492
+
493
+ if (response.ok) {
494
+ console.log(`Successfully refreshed ${response.data.length} accounts`);
495
+ response.data.forEach(stat => {
496
+ console.log(`Account ${stat.account_id}:`);
497
+ console.log(` Followers: ${stat.followers}`);
498
+ console.log(` Views: ${stat.views}`);
499
+ });
500
+ }
501
+ ```
502
+
503
+ ---
504
+
427
505
  #### `client.accounts.getStatus(params)`
428
506
 
429
507
  Get account status and pending tasks.
@@ -775,6 +853,52 @@ if (response.ok) {
775
853
 
776
854
  ---
777
855
 
856
+ #### `client.posts.refreshStats(params?)`
857
+
858
+ Refresh post statistics by fetching live data from TikTok API.
859
+
860
+ **Endpoint:** `POST /post/stats/refresh`
861
+
862
+ **Parameters:**
863
+
864
+ | Parameter | Type | Required | Description |
865
+ |-----------|------|----------|-------------|
866
+ | `postIds` | `string[]` | No | Array of post IDs to refresh stats for |
867
+
868
+ **Returns:** `ApiResponse<PostStat[]>`
869
+
870
+ Returns an array of newly created PostStat objects with live data from TikTok. This endpoint fetches fresh statistics directly from the TikTok API and creates new stat records in the database. Use this when you need up-to-date engagement metrics instead of historical data.
871
+
872
+ **Key Differences from `getStats()`:**
873
+ - `refreshStats()` fetches **live data** from TikTok API and creates new records
874
+ - `getStats()` retrieves **historical data** from your database
875
+
876
+ **Important:** Posts must have a valid `post_url` to refresh statistics. The endpoint extracts the TikTok post ID from the URL to fetch live metrics.
877
+
878
+ **Example:**
879
+
880
+ ```typescript
881
+ const response = await client.posts.refreshStats({
882
+ postIds: ['post-1', 'post-2', 'post-3']
883
+ });
884
+
885
+ if (response.ok) {
886
+ console.log(`Successfully refreshed ${response.data.length} posts`);
887
+ response.data.forEach(stat => {
888
+ console.log(`Post ${stat.post_id}:`);
889
+ console.log(` Views: ${stat.views}`);
890
+ console.log(` Likes: ${stat.likes}`);
891
+ console.log(` Comments: ${stat.comments}`);
892
+ console.log(` Engagement Rate: ${((stat.likes ?? 0) / (stat.views ?? 1) * 100).toFixed(2)}%`);
893
+ });
894
+ }
895
+
896
+ // Refresh all posts (no filters)
897
+ const allPostsResponse = await client.posts.refreshStats();
898
+ ```
899
+
900
+ ---
901
+
778
902
  #### `client.posts.getStatus(params)`
779
903
 
780
904
  Get the status of a specific post.
@@ -1,5 +1,5 @@
1
1
  import { BaseClient } from './base';
2
- import type { Account, AccountStat, AccountTask, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, ApiResponse } from './types';
2
+ import type { Account, AccountStat, AccountTask, GetAccountsParams, GetAccountStatsParams, RefreshAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, ApiResponse } from './types';
3
3
  /**
4
4
  * Client for managing accounts
5
5
  */
@@ -12,6 +12,10 @@ export declare class AccountsClient extends BaseClient {
12
12
  * Get account statistics
13
13
  */
14
14
  getStats(params?: GetAccountStatsParams): Promise<ApiResponse<AccountStat[]>>;
15
+ /**
16
+ * Refresh account statistics from TikTok API
17
+ */
18
+ refreshStats(params?: RefreshAccountStatsParams): Promise<ApiResponse<AccountStat[]>>;
15
19
  /**
16
20
  * Get account status (tasks)
17
21
  */
package/dist/accounts.js CHANGED
@@ -18,6 +18,12 @@ class AccountsClient extends base_1.BaseClient {
18
18
  async getStats(params) {
19
19
  return this.post('/accounts/stats', params ?? {});
20
20
  }
21
+ /**
22
+ * Refresh account statistics from TikTok API
23
+ */
24
+ async refreshStats(params) {
25
+ return this.post('/accounts/stats/refresh', params ?? {});
26
+ }
21
27
  /**
22
28
  * Get account status (tasks)
23
29
  */
package/dist/posts.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BaseClient } from './base';
2
- import type { Post, PostStat, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, ApiResponse } from './types';
2
+ import type { Post, PostStat, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, RefreshPostStatsParams, GetPostStatusParams, CreateVideoParams, ApiResponse } from './types';
3
3
  /**
4
4
  * Client for managing posts
5
5
  */
@@ -16,6 +16,10 @@ export declare class PostsClient extends BaseClient {
16
16
  * Get post statistics
17
17
  */
18
18
  getStats(params?: GetPostStatsParams): Promise<ApiResponse<PostStat[]>>;
19
+ /**
20
+ * Refresh post statistics from TikTok API
21
+ */
22
+ refreshStats(params?: RefreshPostStatsParams): Promise<ApiResponse<PostStat[]>>;
19
23
  /**
20
24
  * Get post status
21
25
  */
package/dist/posts.js CHANGED
@@ -24,6 +24,12 @@ class PostsClient extends base_1.BaseClient {
24
24
  async getStats(params) {
25
25
  return this.post('/post/stats', params ?? {});
26
26
  }
27
+ /**
28
+ * Refresh post statistics from TikTok API
29
+ */
30
+ async refreshStats(params) {
31
+ return this.post('/post/stats/refresh', params ?? {});
32
+ }
27
33
  /**
28
34
  * Get post status
29
35
  */
package/dist/types.d.ts CHANGED
@@ -106,6 +106,12 @@ export interface GetAccountStatsParams {
106
106
  org_group?: string;
107
107
  user_group?: string;
108
108
  }
109
+ export interface RefreshAccountStatsParams {
110
+ accountIds?: string[];
111
+ tag?: string;
112
+ org_group?: string;
113
+ user_group?: string;
114
+ }
109
115
  export interface GetAccountStatusParams {
110
116
  accountId: string;
111
117
  includeCompleted?: boolean;
@@ -142,6 +148,9 @@ export interface GetPostStatsParams {
142
148
  startDate?: string;
143
149
  endDate?: string;
144
150
  }
151
+ export interface RefreshPostStatsParams {
152
+ postIds?: string[];
153
+ }
145
154
  export interface GetPostStatusParams {
146
155
  postId: string;
147
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",