polyv-live-api-sdk 1.0.5 → 1.0.8

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 ADDED
@@ -0,0 +1,186 @@
1
+ # PolyV Live API SDK
2
+
3
+ TypeScript/Node.js SDK for PolyV Live Streaming API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install polyv-live-api-sdk
9
+ # or
10
+ pnpm add polyv-live-api-sdk
11
+ # or
12
+ yarn add polyv-live-api-sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { PolyVClient } from 'polyv-live-api-sdk';
19
+
20
+ const client = new PolyVClient({
21
+ appId: 'your-app-id',
22
+ appSecret: 'your-app-secret'
23
+ });
24
+
25
+ // List channels
26
+ const channels = await client.channel.listChannels({ pageNumber: 1, pageSize: 10 });
27
+
28
+ // Get channel details
29
+ const channel = await client.channel.getChannel({ channelId: 'your-channel-id' });
30
+ ```
31
+
32
+ ## Features
33
+
34
+ - Full TypeScript support with type definitions
35
+ - Automatic API signature generation
36
+ - Promise-based API
37
+ - Comprehensive error handling
38
+ - Support for both V3 and V4 APIs
39
+
40
+ ## Services
41
+
42
+ ### V3 Services
43
+
44
+ | Service | Description |
45
+ |---------|-------------|
46
+ | `channel` | Channel management (CRUD, settings, streams) |
47
+ | `chat` | Chat operations (messages, bans, kicks) |
48
+ | `account` | Account operations |
49
+ | `group` | Group management |
50
+ | `platform` | Platform operations |
51
+ | `finance` | Financial operations |
52
+ | `web` | Web settings |
53
+ | `player` | Player configuration |
54
+ | `liveInteraction` | Live interactions (check-in, lottery, Q&A) |
55
+ | `statistics` | Statistics and reports |
56
+
57
+ ### V4 Services
58
+
59
+ | Service | Description |
60
+ |---------|-------------|
61
+ | `v4Platform` | Coupon management |
62
+ | `v4Channel` | V4 channel APIs |
63
+ | `v4Chat` | V4 chat APIs |
64
+ | `v4User` | User management |
65
+ | `v4Group` | V4 group APIs |
66
+ | `v4AI` | AI features |
67
+ | `v4Robot` | Robot features |
68
+ | `v4Material` | Materials management |
69
+ | `v4Statistics` | V4 statistics |
70
+ | `v4WebApp` | WebApp settings |
71
+ | `v4Global` | Global settings |
72
+
73
+ ## Usage Examples
74
+
75
+ ### Channel Management
76
+
77
+ ```typescript
78
+ // Create a channel
79
+ const newChannel = await client.channel.createChannel({
80
+ name: 'My Live Channel',
81
+ channelPass: 'password123'
82
+ });
83
+
84
+ // List channels with pagination
85
+ const result = await client.channel.listChannels({
86
+ pageNumber: 1,
87
+ pageSize: 20
88
+ });
89
+
90
+ // Update channel
91
+ await client.channel.updateChannel({
92
+ channelId: 'xxx',
93
+ name: 'Updated Name'
94
+ });
95
+ ```
96
+
97
+ ### Coupon Operations (V4)
98
+
99
+ ```typescript
100
+ // Create a coupon
101
+ const couponId = await client.v4Platform.createCoupon({
102
+ name: 'Discount Coupon',
103
+ discount: 100,
104
+ total: 1000
105
+ });
106
+
107
+ // Search coupons
108
+ const coupons = await client.v4Platform.searchCoupons({
109
+ pageNumber: 1,
110
+ pageSize: 10
111
+ });
112
+ ```
113
+
114
+ ### Product Management
115
+
116
+ ```typescript
117
+ // Get product list
118
+ const products = await client.channel.getProductList({
119
+ channelId: 'your-channel-id'
120
+ });
121
+
122
+ // Add product
123
+ const product = await client.channel.addProduct({
124
+ channelId: 'your-channel-id',
125
+ name: 'Product Name',
126
+ price: '99.00'
127
+ });
128
+ ```
129
+
130
+ ### Statistics
131
+
132
+ ```typescript
133
+ // Get channel statistics
134
+ const stats = await client.statistics.getChannelStats({
135
+ channelId: 'your-channel-id',
136
+ startDate: '2024-01-01',
137
+ endDate: '2024-01-31'
138
+ });
139
+ ```
140
+
141
+ ### Error Handling
142
+
143
+ ```typescript
144
+ import { PolyVAPIError, PolyVErrorCode } from 'polyv-live-api-sdk';
145
+
146
+ try {
147
+ await client.channel.getChannel({ channelId: 'invalid-id' });
148
+ } catch (error) {
149
+ if (error instanceof PolyVAPIError) {
150
+ console.log('Error code:', error.code);
151
+ console.log('Error message:', error.message);
152
+ }
153
+ }
154
+ ```
155
+
156
+ ## Pagination Utilities
157
+
158
+ ```typescript
159
+ import { paginate, collectAll } from 'polyv-live-api-sdk';
160
+
161
+ // Auto-paginate through all results
162
+ const allChannels = await collectAll(
163
+ (page) => client.channel.listChannels({ pageNumber: page, pageSize: 100 }),
164
+ (response) => response.contents
165
+ );
166
+ ```
167
+
168
+ ## Configuration Options
169
+
170
+ ```typescript
171
+ const client = new PolyVClient({
172
+ appId: 'your-app-id',
173
+ appSecret: 'your-app-secret',
174
+ userId: 'your-user-id', // Optional
175
+ timeout: 30000, // Request timeout in ms (default: 30000)
176
+ baseURL: 'https://api.polyv.net' // Custom base URL (optional)
177
+ });
178
+ ```
179
+
180
+ ## Requirements
181
+
182
+ - Node.js >= 18.0.0
183
+
184
+ ## License
185
+
186
+ MIT
package/dist/index.cjs CHANGED
@@ -5292,6 +5292,9 @@ var LiveInteractionService = class {
5292
5292
  * ```
5293
5293
  */
5294
5294
  async getCheckinList(params) {
5295
+ if (!params.channelId) {
5296
+ throw new Error("channelId is required");
5297
+ }
5295
5298
  const response = await this.client.httpClient.get(
5296
5299
  "/live/v2/chat/getCheckinList",
5297
5300
  { params }