ugcinc 1.0.0
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 +313 -0
- package/dist/accounts.d.ts +25 -0
- package/dist/accounts.js +34 -0
- package/dist/base.d.ts +12 -0
- package/dist/base.js +39 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.js +39 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +16 -0
- package/dist/posts.d.ts +30 -0
- package/dist/posts.js +40 -0
- package/dist/tasks.d.ts +11 -0
- package/dist/tasks.js +16 -0
- package/dist/types.d.ts +155 -0
- package/dist/types.js +2 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# ugcinc
|
|
2
|
+
|
|
3
|
+
Official TypeScript/JavaScript client for the UGC Inc API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install ugcinc
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
### 1. Get Your API Key
|
|
14
|
+
|
|
15
|
+
Contact UGC Inc to obtain your API key. You'll need this to authenticate all API requests.
|
|
16
|
+
|
|
17
|
+
### 2. Initialize the Client
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { UGCClient } from 'ugcinc';
|
|
21
|
+
|
|
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
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Important:** Keep your API key secure! Never commit it to version control or expose it in client-side code.
|
|
29
|
+
|
|
30
|
+
## API Documentation
|
|
31
|
+
|
|
32
|
+
### Accounts
|
|
33
|
+
|
|
34
|
+
The `accounts` object provides methods for managing accounts.
|
|
35
|
+
|
|
36
|
+
#### Get Accounts
|
|
37
|
+
|
|
38
|
+
Retrieve accounts with optional filters.
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const response = await client.accounts.getAccounts({
|
|
42
|
+
tag: 'influencer',
|
|
43
|
+
org_group: 'group1',
|
|
44
|
+
user_group: 'users1'
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (response.ok) {
|
|
48
|
+
console.log(response.data); // Account[]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
#### Get Account Statistics
|
|
53
|
+
|
|
54
|
+
Get statistics for accounts.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const response = await client.accounts.getStats({
|
|
58
|
+
accountIds: ['account-id-1', 'account-id-2'],
|
|
59
|
+
startDate: '2024-01-01',
|
|
60
|
+
endDate: '2024-12-31'
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (response.ok) {
|
|
64
|
+
response.data.forEach(stat => {
|
|
65
|
+
console.log(`Account ${stat.account_id}: ${stat.followers} followers`);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### Get Account Status
|
|
71
|
+
|
|
72
|
+
Get the status of tasks for a specific account.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const response = await client.accounts.getStatus({
|
|
76
|
+
accountId: 'account-id',
|
|
77
|
+
includeCompleted: false
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (response.ok) {
|
|
81
|
+
console.log(response.data); // AccountTask[]
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### Update Account Info
|
|
86
|
+
|
|
87
|
+
Update account profile information.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const response = await client.accounts.updateInfo({
|
|
91
|
+
accountId: 'account-id',
|
|
92
|
+
nickName: 'New Name',
|
|
93
|
+
bio: 'New bio text',
|
|
94
|
+
avatarUrl: 'https://example.com/avatar.jpg',
|
|
95
|
+
site: 'https://example.com'
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (response.ok) {
|
|
99
|
+
console.log(response.data.message);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Tasks
|
|
104
|
+
|
|
105
|
+
The `tasks` object provides methods for managing tasks.
|
|
106
|
+
|
|
107
|
+
#### Get Tasks
|
|
108
|
+
|
|
109
|
+
Retrieve tasks with optional filters.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const response = await client.tasks.getTasks({
|
|
113
|
+
accountIds: ['account-id-1'],
|
|
114
|
+
startDate: '2024-01-01',
|
|
115
|
+
endDate: '2024-12-31',
|
|
116
|
+
taskType: 'edit_profile'
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (response.ok) {
|
|
120
|
+
console.log(response.data); // Task[]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Posts
|
|
125
|
+
|
|
126
|
+
The `posts` object provides methods for managing posts.
|
|
127
|
+
|
|
128
|
+
#### Get Posts
|
|
129
|
+
|
|
130
|
+
Retrieve posts with optional filters.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
const response = await client.posts.getPosts({
|
|
134
|
+
accountIds: ['account-id-1'],
|
|
135
|
+
startDate: '2024-01-01',
|
|
136
|
+
endDate: '2024-12-31'
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (response.ok) {
|
|
140
|
+
console.log(response.data); // Post[]
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### Create Slideshow
|
|
145
|
+
|
|
146
|
+
Create a slideshow post.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const response = await client.posts.createSlideshow({
|
|
150
|
+
accountId: 'account-id',
|
|
151
|
+
imageUrls: [
|
|
152
|
+
'https://example.com/image1.jpg',
|
|
153
|
+
'https://example.com/image2.jpg',
|
|
154
|
+
'https://example.com/image3.jpg'
|
|
155
|
+
],
|
|
156
|
+
caption: 'Check out this slideshow!',
|
|
157
|
+
musicPostId: 'music-id',
|
|
158
|
+
postTime: '2024-12-31T12:00:00Z',
|
|
159
|
+
strict: true
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
if (response.ok) {
|
|
163
|
+
console.log(`Post created: ${response.data.id}`);
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Create Video
|
|
168
|
+
|
|
169
|
+
Create a video post.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
const response = await client.posts.createVideo({
|
|
173
|
+
accountId: 'account-id',
|
|
174
|
+
videoUrl: 'https://example.com/video.mp4',
|
|
175
|
+
caption: 'My awesome video!',
|
|
176
|
+
musicPostId: 'music-id',
|
|
177
|
+
postTime: '2024-12-31T12:00:00Z',
|
|
178
|
+
strict: true
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
if (response.ok) {
|
|
182
|
+
console.log(`Post created: ${response.data.id}`);
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### Get Post Statistics
|
|
187
|
+
|
|
188
|
+
Get statistics for posts.
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
const response = await client.posts.getStats({
|
|
192
|
+
postIds: ['post-id-1', 'post-id-2'],
|
|
193
|
+
startDate: '2024-01-01',
|
|
194
|
+
endDate: '2024-12-31'
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
if (response.ok) {
|
|
198
|
+
response.data.forEach(stat => {
|
|
199
|
+
console.log(`Post ${stat.post_id}: ${stat.views} views, ${stat.likes} likes`);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Get Post Status
|
|
205
|
+
|
|
206
|
+
Get the status of a specific post.
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
const response = await client.posts.getStatus({
|
|
210
|
+
postId: 'post-id'
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
if (response.ok) {
|
|
214
|
+
console.log(`Post status: ${response.data.status}`);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Response Handling
|
|
219
|
+
|
|
220
|
+
All API methods return a response object with the following structure:
|
|
221
|
+
|
|
222
|
+
### Success Response
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
{
|
|
226
|
+
ok: true,
|
|
227
|
+
code: 200,
|
|
228
|
+
message: "Success",
|
|
229
|
+
data: T // The actual response data
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Error Response
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
{
|
|
237
|
+
ok: false,
|
|
238
|
+
code: number, // HTTP status code
|
|
239
|
+
message: string // Error message
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Type-Safe Response Handling
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
const response = await client.accounts.getAccounts();
|
|
247
|
+
|
|
248
|
+
if (response.ok) {
|
|
249
|
+
// TypeScript knows response.data is Account[]
|
|
250
|
+
response.data.forEach(account => {
|
|
251
|
+
console.log(account.username);
|
|
252
|
+
});
|
|
253
|
+
} else {
|
|
254
|
+
// TypeScript knows response has code and message
|
|
255
|
+
console.error(`Error ${response.code}: ${response.message}`);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## TypeScript Support
|
|
260
|
+
|
|
261
|
+
This package is written in TypeScript and provides full type definitions. All types are exported for your convenience:
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import type {
|
|
265
|
+
Account,
|
|
266
|
+
Post,
|
|
267
|
+
Task,
|
|
268
|
+
CreateVideoParams,
|
|
269
|
+
ApiResponse
|
|
270
|
+
} from 'ugcinc';
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Error Handling
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
try {
|
|
277
|
+
const response = await client.accounts.getAccounts();
|
|
278
|
+
|
|
279
|
+
if (!response.ok) {
|
|
280
|
+
console.error(`API Error: ${response.message}`);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Handle success
|
|
285
|
+
console.log(response.data);
|
|
286
|
+
} catch (error) {
|
|
287
|
+
console.error('Network or parsing error:', error);
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Environment Variables
|
|
292
|
+
|
|
293
|
+
For production use, store your API key securely using environment variables:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# .env file
|
|
297
|
+
UGC_API_KEY=your-api-key-here
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Then in your code:
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
import { UGCClient } from 'ugcinc';
|
|
304
|
+
|
|
305
|
+
const client = new UGCClient({
|
|
306
|
+
apiKey: process.env.UGC_API_KEY!
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## License
|
|
311
|
+
|
|
312
|
+
MIT
|
|
313
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseClient } from './base';
|
|
2
|
+
import type { Account, AccountStat, AccountTask, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, ApiResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for managing accounts
|
|
5
|
+
*/
|
|
6
|
+
export declare class AccountsClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
* Get accounts with optional filters
|
|
9
|
+
*/
|
|
10
|
+
getAccounts(params?: GetAccountsParams): Promise<ApiResponse<Account[]>>;
|
|
11
|
+
/**
|
|
12
|
+
* Get account statistics
|
|
13
|
+
*/
|
|
14
|
+
getStats(params?: GetAccountStatsParams): Promise<ApiResponse<AccountStat[]>>;
|
|
15
|
+
/**
|
|
16
|
+
* Get account status (tasks)
|
|
17
|
+
*/
|
|
18
|
+
getStatus(params: GetAccountStatusParams): Promise<ApiResponse<AccountTask[]>>;
|
|
19
|
+
/**
|
|
20
|
+
* Update account profile information
|
|
21
|
+
*/
|
|
22
|
+
updateInfo(params: UpdateAccountInfoParams): Promise<ApiResponse<{
|
|
23
|
+
message: string;
|
|
24
|
+
}>>;
|
|
25
|
+
}
|
package/dist/accounts.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccountsClient = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
/**
|
|
6
|
+
* Client for managing accounts
|
|
7
|
+
*/
|
|
8
|
+
class AccountsClient extends base_1.BaseClient {
|
|
9
|
+
/**
|
|
10
|
+
* Get accounts with optional filters
|
|
11
|
+
*/
|
|
12
|
+
async getAccounts(params) {
|
|
13
|
+
return this.post('/accounts', params ?? {});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get account statistics
|
|
17
|
+
*/
|
|
18
|
+
async getStats(params) {
|
|
19
|
+
return this.post('/accounts/stats', params ?? {});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get account status (tasks)
|
|
23
|
+
*/
|
|
24
|
+
async getStatus(params) {
|
|
25
|
+
return this.post('/accounts/status', params);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Update account profile information
|
|
29
|
+
*/
|
|
30
|
+
async updateInfo(params) {
|
|
31
|
+
return this.post('/accounts/update-info', params);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.AccountsClient = AccountsClient;
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ApiResponse } from './types';
|
|
2
|
+
export interface ClientConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class BaseClient {
|
|
7
|
+
protected apiKey: string;
|
|
8
|
+
protected baseUrl: string;
|
|
9
|
+
constructor(config: ClientConfig);
|
|
10
|
+
protected request<T>(endpoint: string, options?: RequestInit): Promise<ApiResponse<T>>;
|
|
11
|
+
protected post<T>(endpoint: string, body?: unknown): Promise<ApiResponse<T>>;
|
|
12
|
+
}
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseClient = void 0;
|
|
4
|
+
class BaseClient {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.apiKey = config.apiKey;
|
|
7
|
+
this.baseUrl = config.baseUrl ?? 'https://api.ugc.inc';
|
|
8
|
+
}
|
|
9
|
+
async request(endpoint, options = {}) {
|
|
10
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
11
|
+
const headers = {
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
14
|
+
...options.headers,
|
|
15
|
+
};
|
|
16
|
+
try {
|
|
17
|
+
const response = await fetch(url, {
|
|
18
|
+
...options,
|
|
19
|
+
headers,
|
|
20
|
+
});
|
|
21
|
+
const data = await response.json();
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return {
|
|
26
|
+
ok: false,
|
|
27
|
+
code: 500,
|
|
28
|
+
message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async post(endpoint, body) {
|
|
33
|
+
return this.request(endpoint, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.BaseClient = BaseClient;
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AccountsClient } from './accounts';
|
|
2
|
+
import { TasksClient } from './tasks';
|
|
3
|
+
import { PostsClient } from './posts';
|
|
4
|
+
import type { ClientConfig } from './base';
|
|
5
|
+
/**
|
|
6
|
+
* Main UGC Inc API Client
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { UGCClient } from 'ugcinc';
|
|
11
|
+
*
|
|
12
|
+
* const client = new UGCClient({
|
|
13
|
+
* apiKey: 'your-api-key'
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Get accounts
|
|
17
|
+
* const accountsResponse = await client.accounts.getAccounts();
|
|
18
|
+
* if (accountsResponse.ok) {
|
|
19
|
+
* console.log(accountsResponse.data);
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* // Create a video post
|
|
23
|
+
* const postResponse = await client.posts.createVideo({
|
|
24
|
+
* accountId: 'account-id',
|
|
25
|
+
* videoUrl: 'https://example.com/video.mp4',
|
|
26
|
+
* caption: 'My awesome video!',
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class UGCClient {
|
|
31
|
+
/**
|
|
32
|
+
* Client for account-related operations
|
|
33
|
+
*/
|
|
34
|
+
accounts: AccountsClient;
|
|
35
|
+
/**
|
|
36
|
+
* Client for task-related operations
|
|
37
|
+
*/
|
|
38
|
+
tasks: TasksClient;
|
|
39
|
+
/**
|
|
40
|
+
* Client for post-related operations
|
|
41
|
+
*/
|
|
42
|
+
posts: PostsClient;
|
|
43
|
+
constructor(config: ClientConfig);
|
|
44
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UGCClient = void 0;
|
|
4
|
+
const accounts_1 = require("./accounts");
|
|
5
|
+
const tasks_1 = require("./tasks");
|
|
6
|
+
const posts_1 = require("./posts");
|
|
7
|
+
/**
|
|
8
|
+
* Main UGC Inc API Client
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { UGCClient } from 'ugcinc';
|
|
13
|
+
*
|
|
14
|
+
* const client = new UGCClient({
|
|
15
|
+
* apiKey: 'your-api-key'
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Get accounts
|
|
19
|
+
* const accountsResponse = await client.accounts.getAccounts();
|
|
20
|
+
* if (accountsResponse.ok) {
|
|
21
|
+
* console.log(accountsResponse.data);
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* // Create a video post
|
|
25
|
+
* const postResponse = await client.posts.createVideo({
|
|
26
|
+
* accountId: 'account-id',
|
|
27
|
+
* videoUrl: 'https://example.com/video.mp4',
|
|
28
|
+
* caption: 'My awesome video!',
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
class UGCClient {
|
|
33
|
+
constructor(config) {
|
|
34
|
+
this.accounts = new accounts_1.AccountsClient(config);
|
|
35
|
+
this.tasks = new tasks_1.TasksClient(config);
|
|
36
|
+
this.posts = new posts_1.PostsClient(config);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.UGCClient = UGCClient;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UGC Inc API Client
|
|
3
|
+
*
|
|
4
|
+
* Official TypeScript/JavaScript client for the UGC Inc API
|
|
5
|
+
*/
|
|
6
|
+
export { UGCClient } from './client';
|
|
7
|
+
export { AccountsClient } from './accounts';
|
|
8
|
+
export { TasksClient } from './tasks';
|
|
9
|
+
export { PostsClient } from './posts';
|
|
10
|
+
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';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* UGC Inc API Client
|
|
4
|
+
*
|
|
5
|
+
* Official TypeScript/JavaScript client for the UGC Inc API
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
|
|
9
|
+
var client_1 = require("./client");
|
|
10
|
+
Object.defineProperty(exports, "UGCClient", { enumerable: true, get: function () { return client_1.UGCClient; } });
|
|
11
|
+
var accounts_1 = require("./accounts");
|
|
12
|
+
Object.defineProperty(exports, "AccountsClient", { enumerable: true, get: function () { return accounts_1.AccountsClient; } });
|
|
13
|
+
var tasks_1 = require("./tasks");
|
|
14
|
+
Object.defineProperty(exports, "TasksClient", { enumerable: true, get: function () { return tasks_1.TasksClient; } });
|
|
15
|
+
var posts_1 = require("./posts");
|
|
16
|
+
Object.defineProperty(exports, "PostsClient", { enumerable: true, get: function () { return posts_1.PostsClient; } });
|
package/dist/posts.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseClient } from './base';
|
|
2
|
+
import type { Post, PostStat, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, ApiResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for managing posts
|
|
5
|
+
*/
|
|
6
|
+
export declare class PostsClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
* Get posts with optional filters
|
|
9
|
+
*/
|
|
10
|
+
getPosts(params?: GetPostsParams): Promise<ApiResponse<Post[]>>;
|
|
11
|
+
/**
|
|
12
|
+
* Create a slideshow post
|
|
13
|
+
*/
|
|
14
|
+
createSlideshow(params: CreateSlideshowParams): Promise<ApiResponse<Post>>;
|
|
15
|
+
/**
|
|
16
|
+
* Get post statistics
|
|
17
|
+
*/
|
|
18
|
+
getStats(params?: GetPostStatsParams): Promise<ApiResponse<PostStat[]>>;
|
|
19
|
+
/**
|
|
20
|
+
* Get post status
|
|
21
|
+
*/
|
|
22
|
+
getStatus(params: GetPostStatusParams): Promise<ApiResponse<{
|
|
23
|
+
post_id: string;
|
|
24
|
+
status: string;
|
|
25
|
+
}>>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a video post
|
|
28
|
+
*/
|
|
29
|
+
createVideo(params: CreateVideoParams): Promise<ApiResponse<Post>>;
|
|
30
|
+
}
|
package/dist/posts.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostsClient = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
/**
|
|
6
|
+
* Client for managing posts
|
|
7
|
+
*/
|
|
8
|
+
class PostsClient extends base_1.BaseClient {
|
|
9
|
+
/**
|
|
10
|
+
* Get posts with optional filters
|
|
11
|
+
*/
|
|
12
|
+
async getPosts(params) {
|
|
13
|
+
return this.post('/post', params ?? {});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a slideshow post
|
|
17
|
+
*/
|
|
18
|
+
async createSlideshow(params) {
|
|
19
|
+
return this.post('/post/slideshow', params);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get post statistics
|
|
23
|
+
*/
|
|
24
|
+
async getStats(params) {
|
|
25
|
+
return this.post('/post/stats', params ?? {});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get post status
|
|
29
|
+
*/
|
|
30
|
+
async getStatus(params) {
|
|
31
|
+
return this.post('/post/status', params);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a video post
|
|
35
|
+
*/
|
|
36
|
+
async createVideo(params) {
|
|
37
|
+
return this.post('/post/video', params);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.PostsClient = PostsClient;
|
package/dist/tasks.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseClient } from './base';
|
|
2
|
+
import type { Task, GetTasksParams, ApiResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for managing tasks
|
|
5
|
+
*/
|
|
6
|
+
export declare class TasksClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
* Get tasks with optional filters
|
|
9
|
+
*/
|
|
10
|
+
getTasks(params?: GetTasksParams): Promise<ApiResponse<Task[]>>;
|
|
11
|
+
}
|
package/dist/tasks.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TasksClient = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
/**
|
|
6
|
+
* Client for managing tasks
|
|
7
|
+
*/
|
|
8
|
+
class TasksClient extends base_1.BaseClient {
|
|
9
|
+
/**
|
|
10
|
+
* Get tasks with optional filters
|
|
11
|
+
*/
|
|
12
|
+
async getTasks(params) {
|
|
13
|
+
return this.post('/tasks', params ?? {});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.TasksClient = TasksClient;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API response types
|
|
3
|
+
*/
|
|
4
|
+
export interface SuccessResponse<T> {
|
|
5
|
+
code: 200;
|
|
6
|
+
message: string;
|
|
7
|
+
data: T;
|
|
8
|
+
ok: true;
|
|
9
|
+
}
|
|
10
|
+
export interface ErrorResponse {
|
|
11
|
+
code: number;
|
|
12
|
+
message: string;
|
|
13
|
+
ok: false;
|
|
14
|
+
data?: never;
|
|
15
|
+
}
|
|
16
|
+
export type ApiResponse<T> = SuccessResponse<T> | ErrorResponse;
|
|
17
|
+
/**
|
|
18
|
+
* Account types
|
|
19
|
+
*/
|
|
20
|
+
export interface Account {
|
|
21
|
+
id: string;
|
|
22
|
+
type: string;
|
|
23
|
+
tag: string | null;
|
|
24
|
+
org_group: string | null;
|
|
25
|
+
user_group: string | null;
|
|
26
|
+
username: string | null;
|
|
27
|
+
nick_name: string | null;
|
|
28
|
+
pfp_url: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface AccountStat {
|
|
31
|
+
id: string;
|
|
32
|
+
account_id: string;
|
|
33
|
+
followers: number | null;
|
|
34
|
+
following: number | null;
|
|
35
|
+
views: number | null;
|
|
36
|
+
likes: number | null;
|
|
37
|
+
created_at: string;
|
|
38
|
+
}
|
|
39
|
+
export interface AccountTask {
|
|
40
|
+
id: string;
|
|
41
|
+
account_id: string;
|
|
42
|
+
type: string;
|
|
43
|
+
status: string;
|
|
44
|
+
scheduled_time: string | null;
|
|
45
|
+
edit_profile_info: EditProfileInfo | null;
|
|
46
|
+
created_at: string;
|
|
47
|
+
}
|
|
48
|
+
export interface EditProfileInfo {
|
|
49
|
+
avatarUrl?: string;
|
|
50
|
+
nickName?: string;
|
|
51
|
+
bio?: string;
|
|
52
|
+
site?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Task types
|
|
56
|
+
*/
|
|
57
|
+
export type TaskType = 'warmup_scroll' | 'warmup_search_term' | 'warmup_search_profile' | 'edit_profile';
|
|
58
|
+
export interface Task {
|
|
59
|
+
id: string;
|
|
60
|
+
account_id: string;
|
|
61
|
+
type: TaskType;
|
|
62
|
+
status: string;
|
|
63
|
+
scheduled_time: string | null;
|
|
64
|
+
duration: number | null;
|
|
65
|
+
keywords: string[] | null;
|
|
66
|
+
edit_profile_info: EditProfileInfo | null;
|
|
67
|
+
created_at: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Post types
|
|
71
|
+
*/
|
|
72
|
+
export type PostType = 'video' | 'slideshow';
|
|
73
|
+
export interface Post {
|
|
74
|
+
id: string;
|
|
75
|
+
account_id: string;
|
|
76
|
+
type: PostType;
|
|
77
|
+
status: string;
|
|
78
|
+
post_url: string | null;
|
|
79
|
+
caption: string | null;
|
|
80
|
+
media_urls: string[] | null;
|
|
81
|
+
music_post_id: string | null;
|
|
82
|
+
}
|
|
83
|
+
export interface PostStat {
|
|
84
|
+
id: string;
|
|
85
|
+
post_id: string;
|
|
86
|
+
views: number | null;
|
|
87
|
+
likes: number | null;
|
|
88
|
+
comments: number | null;
|
|
89
|
+
shares: number | null;
|
|
90
|
+
saves: number | null;
|
|
91
|
+
created_at: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Request parameter types
|
|
95
|
+
*/
|
|
96
|
+
export interface GetAccountsParams {
|
|
97
|
+
tag?: string;
|
|
98
|
+
org_group?: string;
|
|
99
|
+
user_group?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface GetAccountStatsParams {
|
|
102
|
+
accountIds?: string[];
|
|
103
|
+
startDate?: string;
|
|
104
|
+
endDate?: string;
|
|
105
|
+
tag?: string;
|
|
106
|
+
org_group?: string;
|
|
107
|
+
user_group?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface GetAccountStatusParams {
|
|
110
|
+
accountId: string;
|
|
111
|
+
includeCompleted?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface UpdateAccountInfoParams {
|
|
114
|
+
accountId: string;
|
|
115
|
+
scheduledTime?: string;
|
|
116
|
+
avatarUrl?: string;
|
|
117
|
+
nickName?: string;
|
|
118
|
+
bio?: string;
|
|
119
|
+
site?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface GetTasksParams {
|
|
122
|
+
accountIds?: string[];
|
|
123
|
+
startDate?: string;
|
|
124
|
+
endDate?: string;
|
|
125
|
+
taskType?: TaskType;
|
|
126
|
+
}
|
|
127
|
+
export interface GetPostsParams {
|
|
128
|
+
accountIds?: string[];
|
|
129
|
+
startDate?: string;
|
|
130
|
+
endDate?: string;
|
|
131
|
+
}
|
|
132
|
+
export interface CreateSlideshowParams {
|
|
133
|
+
accountId: string;
|
|
134
|
+
caption?: string;
|
|
135
|
+
musicPostId?: string;
|
|
136
|
+
postTime?: string;
|
|
137
|
+
imageUrls: string[];
|
|
138
|
+
strict?: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface GetPostStatsParams {
|
|
141
|
+
postIds?: string[];
|
|
142
|
+
startDate?: string;
|
|
143
|
+
endDate?: string;
|
|
144
|
+
}
|
|
145
|
+
export interface GetPostStatusParams {
|
|
146
|
+
postId: string;
|
|
147
|
+
}
|
|
148
|
+
export interface CreateVideoParams {
|
|
149
|
+
accountId: string;
|
|
150
|
+
caption?: string;
|
|
151
|
+
musicPostId?: string;
|
|
152
|
+
postTime?: string;
|
|
153
|
+
videoUrl: string;
|
|
154
|
+
strict?: boolean;
|
|
155
|
+
}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ugcinc",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript/JavaScript client for the UGC Inc API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build",
|
|
10
|
+
"test": "echo \"No tests specified\" && exit 0"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"ugcinc",
|
|
14
|
+
"api",
|
|
15
|
+
"client",
|
|
16
|
+
"tiktok",
|
|
17
|
+
"automation",
|
|
18
|
+
"social-media",
|
|
19
|
+
"content-management"
|
|
20
|
+
],
|
|
21
|
+
"author": "UGC Inc",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^20.0.0",
|
|
25
|
+
"typescript": "^5.0.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
|