ugcinc 1.0.7 → 1.0.9
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 +15 -1039
- package/dist/accounts.d.ts +1 -9
- package/dist/accounts.js +0 -12
- package/dist/client.d.ts +5 -0
- package/dist/client.js +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/posts.d.ts +1 -10
- package/dist/posts.js +0 -13
- package/dist/stats.d.ts +20 -0
- package/dist/stats.js +29 -0
- package/dist/types.d.ts +10 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,16 +5,10 @@ Official TypeScript/JavaScript client for the UGC Inc API.
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm
|
|
8
|
+
npm install ugcinc
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
### 1. Get Your API Key
|
|
14
|
-
|
|
15
|
-
Get your API key at **https://ugc.inc**. You'll need this to authenticate all API requests.
|
|
16
|
-
|
|
17
|
-
### 2. Initialize the Client
|
|
11
|
+
## Quick Start
|
|
18
12
|
|
|
19
13
|
```typescript
|
|
20
14
|
import { UGCClient } from 'ugcinc';
|
|
@@ -22,1057 +16,39 @@ import { UGCClient } from 'ugcinc';
|
|
|
22
16
|
const client = new UGCClient({
|
|
23
17
|
apiKey: 'your-api-key-here'
|
|
24
18
|
});
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**Important:** Keep your API key secure! Never commit it to version control or expose it in client-side code.
|
|
28
|
-
|
|
29
|
-
## API Documentation
|
|
30
|
-
|
|
31
|
-
### Accounts
|
|
32
|
-
|
|
33
|
-
The `accounts` object provides methods for managing accounts.
|
|
34
|
-
|
|
35
|
-
#### Get Accounts
|
|
36
|
-
|
|
37
|
-
Retrieve accounts with optional filters.
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
const response = await client.accounts.getAccounts({
|
|
41
|
-
tag: 'influencer',
|
|
42
|
-
org_group: 'group1',
|
|
43
|
-
user_group: 'users1'
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
if (response.ok) {
|
|
47
|
-
console.log(response.data); // Account[]
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
#### Get Account Statistics
|
|
52
|
-
|
|
53
|
-
Get statistics for accounts.
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
const response = await client.accounts.getStats({
|
|
57
|
-
accountIds: ['account-id-1', 'account-id-2'],
|
|
58
|
-
startDate: '2024-01-01',
|
|
59
|
-
endDate: '2024-12-31'
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
if (response.ok) {
|
|
63
|
-
response.data.forEach(stat => {
|
|
64
|
-
console.log(`Account ${stat.account_id}: ${stat.followers} followers`);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
#### Refresh Account Statistics
|
|
70
|
-
|
|
71
|
-
Fetch live statistics from TikTok/Instagram 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
|
-
|
|
87
|
-
#### Get Account Status
|
|
88
|
-
|
|
89
|
-
Get the status of tasks for one or more accounts.
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
// Get status for specific accounts
|
|
93
|
-
const response = await client.accounts.getStatus({
|
|
94
|
-
accountIds: ['account-id-1', 'account-id-2'],
|
|
95
|
-
includeCompleted: false
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// Get status for all accounts
|
|
99
|
-
const allResponse = await client.accounts.getStatus();
|
|
100
|
-
|
|
101
|
-
if (response.ok) {
|
|
102
|
-
console.log(response.data); // AccountTask[]
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
#### Update Account Info
|
|
107
|
-
|
|
108
|
-
Update account metadata (tag, org_group, user_group).
|
|
109
|
-
|
|
110
|
-
```typescript
|
|
111
|
-
const response = await client.accounts.updateInfo({
|
|
112
|
-
accountId: 'account-id',
|
|
113
|
-
tag: 'influencer',
|
|
114
|
-
org_group: 'group1',
|
|
115
|
-
user_group: 'users1'
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
if (response.ok) {
|
|
119
|
-
console.log(response.data.message);
|
|
120
|
-
console.log(response.data.account); // Updated account
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
#### Update Account Social Profile
|
|
125
|
-
|
|
126
|
-
Update account social profile information (avatar, nickname, bio).
|
|
127
|
-
|
|
128
|
-
**Important Restrictions:**
|
|
129
|
-
- **Nickname:** Can only be updated once every **7 days**
|
|
130
|
-
- **Avatar:** Can only be updated once every **24 hours**
|
|
131
|
-
- **Bio:** Can only be updated once every **24 hours**
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
const response = await client.accounts.updateSocial({
|
|
135
|
-
accountId: 'account-id',
|
|
136
|
-
nickName: 'New Name',
|
|
137
|
-
bio: 'New bio text',
|
|
138
|
-
avatarUrl: 'https://example.com/avatar.jpg'
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
if (response.ok) {
|
|
142
|
-
console.log(response.data.message);
|
|
143
|
-
} else {
|
|
144
|
-
// Error response includes when the field can be updated again
|
|
145
|
-
console.error(response.message);
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Tasks
|
|
150
|
-
|
|
151
|
-
The `tasks` object provides methods for managing tasks.
|
|
152
|
-
|
|
153
|
-
#### Get Tasks
|
|
154
|
-
|
|
155
|
-
Retrieve tasks with optional filters.
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
const response = await client.tasks.getTasks({
|
|
159
|
-
accountIds: ['account-id-1'],
|
|
160
|
-
startDate: '2024-01-01',
|
|
161
|
-
endDate: '2024-12-31',
|
|
162
|
-
taskType: 'edit_profile'
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
if (response.ok) {
|
|
166
|
-
console.log(response.data); // Task[]
|
|
167
|
-
}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### Posts
|
|
171
|
-
|
|
172
|
-
The `posts` object provides methods for managing posts.
|
|
173
|
-
|
|
174
|
-
#### Get Posts
|
|
175
|
-
|
|
176
|
-
Retrieve posts with optional filters.
|
|
177
|
-
|
|
178
|
-
```typescript
|
|
179
|
-
const response = await client.posts.getPosts({
|
|
180
|
-
accountIds: ['account-id-1'],
|
|
181
|
-
startDate: '2024-01-01',
|
|
182
|
-
endDate: '2024-12-31'
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
if (response.ok) {
|
|
186
|
-
console.log(response.data); // Post[]
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
#### Create Slideshow
|
|
191
|
-
|
|
192
|
-
Create a slideshow post.
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
const response = await client.posts.createSlideshow({
|
|
196
|
-
accountId: 'account-id',
|
|
197
|
-
imageUrls: [
|
|
198
|
-
'https://example.com/image1.jpg',
|
|
199
|
-
'https://example.com/image2.jpg',
|
|
200
|
-
'https://example.com/image3.jpg'
|
|
201
|
-
],
|
|
202
|
-
caption: 'Check out this slideshow!',
|
|
203
|
-
musicPostId: 'music-id',
|
|
204
|
-
postTime: '2024-12-31T12:00:00Z',
|
|
205
|
-
strict: true
|
|
206
|
-
});
|
|
207
19
|
|
|
208
|
-
|
|
209
|
-
console.log(`Post created: ${response.data.id}`);
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
#### Create Video
|
|
214
|
-
|
|
215
|
-
Create a video post.
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
const response = await client.posts.createVideo({
|
|
219
|
-
accountId: 'account-id',
|
|
220
|
-
videoUrl: 'https://example.com/video.mp4',
|
|
221
|
-
caption: 'My awesome video!',
|
|
222
|
-
musicPostId: 'music-id',
|
|
223
|
-
postTime: '2024-12-31T12:00:00Z',
|
|
224
|
-
strict: true
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
if (response.ok) {
|
|
228
|
-
console.log(`Post created: ${response.data.id}`);
|
|
229
|
-
}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
#### Get Post Statistics
|
|
233
|
-
|
|
234
|
-
Get statistics for posts.
|
|
235
|
-
|
|
236
|
-
```typescript
|
|
237
|
-
const response = await client.posts.getStats({
|
|
238
|
-
postIds: ['post-id-1', 'post-id-2'],
|
|
239
|
-
startDate: '2024-01-01',
|
|
240
|
-
endDate: '2024-12-31'
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
if (response.ok) {
|
|
244
|
-
response.data.forEach(stat => {
|
|
245
|
-
console.log(`Post ${stat.post_id}: ${stat.views} views, ${stat.likes} likes`);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
#### Refresh Post Statistics
|
|
251
|
-
|
|
252
|
-
Fetch live statistics from TikTok/Instagram API and create new stat records.
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
const response = await client.posts.refreshStats({
|
|
256
|
-
postIds: ['post-id-1', 'post-id-2']
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
if (response.ok) {
|
|
260
|
-
console.log(`Refreshed stats for ${response.data.length} posts`);
|
|
261
|
-
response.data.forEach(stat => {
|
|
262
|
-
console.log(`Post ${stat.post_id}: ${stat.views} views, ${stat.likes} likes`);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
#### Get Post Status
|
|
268
|
-
|
|
269
|
-
Get the status of a specific post.
|
|
270
|
-
|
|
271
|
-
```typescript
|
|
272
|
-
const response = await client.posts.getStatus({
|
|
273
|
-
postId: 'post-id'
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
if (response.ok) {
|
|
277
|
-
console.log(`Post status: ${response.data.status}`);
|
|
278
|
-
}
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
## Response Handling
|
|
282
|
-
|
|
283
|
-
All API methods return a response object with the following structure:
|
|
284
|
-
|
|
285
|
-
### Success Response
|
|
286
|
-
|
|
287
|
-
```typescript
|
|
288
|
-
{
|
|
289
|
-
ok: true,
|
|
290
|
-
code: 200,
|
|
291
|
-
message: "Success",
|
|
292
|
-
data: T // The actual response data
|
|
293
|
-
}
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
### Error Response
|
|
297
|
-
|
|
298
|
-
```typescript
|
|
299
|
-
{
|
|
300
|
-
ok: false,
|
|
301
|
-
code: number, // HTTP status code
|
|
302
|
-
message: string // Error message
|
|
303
|
-
}
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
### Type-Safe Response Handling
|
|
307
|
-
|
|
308
|
-
```typescript
|
|
20
|
+
// Example: Get accounts
|
|
309
21
|
const response = await client.accounts.getAccounts();
|
|
310
22
|
|
|
311
23
|
if (response.ok) {
|
|
312
|
-
// TypeScript knows response.data is Account[]
|
|
313
|
-
response.data.forEach(account => {
|
|
314
|
-
console.log(account.username);
|
|
315
|
-
});
|
|
316
|
-
} else {
|
|
317
|
-
// TypeScript knows response has code and message
|
|
318
|
-
console.error(`Error ${response.code}: ${response.message}`);
|
|
319
|
-
}
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
## TypeScript Support
|
|
323
|
-
|
|
324
|
-
This package is written in TypeScript and provides full type definitions. All types are exported for your convenience:
|
|
325
|
-
|
|
326
|
-
```typescript
|
|
327
|
-
import type {
|
|
328
|
-
Account,
|
|
329
|
-
Post,
|
|
330
|
-
Task,
|
|
331
|
-
CreateVideoParams,
|
|
332
|
-
ApiResponse
|
|
333
|
-
} from 'ugcinc';
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
## Error Handling
|
|
337
|
-
|
|
338
|
-
```typescript
|
|
339
|
-
try {
|
|
340
|
-
const response = await client.accounts.getAccounts();
|
|
341
|
-
|
|
342
|
-
if (!response.ok) {
|
|
343
|
-
console.error(`API Error: ${response.message}`);
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Handle success
|
|
348
24
|
console.log(response.data);
|
|
349
|
-
} catch (error) {
|
|
350
|
-
console.error('Network or parsing error:', error);
|
|
351
25
|
}
|
|
352
26
|
```
|
|
353
27
|
|
|
354
|
-
##
|
|
355
|
-
|
|
356
|
-
For production use, store your API key securely using environment variables:
|
|
357
|
-
|
|
358
|
-
```bash
|
|
359
|
-
# .env file
|
|
360
|
-
UGC_API_KEY=your-api-key-here
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
Then in your code:
|
|
364
|
-
|
|
365
|
-
```typescript
|
|
366
|
-
import { UGCClient } from 'ugcinc';
|
|
367
|
-
|
|
368
|
-
const client = new UGCClient({
|
|
369
|
-
apiKey: process.env.UGC_API_KEY!
|
|
370
|
-
});
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
## Complete API Reference
|
|
376
|
-
|
|
377
|
-
### Accounts API
|
|
378
|
-
|
|
379
|
-
#### `client.accounts.getAccounts(params?)`
|
|
380
|
-
|
|
381
|
-
Retrieve accounts with optional filters.
|
|
382
|
-
|
|
383
|
-
**Endpoint:** `POST /accounts`
|
|
384
|
-
|
|
385
|
-
**Parameters:**
|
|
386
|
-
|
|
387
|
-
| Parameter | Type | Required | Description |
|
|
388
|
-
|-----------|------|----------|-------------|
|
|
389
|
-
| `tag` | `string` | No | Filter by tag |
|
|
390
|
-
| `org_group` | `string` | No | Filter by organization group |
|
|
391
|
-
| `user_group` | `string` | No | Filter by user group |
|
|
392
|
-
|
|
393
|
-
**Returns:** `ApiResponse<Account[]>`
|
|
394
|
-
|
|
395
|
-
Returns an array of Account objects matching the specified filters. If no filters are provided, returns all accounts for your organization.
|
|
396
|
-
|
|
397
|
-
**Account Object:**
|
|
398
|
-
|
|
399
|
-
```typescript
|
|
400
|
-
{
|
|
401
|
-
id: string; // Unique account identifier
|
|
402
|
-
type: string; // Account type ('tiktok' or 'instagram')
|
|
403
|
-
tag: string | null; // Custom tag for categorization
|
|
404
|
-
org_group: string | null; // Organization group identifier
|
|
405
|
-
user_group: string | null; // User group identifier
|
|
406
|
-
username: string | null; // Account username/handle
|
|
407
|
-
nick_name: string | null; // Account display name
|
|
408
|
-
pfp_url: string | null; // Profile picture URL
|
|
409
|
-
}
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
| Field | Type | Description |
|
|
413
|
-
|-------|------|-------------|
|
|
414
|
-
| `id` | `string` | Unique account identifier |
|
|
415
|
-
| `type` | `string` | Account platform type (`'tiktok'` or `'instagram'`) |
|
|
416
|
-
| `tag` | `string \| null` | Custom tag for categorization |
|
|
417
|
-
| `org_group` | `string \| null` | Organization group identifier for grouping |
|
|
418
|
-
| `user_group` | `string \| null` | User group identifier for grouping |
|
|
419
|
-
| `username` | `string \| null` | Account username/handle on the platform |
|
|
420
|
-
| `nick_name` | `string \| null` | Display name shown on profile |
|
|
421
|
-
| `pfp_url` | `string \| null` | URL to account's profile picture |
|
|
422
|
-
|
|
423
|
-
**Example:**
|
|
424
|
-
|
|
425
|
-
```typescript
|
|
426
|
-
const response = await client.accounts.getAccounts({
|
|
427
|
-
tag: 'influencer',
|
|
428
|
-
org_group: 'group1'
|
|
429
|
-
});
|
|
430
|
-
```
|
|
431
|
-
|
|
432
|
-
---
|
|
433
|
-
|
|
434
|
-
#### `client.accounts.getStats(params?)`
|
|
435
|
-
|
|
436
|
-
Get account statistics.
|
|
437
|
-
|
|
438
|
-
**Endpoint:** `POST /accounts/stats`
|
|
439
|
-
|
|
440
|
-
**Parameters:**
|
|
441
|
-
|
|
442
|
-
| Parameter | Type | Required | Description |
|
|
443
|
-
|-----------|------|----------|-------------|
|
|
444
|
-
| `accountIds` | `string[]` | No | Array of account IDs to get stats for |
|
|
445
|
-
| `startDate` | `string` | No | Start date (ISO 8601 format) |
|
|
446
|
-
| `endDate` | `string` | No | End date (ISO 8601 format) |
|
|
447
|
-
| `tag` | `string` | No | Filter by tag |
|
|
448
|
-
| `org_group` | `string` | No | Filter by organization group |
|
|
449
|
-
| `user_group` | `string` | No | Filter by user group |
|
|
450
|
-
|
|
451
|
-
**Returns:** `ApiResponse<AccountStat[]>`
|
|
452
|
-
|
|
453
|
-
Returns an array of AccountStat objects containing follower counts, views, likes, and other metrics for the specified accounts and date range.
|
|
454
|
-
|
|
455
|
-
**AccountStat Object:**
|
|
456
|
-
|
|
457
|
-
```typescript
|
|
458
|
-
{
|
|
459
|
-
id: string; // Unique stat record identifier
|
|
460
|
-
account_id: string; // Associated account ID
|
|
461
|
-
followers: number | null; // Follower count
|
|
462
|
-
following: number | null; // Following count
|
|
463
|
-
views: number | null; // Total profile views
|
|
464
|
-
likes: number | null; // Total likes received
|
|
465
|
-
created_at: string; // Timestamp when stat was recorded
|
|
466
|
-
}
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
| Field | Type | Description |
|
|
470
|
-
|-------|------|-------------|
|
|
471
|
-
| `id` | `string` | Unique identifier for this stat record |
|
|
472
|
-
| `account_id` | `string` | ID of the account these stats belong to |
|
|
473
|
-
| `followers` | `number \| null` | Total number of followers |
|
|
474
|
-
| `following` | `number \| null` | Total number of accounts being followed |
|
|
475
|
-
| `views` | `number \| null` | Total profile/content views |
|
|
476
|
-
| `likes` | `number \| null` | Total likes received across all content |
|
|
477
|
-
| `created_at` | `string` | ISO 8601 timestamp when this stat was recorded |
|
|
478
|
-
|
|
479
|
-
**Example:**
|
|
480
|
-
|
|
481
|
-
```typescript
|
|
482
|
-
const response = await client.accounts.getStats({
|
|
483
|
-
accountIds: ['account-1', 'account-2'],
|
|
484
|
-
startDate: '2024-01-01T00:00:00Z',
|
|
485
|
-
endDate: '2024-12-31T23:59:59Z'
|
|
486
|
-
});
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
---
|
|
490
|
-
|
|
491
|
-
#### `client.accounts.refreshStats(params?)`
|
|
492
|
-
|
|
493
|
-
Refresh account statistics by fetching live data from TikTok/Instagram API.
|
|
494
|
-
|
|
495
|
-
**Endpoint:** `POST /accounts/stats/refresh`
|
|
496
|
-
|
|
497
|
-
**Parameters:**
|
|
498
|
-
|
|
499
|
-
| Parameter | Type | Required | Description |
|
|
500
|
-
|-----------|------|----------|-------------|
|
|
501
|
-
| `accountIds` | `string[]` | No | Array of account IDs to refresh stats for |
|
|
502
|
-
| `tag` | `string` | No | Filter by tag |
|
|
503
|
-
| `org_group` | `string` | No | Filter by organization group |
|
|
504
|
-
| `user_group` | `string` | No | Filter by user group |
|
|
28
|
+
## Get Your API Key
|
|
505
29
|
|
|
506
|
-
|
|
30
|
+
To get your API key:
|
|
507
31
|
|
|
508
|
-
|
|
32
|
+
1. Visit [ugc.inc](https://ugc.inc)
|
|
33
|
+
2. Schedule a call with our team
|
|
34
|
+
3. You'll receive your API key after the call
|
|
509
35
|
|
|
510
|
-
**
|
|
511
|
-
- `refreshStats()` fetches **live data** from TikTok/Instagram API and creates new records
|
|
512
|
-
- `getStats()` retrieves **historical data** from your database
|
|
513
|
-
|
|
514
|
-
**Example:**
|
|
515
|
-
|
|
516
|
-
```typescript
|
|
517
|
-
const response = await client.accounts.refreshStats({
|
|
518
|
-
accountIds: ['account-1', 'account-2'],
|
|
519
|
-
tag: 'influencer'
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
if (response.ok) {
|
|
523
|
-
console.log(`Successfully refreshed ${response.data.length} accounts`);
|
|
524
|
-
response.data.forEach(stat => {
|
|
525
|
-
console.log(`Account ${stat.account_id}:`);
|
|
526
|
-
console.log(` Followers: ${stat.followers}`);
|
|
527
|
-
console.log(` Views: ${stat.views}`);
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
---
|
|
533
|
-
|
|
534
|
-
#### `client.accounts.getStatus(params?)`
|
|
535
|
-
|
|
536
|
-
Get account status and pending tasks for one or more accounts.
|
|
537
|
-
|
|
538
|
-
**Endpoint:** `POST /accounts/status`
|
|
539
|
-
|
|
540
|
-
**Parameters:**
|
|
541
|
-
|
|
542
|
-
| Parameter | Type | Required | Description |
|
|
543
|
-
|-----------|------|----------|-------------|
|
|
544
|
-
| `accountIds` | `string[]` | No | Array of account IDs to check status for (omit to get all accounts) |
|
|
545
|
-
| `includeCompleted` | `boolean` | No | Include completed tasks (default: false) |
|
|
546
|
-
|
|
547
|
-
**Returns:** `ApiResponse<AccountTask[]>`
|
|
548
|
-
|
|
549
|
-
Returns an array of AccountTask objects showing pending and (optionally) completed tasks for the specified accounts. If no `accountIds` are provided, returns tasks for all accounts in your organization. Tasks include profile edits and other account-level operations.
|
|
550
|
-
|
|
551
|
-
**AccountTask Object:**
|
|
552
|
-
|
|
553
|
-
```typescript
|
|
554
|
-
{
|
|
555
|
-
id: string; // Unique task identifier
|
|
556
|
-
account_id: string; // Associated account ID
|
|
557
|
-
type: string; // Task type
|
|
558
|
-
status: string; // Current task status
|
|
559
|
-
scheduled_time: string | null; // When task is scheduled to run
|
|
560
|
-
edit_profile_info: EditProfileInfo | null; // Profile update details (if type is 'edit_profile')
|
|
561
|
-
created_at: string; // When task was created
|
|
562
|
-
}
|
|
563
|
-
```
|
|
564
|
-
|
|
565
|
-
| Field | Type | Description |
|
|
566
|
-
|-------|------|-------------|
|
|
567
|
-
| `id` | `string` | Unique identifier for this task |
|
|
568
|
-
| `account_id` | `string` | ID of the account this task belongs to |
|
|
569
|
-
| `type` | `string` | Task type (e.g., `'edit_profile'`, `'warmup_scroll'`) |
|
|
570
|
-
| `status` | `string` | Current task status (`'scheduled'`, `'pending'`, `'complete'`, `'failed'`) |
|
|
571
|
-
| `scheduled_time` | `string \| null` | ISO 8601 timestamp when task is scheduled to execute |
|
|
572
|
-
| `edit_profile_info` | `EditProfileInfo \| null` | Profile update information (only for `edit_profile` tasks) |
|
|
573
|
-
| `created_at` | `string` | ISO 8601 timestamp when task was created |
|
|
574
|
-
|
|
575
|
-
**Example:**
|
|
576
|
-
|
|
577
|
-
```typescript
|
|
578
|
-
// Get status for specific accounts
|
|
579
|
-
const response = await client.accounts.getStatus({
|
|
580
|
-
accountIds: ['account-1', 'account-2'],
|
|
581
|
-
includeCompleted: true
|
|
582
|
-
});
|
|
583
|
-
|
|
584
|
-
// Get status for all accounts
|
|
585
|
-
const allResponse = await client.accounts.getStatus();
|
|
586
|
-
|
|
587
|
-
if (response.ok) {
|
|
588
|
-
response.data.forEach(task => {
|
|
589
|
-
console.log(`Task ${task.id} for account ${task.account_id}: ${task.status}`);
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
```
|
|
593
|
-
|
|
594
|
-
---
|
|
595
|
-
|
|
596
|
-
#### `client.accounts.updateInfo(params)`
|
|
597
|
-
|
|
598
|
-
Update account metadata (tag, org_group, user_group).
|
|
599
|
-
|
|
600
|
-
**Endpoint:** `POST /accounts/update-info`
|
|
601
|
-
|
|
602
|
-
**Parameters:**
|
|
603
|
-
|
|
604
|
-
| Parameter | Type | Required | Description |
|
|
605
|
-
|-----------|------|----------|-------------|
|
|
606
|
-
| `accountId` | `string` | **Yes** | Account ID to update |
|
|
607
|
-
| `tag` | `string` | No | New tag value for categorization |
|
|
608
|
-
| `org_group` | `string` | No | New organization group identifier |
|
|
609
|
-
| `user_group` | `string` | No | New user group identifier |
|
|
610
|
-
|
|
611
|
-
**Note:** At least one of `tag`, `org_group`, or `user_group` must be provided.
|
|
612
|
-
|
|
613
|
-
**Returns:** `ApiResponse<{ message: string; account: Account }>`
|
|
614
|
-
|
|
615
|
-
Returns a success message and the updated account object. The update is applied immediately to the database.
|
|
616
|
-
|
|
617
|
-
**Response Object:**
|
|
618
|
-
|
|
619
|
-
```typescript
|
|
620
|
-
{
|
|
621
|
-
message: string; // Success message (e.g., "Account info updated successfully")
|
|
622
|
-
account: Account; // Updated account object with new values
|
|
623
|
-
}
|
|
624
|
-
```
|
|
625
|
-
|
|
626
|
-
**Example:**
|
|
627
|
-
|
|
628
|
-
```typescript
|
|
629
|
-
const response = await client.accounts.updateInfo({
|
|
630
|
-
accountId: 'account-id',
|
|
631
|
-
tag: 'influencer',
|
|
632
|
-
org_group: 'group1',
|
|
633
|
-
user_group: 'users1'
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
if (response.ok) {
|
|
637
|
-
console.log(response.data.account.tag); // 'influencer'
|
|
638
|
-
}
|
|
639
|
-
```
|
|
640
|
-
|
|
641
|
-
---
|
|
642
|
-
|
|
643
|
-
#### `client.accounts.updateSocial(params)`
|
|
644
|
-
|
|
645
|
-
Update account social profile (avatar, nickname, bio).
|
|
646
|
-
|
|
647
|
-
**Endpoint:** `POST /accounts/update-social`
|
|
648
|
-
|
|
649
|
-
**Parameters:**
|
|
650
|
-
|
|
651
|
-
| Parameter | Type | Required | Description |
|
|
652
|
-
|-----------|------|----------|-------------|
|
|
653
|
-
| `accountId` | `string` | **Yes** | Account ID to update |
|
|
654
|
-
| `avatarUrl` | `string` | No | New avatar/profile picture URL |
|
|
655
|
-
| `nickName` | `string` | No | New display name |
|
|
656
|
-
| `bio` | `string` | No | New bio text |
|
|
657
|
-
|
|
658
|
-
**Important Update Restrictions:**
|
|
659
|
-
|
|
660
|
-
Each profile field has a cooldown period before it can be updated again:
|
|
661
|
-
- **Nickname:** Can only be updated **once every 7 days**
|
|
662
|
-
- **Avatar:** Can only be updated **once every 24 hours**
|
|
663
|
-
- **Bio:** Can only be updated **once every 24 hours**
|
|
664
|
-
|
|
665
|
-
If you attempt to update a field before its cooldown period has elapsed, the API will return an error with details about when the next update is allowed.
|
|
666
|
-
|
|
667
|
-
**Returns:** `ApiResponse<{ message: string }>`
|
|
668
|
-
|
|
669
|
-
Returns a success message when the profile update task has been successfully created and queued. The actual profile update will be processed asynchronously through the GeeLark API.
|
|
670
|
-
|
|
671
|
-
**Response Object:**
|
|
672
|
-
|
|
673
|
-
```typescript
|
|
674
|
-
{
|
|
675
|
-
message: string; // Success message (e.g., "Profile update task created successfully")
|
|
676
|
-
}
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
**Error Response (Rate Limit):**
|
|
680
|
-
|
|
681
|
-
If you attempt to update a field too soon, you'll receive an error like:
|
|
682
|
-
|
|
683
|
-
```typescript
|
|
684
|
-
// Nickname restriction (7 days)
|
|
685
|
-
{
|
|
686
|
-
ok: false,
|
|
687
|
-
code: 400,
|
|
688
|
-
message: "Nickname can only be updated once every 7 days. Last update was X days ago. You can update again in Y day(s) on YYYY-MM-DD"
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
// Avatar restriction (24 hours)
|
|
692
|
-
{
|
|
693
|
-
ok: false,
|
|
694
|
-
code: 400,
|
|
695
|
-
message: "Avatar can only be updated once every 24 hours. Last update was X hours ago. You can update again in Y hour(s) on YYYY-MM-DD"
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
// Bio restriction (24 hours)
|
|
699
|
-
{
|
|
700
|
-
ok: false,
|
|
701
|
-
code: 400,
|
|
702
|
-
message: "Bio can only be updated once every 24 hours. Last update was X hours ago. You can update again in Y hour(s) on YYYY-MM-DD"
|
|
703
|
-
}
|
|
704
|
-
```
|
|
705
|
-
|
|
706
|
-
**Example:**
|
|
707
|
-
|
|
708
|
-
```typescript
|
|
709
|
-
const response = await client.accounts.updateSocial({
|
|
710
|
-
accountId: 'account-id',
|
|
711
|
-
nickName: 'Cool Creator',
|
|
712
|
-
bio: 'Content creator 🎥',
|
|
713
|
-
avatarUrl: 'https://storage.example.com/avatar.jpg'
|
|
714
|
-
});
|
|
715
|
-
|
|
716
|
-
if (response.ok) {
|
|
717
|
-
console.log(response.data.message);
|
|
718
|
-
} else {
|
|
719
|
-
// Handle rate limit error
|
|
720
|
-
console.error(response.message);
|
|
721
|
-
}
|
|
722
|
-
```
|
|
723
|
-
|
|
724
|
-
---
|
|
725
|
-
|
|
726
|
-
### Tasks API
|
|
727
|
-
|
|
728
|
-
#### `client.tasks.getTasks(params?)`
|
|
729
|
-
|
|
730
|
-
Retrieve tasks with optional filters.
|
|
731
|
-
|
|
732
|
-
**Endpoint:** `POST /tasks`
|
|
733
|
-
|
|
734
|
-
**Parameters:**
|
|
735
|
-
|
|
736
|
-
| Parameter | Type | Required | Description |
|
|
737
|
-
|-----------|------|----------|-------------|
|
|
738
|
-
| `accountIds` | `string[]` | No | Filter by account IDs |
|
|
739
|
-
| `startDate` | `string` | No | Start date (ISO 8601 format) |
|
|
740
|
-
| `endDate` | `string` | No | End date (ISO 8601 format) |
|
|
741
|
-
| `taskType` | `TaskType` | No | Filter by task type |
|
|
742
|
-
|
|
743
|
-
**TaskType:** `'warmup_scroll' | 'warmup_search_term' | 'warmup_search_profile' | 'edit_profile'`
|
|
744
|
-
|
|
745
|
-
**Returns:** `ApiResponse<Task[]>`
|
|
746
|
-
|
|
747
|
-
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.
|
|
748
|
-
|
|
749
|
-
**Task Object:**
|
|
750
|
-
|
|
751
|
-
```typescript
|
|
752
|
-
{
|
|
753
|
-
id: string; // Unique task identifier
|
|
754
|
-
account_id: string; // Associated account ID
|
|
755
|
-
type: TaskType; // Task type
|
|
756
|
-
status: string; // Current status
|
|
757
|
-
scheduled_time: string | null; // When task is scheduled
|
|
758
|
-
duration: number | null; // Task duration in seconds
|
|
759
|
-
keywords: string[] | null; // Keywords for search tasks
|
|
760
|
-
edit_profile_info: EditProfileInfo | null; // Profile info for edit tasks
|
|
761
|
-
created_at: string; // Creation timestamp
|
|
762
|
-
}
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
| Field | Type | Description |
|
|
766
|
-
|-------|------|-------------|
|
|
767
|
-
| `id` | `string` | Unique identifier for this task |
|
|
768
|
-
| `account_id` | `string` | ID of the account this task belongs to |
|
|
769
|
-
| `type` | `TaskType` | Task type: `'warmup_scroll'`, `'warmup_search_term'`, `'warmup_search_profile'`, or `'edit_profile'` |
|
|
770
|
-
| `status` | `string` | Current status: `'scheduled'`, `'pending'`, `'complete'`, or `'failed'` |
|
|
771
|
-
| `scheduled_time` | `string \| null` | ISO 8601 timestamp when task should execute |
|
|
772
|
-
| `duration` | `number \| null` | Task duration in seconds (for warmup tasks) |
|
|
773
|
-
| `keywords` | `string[] \| null` | Array of keywords (for search tasks) |
|
|
774
|
-
| `edit_profile_info` | `EditProfileInfo \| null` | Profile update details (for `edit_profile` tasks) |
|
|
775
|
-
| `created_at` | `string` | ISO 8601 timestamp when task was created |
|
|
776
|
-
|
|
777
|
-
**Example:**
|
|
778
|
-
|
|
779
|
-
```typescript
|
|
780
|
-
const response = await client.tasks.getTasks({
|
|
781
|
-
accountIds: ['account-1', 'account-2'],
|
|
782
|
-
taskType: 'edit_profile',
|
|
783
|
-
startDate: '2024-01-01T00:00:00Z'
|
|
784
|
-
});
|
|
785
|
-
```
|
|
786
|
-
|
|
787
|
-
---
|
|
788
|
-
|
|
789
|
-
### Posts API
|
|
790
|
-
|
|
791
|
-
#### `client.posts.getPosts(params?)`
|
|
792
|
-
|
|
793
|
-
Retrieve posts with optional filters.
|
|
794
|
-
|
|
795
|
-
**Endpoint:** `POST /post`
|
|
796
|
-
|
|
797
|
-
**Parameters:**
|
|
798
|
-
|
|
799
|
-
| Parameter | Type | Required | Description |
|
|
800
|
-
|-----------|------|----------|-------------|
|
|
801
|
-
| `accountIds` | `string[]` | No | Filter by account IDs |
|
|
802
|
-
| `startDate` | `string` | No | Start date (ISO 8601 format) |
|
|
803
|
-
| `endDate` | `string` | No | End date (ISO 8601 format) |
|
|
804
|
-
|
|
805
|
-
**Returns:** `ApiResponse<Post[]>`
|
|
806
|
-
|
|
807
|
-
Returns an array of Post objects (videos and slideshows) for the specified accounts and date range. Includes post status, URLs, captions, and associated media.
|
|
808
|
-
|
|
809
|
-
**Post Object:**
|
|
810
|
-
|
|
811
|
-
```typescript
|
|
812
|
-
{
|
|
813
|
-
id: string; // Unique post identifier
|
|
814
|
-
account_id: string; // Account that posted this
|
|
815
|
-
type: 'video' | 'slideshow'; // Post type
|
|
816
|
-
status: string; // Current post status
|
|
817
|
-
social_id: string | null; // Platform post ID (TikTok video ID or Instagram reel code)
|
|
818
|
-
caption: string | null; // Post caption/description
|
|
819
|
-
media_urls: string[] | null; // URLs to media files
|
|
820
|
-
music_post_id: string | null; // Associated music/audio ID
|
|
821
|
-
}
|
|
822
|
-
```
|
|
823
|
-
|
|
824
|
-
| Field | Type | Description |
|
|
825
|
-
|-------|------|-------------|
|
|
826
|
-
| `id` | `string` | Unique identifier for this post |
|
|
827
|
-
| `account_id` | `string` | ID of the account that created this post |
|
|
828
|
-
| `type` | `'video' \| 'slideshow'` | Type of post content |
|
|
829
|
-
| `status` | `string` | Current status: `'scheduled'`, `'pending'`, `'complete'`, or `'failed'` |
|
|
830
|
-
| `social_id` | `string \| null` | Platform-specific post ID (TikTok video ID or Instagram reel code, available after posting) |
|
|
831
|
-
| `caption` | `string \| null` | Post caption/description text (max 500 characters) |
|
|
832
|
-
| `media_urls` | `string[] \| null` | Array of URLs to video/image files used in the post |
|
|
833
|
-
| `music_post_id` | `string \| null` | ID of the music/audio track used in the post |
|
|
834
|
-
|
|
835
|
-
**Example:**
|
|
836
|
-
|
|
837
|
-
```typescript
|
|
838
|
-
const response = await client.posts.getPosts({
|
|
839
|
-
accountIds: ['account-1'],
|
|
840
|
-
startDate: '2024-01-01T00:00:00Z',
|
|
841
|
-
endDate: '2024-12-31T23:59:59Z'
|
|
842
|
-
});
|
|
843
|
-
```
|
|
844
|
-
|
|
845
|
-
---
|
|
846
|
-
|
|
847
|
-
#### `client.posts.createSlideshow(params)`
|
|
848
|
-
|
|
849
|
-
Create a slideshow post from multiple images.
|
|
850
|
-
|
|
851
|
-
**Endpoint:** `POST /post/slideshow`
|
|
852
|
-
|
|
853
|
-
**Parameters:**
|
|
854
|
-
|
|
855
|
-
| Parameter | Type | Required | Description |
|
|
856
|
-
|-----------|------|----------|-------------|
|
|
857
|
-
| `accountId` | `string` | **Yes** | Account ID to post from |
|
|
858
|
-
| `imageUrls` | `string[]` | **Yes** | Array of image URLs (at least 1 required) |
|
|
859
|
-
| `caption` | `string` | No | Post caption (max 500 characters) |
|
|
860
|
-
| `musicPostId` | `string` | No | Music/audio post ID to use |
|
|
861
|
-
| `postTime` | `string` | No | When to schedule the post (ISO 8601) |
|
|
862
|
-
| `strict` | `boolean` | No | Strict mode (default: true) |
|
|
863
|
-
|
|
864
|
-
**Returns:** `ApiResponse<Post>`
|
|
865
|
-
|
|
866
|
-
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.
|
|
867
|
-
|
|
868
|
-
**Example:**
|
|
869
|
-
|
|
870
|
-
```typescript
|
|
871
|
-
const response = await client.posts.createSlideshow({
|
|
872
|
-
accountId: 'account-id',
|
|
873
|
-
imageUrls: [
|
|
874
|
-
'https://storage.example.com/img1.jpg',
|
|
875
|
-
'https://storage.example.com/img2.jpg',
|
|
876
|
-
'https://storage.example.com/img3.jpg'
|
|
877
|
-
],
|
|
878
|
-
caption: 'Check out these photos! 📸',
|
|
879
|
-
postTime: '2024-12-25T12:00:00Z'
|
|
880
|
-
});
|
|
881
|
-
```
|
|
882
|
-
|
|
883
|
-
---
|
|
884
|
-
|
|
885
|
-
#### `client.posts.createVideo(params)`
|
|
886
|
-
|
|
887
|
-
Create a video post.
|
|
888
|
-
|
|
889
|
-
**Endpoint:** `POST /post/video`
|
|
890
|
-
|
|
891
|
-
**Parameters:**
|
|
892
|
-
|
|
893
|
-
| Parameter | Type | Required | Description |
|
|
894
|
-
|-----------|------|----------|-------------|
|
|
895
|
-
| `accountId` | `string` | **Yes** | Account ID to post from |
|
|
896
|
-
| `videoUrl` | `string` | **Yes** | Video file URL |
|
|
897
|
-
| `caption` | `string` | No | Post caption (max 500 characters) |
|
|
898
|
-
| `musicPostId` | `string` | No | Music/audio post ID to use |
|
|
899
|
-
| `postTime` | `string` | No | When to schedule the post (ISO 8601) |
|
|
900
|
-
| `strict` | `boolean` | No | Strict mode (default: true) |
|
|
901
|
-
|
|
902
|
-
**Returns:** `ApiResponse<Post>`
|
|
903
|
-
|
|
904
|
-
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.
|
|
905
|
-
|
|
906
|
-
**Example:**
|
|
907
|
-
|
|
908
|
-
```typescript
|
|
909
|
-
const response = await client.posts.createVideo({
|
|
910
|
-
accountId: 'account-id',
|
|
911
|
-
videoUrl: 'https://storage.example.com/video.mp4',
|
|
912
|
-
caption: 'My awesome video! 🎥 #viral',
|
|
913
|
-
strict: false
|
|
914
|
-
});
|
|
915
|
-
```
|
|
916
|
-
|
|
917
|
-
---
|
|
918
|
-
|
|
919
|
-
#### `client.posts.getStats(params?)`
|
|
920
|
-
|
|
921
|
-
Get post statistics.
|
|
922
|
-
|
|
923
|
-
**Endpoint:** `POST /post/stats`
|
|
924
|
-
|
|
925
|
-
**Parameters:**
|
|
926
|
-
|
|
927
|
-
| Parameter | Type | Required | Description |
|
|
928
|
-
|-----------|------|----------|-------------|
|
|
929
|
-
| `postIds` | `string[]` | No | Array of post IDs to get stats for |
|
|
930
|
-
| `startDate` | `string` | No | Start date (ISO 8601 format) |
|
|
931
|
-
| `endDate` | `string` | No | End date (ISO 8601 format) |
|
|
932
|
-
|
|
933
|
-
**Returns:** `ApiResponse<PostStat[]>`
|
|
934
|
-
|
|
935
|
-
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.
|
|
936
|
-
|
|
937
|
-
**PostStat Object:**
|
|
938
|
-
|
|
939
|
-
```typescript
|
|
940
|
-
{
|
|
941
|
-
id: string; // Unique stat record identifier
|
|
942
|
-
post_id: string; // Associated post ID
|
|
943
|
-
views: number | null; // View count
|
|
944
|
-
likes: number | null; // Like count
|
|
945
|
-
comments: number | null; // Comment count
|
|
946
|
-
shares: number | null; // Share count
|
|
947
|
-
saves: number | null; // Save/bookmark count
|
|
948
|
-
created_at: string; // When stat was recorded
|
|
949
|
-
}
|
|
950
|
-
```
|
|
951
|
-
|
|
952
|
-
| Field | Type | Description |
|
|
953
|
-
|-------|------|-------------|
|
|
954
|
-
| `id` | `string` | Unique identifier for this stat record |
|
|
955
|
-
| `post_id` | `string` | ID of the post these stats belong to |
|
|
956
|
-
| `views` | `number \| null` | Total number of views the post received |
|
|
957
|
-
| `likes` | `number \| null` | Total number of likes the post received |
|
|
958
|
-
| `comments` | `number \| null` | Total number of comments on the post |
|
|
959
|
-
| `shares` | `number \| null` | Total number of times the post was shared |
|
|
960
|
-
| `saves` | `number \| null` | Total number of times the post was saved/bookmarked |
|
|
961
|
-
| `created_at` | `string` | ISO 8601 timestamp when this stat was recorded |
|
|
962
|
-
|
|
963
|
-
**Example:**
|
|
964
|
-
|
|
965
|
-
```typescript
|
|
966
|
-
const response = await client.posts.getStats({
|
|
967
|
-
postIds: ['post-1', 'post-2', 'post-3'],
|
|
968
|
-
startDate: '2024-01-01T00:00:00Z'
|
|
969
|
-
});
|
|
970
|
-
|
|
971
|
-
if (response.ok) {
|
|
972
|
-
response.data.forEach(stat => {
|
|
973
|
-
console.log(`Post ${stat.post_id}:`);
|
|
974
|
-
console.log(` Views: ${stat.views}`);
|
|
975
|
-
console.log(` Likes: ${stat.likes}`);
|
|
976
|
-
console.log(` Engagement: ${(stat.likes ?? 0) + (stat.comments ?? 0)}`);
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
```
|
|
980
|
-
|
|
981
|
-
---
|
|
982
|
-
|
|
983
|
-
#### `client.posts.refreshStats(params?)`
|
|
984
|
-
|
|
985
|
-
Refresh post statistics by fetching live data from TikTok/Instagram API.
|
|
986
|
-
|
|
987
|
-
**Endpoint:** `POST /post/stats/refresh`
|
|
988
|
-
|
|
989
|
-
**Parameters:**
|
|
990
|
-
|
|
991
|
-
| Parameter | Type | Required | Description |
|
|
992
|
-
|-----------|------|----------|-------------|
|
|
993
|
-
| `postIds` | `string[]` | No | Array of post IDs to refresh stats for |
|
|
994
|
-
|
|
995
|
-
**Returns:** `ApiResponse<PostStat[]>`
|
|
996
|
-
|
|
997
|
-
Returns an array of newly created PostStat objects with live data from TikTok or Instagram. This endpoint fetches fresh statistics directly from the platform APIs and creates new stat records in the database. Use this when you need up-to-date engagement metrics instead of historical data. The API automatically determines which platform to query based on the account type.
|
|
998
|
-
|
|
999
|
-
**Key Differences from `getStats()`:**
|
|
1000
|
-
- `refreshStats()` fetches **live data** from TikTok/Instagram API and creates new records
|
|
1001
|
-
- `getStats()` retrieves **historical data** from your database
|
|
1002
|
-
|
|
1003
|
-
**Important:** Posts must have a valid `social_id` (TikTok video ID or Instagram reel code) to refresh statistics. The endpoint uses this ID to fetch live metrics from the platform.
|
|
1004
|
-
|
|
1005
|
-
**Example:**
|
|
1006
|
-
|
|
1007
|
-
```typescript
|
|
1008
|
-
const response = await client.posts.refreshStats({
|
|
1009
|
-
postIds: ['post-1', 'post-2', 'post-3']
|
|
1010
|
-
});
|
|
1011
|
-
|
|
1012
|
-
if (response.ok) {
|
|
1013
|
-
console.log(`Successfully refreshed ${response.data.length} posts`);
|
|
1014
|
-
response.data.forEach(stat => {
|
|
1015
|
-
console.log(`Post ${stat.post_id}:`);
|
|
1016
|
-
console.log(` Views: ${stat.views}`);
|
|
1017
|
-
console.log(` Likes: ${stat.likes}`);
|
|
1018
|
-
console.log(` Comments: ${stat.comments}`);
|
|
1019
|
-
console.log(` Engagement Rate: ${((stat.likes ?? 0) / (stat.views ?? 1) * 100).toFixed(2)}%`);
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
// Refresh all posts (no filters)
|
|
1024
|
-
const allPostsResponse = await client.posts.refreshStats();
|
|
1025
|
-
```
|
|
1026
|
-
|
|
1027
|
-
---
|
|
1028
|
-
|
|
1029
|
-
#### `client.posts.getStatus(params)`
|
|
1030
|
-
|
|
1031
|
-
Get the status of a specific post.
|
|
1032
|
-
|
|
1033
|
-
**Endpoint:** `POST /post/status`
|
|
1034
|
-
|
|
1035
|
-
**Parameters:**
|
|
1036
|
-
|
|
1037
|
-
| Parameter | Type | Required | Description |
|
|
1038
|
-
|-----------|------|----------|-------------|
|
|
1039
|
-
| `postId` | `string` | **Yes** | Post ID to check status for |
|
|
36
|
+
**Important:** Keep your API key secure! Never commit it to version control or expose it in client-side code.
|
|
1040
37
|
|
|
1041
|
-
|
|
38
|
+
## Documentation
|
|
1042
39
|
|
|
1043
|
-
|
|
40
|
+
For complete API documentation, including all endpoints, parameters, and examples, visit:
|
|
1044
41
|
|
|
1045
|
-
**
|
|
42
|
+
**[docs.ugc.inc](https://docs.ugc.inc)**
|
|
1046
43
|
|
|
1047
|
-
|
|
1048
|
-
{
|
|
1049
|
-
post_id: string; // ID of the post being checked
|
|
1050
|
-
status: string; // Current status
|
|
1051
|
-
}
|
|
1052
|
-
```
|
|
1053
|
-
|
|
1054
|
-
**Status Values:** `'scheduled' | 'pending' | 'complete' | 'failed'`
|
|
1055
|
-
|
|
1056
|
-
- `'scheduled'` - Post is scheduled to be published at a future time
|
|
1057
|
-
- `'pending'` - Post is currently being processed/published
|
|
1058
|
-
- `'complete'` - Post was successfully published
|
|
1059
|
-
- `'failed'` - Post failed to publish (check error logs)
|
|
44
|
+
## TypeScript Support
|
|
1060
45
|
|
|
1061
|
-
|
|
46
|
+
This package is written in TypeScript and provides full type definitions:
|
|
1062
47
|
|
|
1063
48
|
```typescript
|
|
1064
|
-
|
|
1065
|
-
postId: 'post-id'
|
|
1066
|
-
});
|
|
1067
|
-
|
|
1068
|
-
if (response.ok) {
|
|
1069
|
-
console.log(`Post status: ${response.data.status}`);
|
|
1070
|
-
}
|
|
49
|
+
import type { Account, Post, Task, ApiResponse } from 'ugcinc';
|
|
1071
50
|
```
|
|
1072
51
|
|
|
1073
|
-
---
|
|
1074
|
-
|
|
1075
52
|
## License
|
|
1076
53
|
|
|
1077
54
|
MIT
|
|
1078
|
-
|
package/dist/accounts.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClient } from './base';
|
|
2
|
-
import type { Account,
|
|
2
|
+
import type { Account, AccountTask, GetAccountsParams, GetAccountStatusParams, UpdateAccountInfoParams, UpdateAccountSocialParams, ApiResponse } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Client for managing accounts
|
|
5
5
|
*/
|
|
@@ -8,14 +8,6 @@ export declare class AccountsClient extends BaseClient {
|
|
|
8
8
|
* Get accounts with optional filters
|
|
9
9
|
*/
|
|
10
10
|
getAccounts(params?: GetAccountsParams): Promise<ApiResponse<Account[]>>;
|
|
11
|
-
/**
|
|
12
|
-
* Get account statistics
|
|
13
|
-
*/
|
|
14
|
-
getStats(params?: GetAccountStatsParams): Promise<ApiResponse<AccountStat[]>>;
|
|
15
|
-
/**
|
|
16
|
-
* Refresh account statistics from TikTok/Instagram API
|
|
17
|
-
*/
|
|
18
|
-
refreshStats(params?: RefreshAccountStatsParams): Promise<ApiResponse<AccountStat[]>>;
|
|
19
11
|
/**
|
|
20
12
|
* Get account status (tasks) for one or more accounts
|
|
21
13
|
*/
|
package/dist/accounts.js
CHANGED
|
@@ -12,18 +12,6 @@ class AccountsClient extends base_1.BaseClient {
|
|
|
12
12
|
async getAccounts(params) {
|
|
13
13
|
return this.post('/accounts', params ?? {});
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Get account statistics
|
|
17
|
-
*/
|
|
18
|
-
async getStats(params) {
|
|
19
|
-
return this.post('/accounts/stats', params ?? {});
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Refresh account statistics from TikTok/Instagram API
|
|
23
|
-
*/
|
|
24
|
-
async refreshStats(params) {
|
|
25
|
-
return this.post('/accounts/stats/refresh', params ?? {});
|
|
26
|
-
}
|
|
27
15
|
/**
|
|
28
16
|
* Get account status (tasks) for one or more accounts
|
|
29
17
|
*/
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AccountsClient } from './accounts';
|
|
2
2
|
import { TasksClient } from './tasks';
|
|
3
3
|
import { PostsClient } from './posts';
|
|
4
|
+
import { StatsClient } from './stats';
|
|
4
5
|
import type { ClientConfig } from './base';
|
|
5
6
|
/**
|
|
6
7
|
* Main UGC Inc API Client
|
|
@@ -40,5 +41,9 @@ export declare class UGCClient {
|
|
|
40
41
|
* Client for post-related operations
|
|
41
42
|
*/
|
|
42
43
|
posts: PostsClient;
|
|
44
|
+
/**
|
|
45
|
+
* Client for statistics operations
|
|
46
|
+
*/
|
|
47
|
+
stats: StatsClient;
|
|
43
48
|
constructor(config: ClientConfig);
|
|
44
49
|
}
|
package/dist/client.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.UGCClient = void 0;
|
|
|
4
4
|
const accounts_1 = require("./accounts");
|
|
5
5
|
const tasks_1 = require("./tasks");
|
|
6
6
|
const posts_1 = require("./posts");
|
|
7
|
+
const stats_1 = require("./stats");
|
|
7
8
|
/**
|
|
8
9
|
* Main UGC Inc API Client
|
|
9
10
|
*
|
|
@@ -34,6 +35,7 @@ class UGCClient {
|
|
|
34
35
|
this.accounts = new accounts_1.AccountsClient(config);
|
|
35
36
|
this.tasks = new tasks_1.TasksClient(config);
|
|
36
37
|
this.posts = new posts_1.PostsClient(config);
|
|
38
|
+
this.stats = new stats_1.StatsClient(config);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
exports.UGCClient = UGCClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export { UGCClient } from './client';
|
|
|
7
7
|
export { AccountsClient } from './accounts';
|
|
8
8
|
export { TasksClient } from './tasks';
|
|
9
9
|
export { PostsClient } from './posts';
|
|
10
|
+
export { StatsClient } from './stats';
|
|
10
11
|
export type { ClientConfig, } from './base';
|
|
11
|
-
export type { SuccessResponse, ErrorResponse, ApiResponse, Account, AccountStat, AccountTask, EditProfileInfo, Task, TaskType, Post, PostType, PostStat, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, GetTasksParams, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, } from './types';
|
|
12
|
+
export type { SuccessResponse, ErrorResponse, ApiResponse, Account, AccountStat, AccountTask, EditProfileInfo, Task, TaskType, Post, PostType, PostStat, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, GetTasksParams, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, RefreshStatsParams, RefreshStatsResponse, } from './types';
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Official TypeScript/JavaScript client for the UGC Inc API
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
|
|
8
|
+
exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
|
|
9
9
|
var client_1 = require("./client");
|
|
10
10
|
Object.defineProperty(exports, "UGCClient", { enumerable: true, get: function () { return client_1.UGCClient; } });
|
|
11
11
|
var accounts_1 = require("./accounts");
|
|
@@ -14,3 +14,5 @@ var tasks_1 = require("./tasks");
|
|
|
14
14
|
Object.defineProperty(exports, "TasksClient", { enumerable: true, get: function () { return tasks_1.TasksClient; } });
|
|
15
15
|
var posts_1 = require("./posts");
|
|
16
16
|
Object.defineProperty(exports, "PostsClient", { enumerable: true, get: function () { return posts_1.PostsClient; } });
|
|
17
|
+
var stats_1 = require("./stats");
|
|
18
|
+
Object.defineProperty(exports, "StatsClient", { enumerable: true, get: function () { return stats_1.StatsClient; } });
|
package/dist/posts.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClient } from './base';
|
|
2
|
-
import type { Post,
|
|
2
|
+
import type { Post, GetPostsParams, CreateSlideshowParams, GetPostStatusParams, CreateVideoParams, ApiResponse } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Client for managing posts
|
|
5
5
|
*/
|
|
@@ -12,15 +12,6 @@ export declare class PostsClient extends BaseClient {
|
|
|
12
12
|
* Create a slideshow post
|
|
13
13
|
*/
|
|
14
14
|
createSlideshow(params: CreateSlideshowParams): Promise<ApiResponse<Post>>;
|
|
15
|
-
/**
|
|
16
|
-
* Get post statistics
|
|
17
|
-
*/
|
|
18
|
-
getStats(params?: GetPostStatsParams): Promise<ApiResponse<PostStat[]>>;
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
* Refresh post statistics from TikTok/Instagram API
|
|
22
|
-
*/
|
|
23
|
-
refreshStats(params?: RefreshPostStatsParams): Promise<ApiResponse<PostStat[]>>;
|
|
24
15
|
/**
|
|
25
16
|
* Get post status
|
|
26
17
|
*/
|
package/dist/posts.js
CHANGED
|
@@ -18,19 +18,6 @@ class PostsClient extends base_1.BaseClient {
|
|
|
18
18
|
async createSlideshow(params) {
|
|
19
19
|
return this.post('/post/slideshow', params);
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Get post statistics
|
|
23
|
-
*/
|
|
24
|
-
async getStats(params) {
|
|
25
|
-
return this.post('/post/stats', params ?? {});
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
* Refresh post statistics from TikTok/Instagram API
|
|
30
|
-
*/
|
|
31
|
-
async refreshStats(params) {
|
|
32
|
-
return this.post('/post/stats/refresh', params ?? {});
|
|
33
|
-
}
|
|
34
21
|
/**
|
|
35
22
|
* Get post status
|
|
36
23
|
*/
|
package/dist/stats.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseClient } from './base';
|
|
2
|
+
import type { AccountStat, PostStat, GetAccountStatsParams, GetPostStatsParams, RefreshStatsParams, RefreshStatsResponse, ApiResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for managing statistics
|
|
5
|
+
*/
|
|
6
|
+
export declare class StatsClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
* Get account statistics
|
|
9
|
+
*/
|
|
10
|
+
getAccountStats(params?: GetAccountStatsParams): Promise<ApiResponse<AccountStat[]>>;
|
|
11
|
+
/**
|
|
12
|
+
* Get post statistics
|
|
13
|
+
*/
|
|
14
|
+
getPostStats(params?: GetPostStatsParams): Promise<ApiResponse<PostStat[]>>;
|
|
15
|
+
/**
|
|
16
|
+
* Refresh statistics for an account and all its posts
|
|
17
|
+
* Fetches live data from TikTok/Instagram API and creates new stat records
|
|
18
|
+
*/
|
|
19
|
+
refresh(params: RefreshStatsParams): Promise<ApiResponse<RefreshStatsResponse>>;
|
|
20
|
+
}
|
package/dist/stats.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatsClient = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
/**
|
|
6
|
+
* Client for managing statistics
|
|
7
|
+
*/
|
|
8
|
+
class StatsClient extends base_1.BaseClient {
|
|
9
|
+
/**
|
|
10
|
+
* Get account statistics
|
|
11
|
+
*/
|
|
12
|
+
async getAccountStats(params) {
|
|
13
|
+
return this.post('/stats/accounts', params ?? {});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get post statistics
|
|
17
|
+
*/
|
|
18
|
+
async getPostStats(params) {
|
|
19
|
+
return this.post('/stats/posts', params ?? {});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Refresh statistics for an account and all its posts
|
|
23
|
+
* Fetches live data from TikTok/Instagram API and creates new stat records
|
|
24
|
+
*/
|
|
25
|
+
async refresh(params) {
|
|
26
|
+
return this.post('/stats/refresh', params);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.StatsClient = StatsClient;
|
package/dist/types.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface EditProfileInfo {
|
|
|
53
53
|
/**
|
|
54
54
|
* Task types
|
|
55
55
|
*/
|
|
56
|
-
export type TaskType = 'warmup_scroll' | 'warmup_search_term' | 'warmup_search_profile' | 'edit_profile';
|
|
56
|
+
export type TaskType = 'warmup_scroll' | 'warmup_search_term' | 'warmup_search_profile' | 'edit_profile' | 'update_posts';
|
|
57
57
|
export interface Task {
|
|
58
58
|
id: string;
|
|
59
59
|
account_id: string;
|
|
@@ -61,7 +61,7 @@ export interface Task {
|
|
|
61
61
|
status: string;
|
|
62
62
|
scheduled_time: string | null;
|
|
63
63
|
duration: number | null;
|
|
64
|
-
keywords: string
|
|
64
|
+
keywords: string | null;
|
|
65
65
|
edit_profile_info: EditProfileInfo | null;
|
|
66
66
|
created_at: string;
|
|
67
67
|
}
|
|
@@ -105,12 +105,6 @@ export interface GetAccountStatsParams {
|
|
|
105
105
|
org_group?: string;
|
|
106
106
|
user_group?: string;
|
|
107
107
|
}
|
|
108
|
-
export interface RefreshAccountStatsParams {
|
|
109
|
-
accountIds?: string[];
|
|
110
|
-
tag?: string;
|
|
111
|
-
org_group?: string;
|
|
112
|
-
user_group?: string;
|
|
113
|
-
}
|
|
114
108
|
export interface GetAccountStatusParams {
|
|
115
109
|
accountIds?: string[];
|
|
116
110
|
includeCompleted?: boolean;
|
|
@@ -151,9 +145,6 @@ export interface GetPostStatsParams {
|
|
|
151
145
|
startDate?: string;
|
|
152
146
|
endDate?: string;
|
|
153
147
|
}
|
|
154
|
-
export interface RefreshPostStatsParams {
|
|
155
|
-
postIds?: string[];
|
|
156
|
-
}
|
|
157
148
|
export interface GetPostStatusParams {
|
|
158
149
|
postId: string;
|
|
159
150
|
}
|
|
@@ -165,3 +156,11 @@ export interface CreateVideoParams {
|
|
|
165
156
|
videoUrl: string;
|
|
166
157
|
strict?: boolean;
|
|
167
158
|
}
|
|
159
|
+
export interface RefreshStatsParams {
|
|
160
|
+
accountId: string;
|
|
161
|
+
}
|
|
162
|
+
export interface RefreshStatsResponse {
|
|
163
|
+
account_stats: AccountStat;
|
|
164
|
+
post_stats: PostStat[];
|
|
165
|
+
post_stats_count: number;
|
|
166
|
+
}
|