ts-twitch-api 0.1.1 → 0.1.2

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/twitch-api.ts CHANGED
@@ -38,6 +38,8 @@ export type GetUserChatColorParams = ParamsSchema<'get-user-chat-color'>;
38
38
  export type UpdateUserChatColorParams = ParamsSchema<'update-user-chat-color'>;
39
39
  export type CreateClipParams = ParamsSchema<'create-clip'>;
40
40
  export type GetClipsParams = ParamsSchema<'get-clips'>;
41
+ export type DeleteConduitParams = ParamsSchema<'delete-conduit'>;
42
+ export type GetConduitShardsParams = ParamsSchema<'get-conduit-shards'>;
41
43
  export type GetContentClassificationLabelsParams = ParamsSchema<'get-content-classification-labels'>;
42
44
  export type GetDropsEntitlementsParams = ParamsSchema<'get-drops-entitlements'>;
43
45
  export type GetExtensionConfigurationSegmentParams = ParamsSchema<'get-extension-configuration-segment'>;
@@ -171,11 +173,21 @@ export type UpdateChatSettingsBody = Schema<'UpdateChatSettingsBody'>;
171
173
  export type ChatSettingsUpdated = Schema<'ChatSettingsUpdated'>;
172
174
  export type UpdateChatSettingsResponse = Schema<'UpdateChatSettingsResponse'>;
173
175
  export type SendChatAnnouncementBody = Schema<'SendChatAnnouncementBody'>;
176
+ export type SendChatMessageBody = Schema<'SendChatMessageBody'>;
177
+ export type SendChatMessageResponse = Schema<'SendChatMessageResponse'>;
174
178
  export type UserChatColor = Schema<'UserChatColor'>;
175
179
  export type GetUserChatColorResponse = Schema<'GetUserChatColorResponse'>;
176
180
  export type CreateClipResponse = Schema<'CreateClipResponse'>;
177
181
  export type Clip = Schema<'Clip'>;
178
182
  export type GetClipsResponse = Schema<'GetClipsResponse'>;
183
+ export type GetConduitsResponse = Schema<'GetConduitsResponse'>;
184
+ export type CreateConduitsBody = Schema<'CreateConduitsBody'>;
185
+ export type CreateConduitsResponse = Schema<'CreateConduitsResponse'>;
186
+ export type UpdateConduitsBody = Schema<'UpdateConduitsBody'>;
187
+ export type UpdateConduitsResponse = Schema<'UpdateConduitsResponse'>;
188
+ export type GetConduitShardsResponse = Schema<'GetConduitShardsResponse'>;
189
+ export type UpdateConduitShardsBody = Schema<'UpdateConduitShardsBody'>;
190
+ export type UpdateConduitShardsResponse = Schema<'UpdateConduitShardsResponse'>;
179
191
  export type ContentClassificationLabel = Schema<'ContentClassificationLabel'>;
180
192
  export type GetContentClassificationLabelsResponse = Schema<'GetContentClassificationLabelsResponse'>;
181
193
  export type DropsEntitlement = Schema<'DropsEntitlement'>;
@@ -550,7 +562,7 @@ export class TwitchApi {
550
562
  *
551
563
  * _200 OK_
552
564
  *
553
- * Successfully retrieved the broadcaster’s analytics reports.
565
+ * Successfully retrieved the broadcaster's analytics reports.
554
566
  *
555
567
  * _400 Bad Request_
556
568
  *
@@ -1812,7 +1824,6 @@ export class TwitchApi {
1812
1824
  *
1813
1825
  * * The `message` field in the request's body is required.
1814
1826
  * * The `message` field may not contain an empty string.
1815
- * * The `message` field may not contain an empty string.
1816
1827
  * * The string in the `message` field failed review.
1817
1828
  * * The specified color is not valid.
1818
1829
  *
@@ -1899,6 +1910,60 @@ export class TwitchApi {
1899
1910
  params,
1900
1911
  request,
1901
1912
  }),
1913
+ /**
1914
+ * NEW Sends a message to the broadcaster’s chat room.
1915
+ *
1916
+ * __Authorization:__
1917
+ *
1918
+ * Requires an [app access token](https://dev.twitch.tv/docs/authentication#app-access-tokens) or [user access token](https://dev.twitch.tv/docs/authentication#user-access-tokens) that includes the `user:write:chat` scope. If app access token used, then additionally requires `user:bot` scope from chatting user, and either `channel:bot` scope from broadcaster or moderator status.
1919
+ *
1920
+ * __URL:__
1921
+ *
1922
+ * `POST https://api.twitch.tv/helix/chat/messages`
1923
+ *
1924
+ * __Response Codes:__
1925
+ *
1926
+ * _200 OK_
1927
+ *
1928
+ * Successfully sent the specified broadcaster a message.
1929
+ *
1930
+ * _400 Bad Request_
1931
+ *
1932
+ * * The _broadcaster\_id_ query parameter is required.
1933
+ * * The ID in the _broadcaster\_id_ query parameter is not valid.
1934
+ * * The _sender\_id_ query parameter is required.
1935
+ * * The ID in the _sender\_id_ query parameter is not valid.
1936
+ * * The _text_ query parameter is required.
1937
+ * * The ID in the _reply\_parent\_message\_id_ query parameter is not valid.
1938
+ *
1939
+ * _401 Unauthorized_
1940
+ *
1941
+ * * The ID in the user\_id query parameter must match the user ID in the access token.
1942
+ * * The Authorization header is required and must contain a user access token.
1943
+ * * The user access token must include the user:write:chat scope.
1944
+ * * The access token is not valid.
1945
+ * * The client ID specified in the Client-Id header does not match the client ID specified in the access token.
1946
+ *
1947
+ * _403 Forbidden_
1948
+ *
1949
+ * The sender is not permitted to send chat messages to the broadcaster’s chat room.
1950
+ *
1951
+ * _422 Unprocessable Entity_
1952
+ *
1953
+ * The message is too large.
1954
+ *
1955
+ * @see https://dev.twitch.tv/docs/api/reference#send-chat-message
1956
+ */
1957
+ sendChatMessage: async (
1958
+ body: SendChatMessageBody,
1959
+ ...request: CallApiOptions['request']
1960
+ ) =>
1961
+ this.callApi<SendChatMessageResponse, 200, 400 | 401 | 403 | 422>({
1962
+ path: '/chat/messages',
1963
+ method: 'POST',
1964
+ body,
1965
+ request,
1966
+ }),
1902
1967
  /**
1903
1968
  * Gets the color used for the user’s name in chat.
1904
1969
  *
@@ -1952,7 +2017,7 @@ export class TwitchApi {
1952
2017
  *
1953
2018
  * _204 No Content_
1954
2019
  *
1955
- * Successfully updated the user’s chat color.
2020
+ * Successfully updated the user's chat color.
1956
2021
  *
1957
2022
  * _400 Bad Request_
1958
2023
  *
@@ -2087,6 +2152,247 @@ export class TwitchApi {
2087
2152
  request,
2088
2153
  }),
2089
2154
  };
2155
+ conduits = {
2156
+ /**
2157
+ * NEW Gets the [conduits](https://dev.twitch.tv/docs/eventsub/handling-conduit-events) for a client ID.
2158
+ *
2159
+ * __Authorization:__
2160
+ *
2161
+ * Requires an [app access token](https://dev.twitch.tv/docs/authentication#app-access-tokens).
2162
+ *
2163
+ * __URL:__
2164
+ *
2165
+ * `GET https://api.twitch.tv/helix/eventsub/conduits`
2166
+ *
2167
+ * __Response Codes:__
2168
+ *
2169
+ * _200 OK_
2170
+ *
2171
+ * Successfully retrieved conduits.
2172
+ *
2173
+ * _401 Unauthorized_
2174
+ *
2175
+ * Authorization header required with an app access token.
2176
+ *
2177
+ * @see https://dev.twitch.tv/docs/api/reference#get-conduits
2178
+ */
2179
+ getConduits: async (...request: CallApiOptions['request']) =>
2180
+ this.callApi<GetConduitsResponse, 200, 401>({
2181
+ path: '/eventsub/conduits',
2182
+ request,
2183
+ }),
2184
+ /**
2185
+ * NEW Creates a new [conduit](https://dev.twitch.tv/docs/eventsub/handling-conduit-events).
2186
+ *
2187
+ * __Authorization:__
2188
+ *
2189
+ * Requires an [app access token](https://dev.twitch.tv/docs/authentication#app-access-tokens).
2190
+ *
2191
+ * __URL:__
2192
+ *
2193
+ * `POST https://api.twitch.tv/helix/eventsub/conduits`
2194
+ *
2195
+ * __Response Codes:__
2196
+ *
2197
+ * _200 OK_
2198
+ *
2199
+ * Conduit created.
2200
+ *
2201
+ * _400 Bad Request_
2202
+ *
2203
+ * Invalid shard count.
2204
+ *
2205
+ * _401 Unauthorized_
2206
+ *
2207
+ * Authorization header required with an app access token.
2208
+ *
2209
+ * _429 Too Many Requests_
2210
+ *
2211
+ * Conduit limit reached.
2212
+ *
2213
+ * @see https://dev.twitch.tv/docs/api/reference#create-conduits
2214
+ */
2215
+ createConduits: async (
2216
+ body: CreateConduitsBody,
2217
+ ...request: CallApiOptions['request']
2218
+ ) =>
2219
+ this.callApi<CreateConduitsResponse, 200, 400 | 401 | 429>({
2220
+ path: '/eventsub/conduits',
2221
+ method: 'POST',
2222
+ body,
2223
+ request,
2224
+ }),
2225
+ /**
2226
+ * NEW Updates a [conduit’s](https://dev.twitch.tv/docs/eventsub/handling-conduit-events) shard count. To delete shards, update the count to a lower number, and the shards above the count will be deleted. For example, if the existing shard count is 100, by resetting shard count to 50, shards 50-99 are disabled.
2227
+ *
2228
+ * __Authorization:__
2229
+ *
2230
+ * Requires an [app access token](https://dev.twitch.tv/docs/authentication#app-access-tokens).
2231
+ *
2232
+ * __URL:__
2233
+ *
2234
+ * `PATCH https://api.twitch.tv/helix/eventsub/conduits`
2235
+ *
2236
+ * __Response Codes:__
2237
+ *
2238
+ * _200 OK_
2239
+ *
2240
+ * Conduit updated.
2241
+ *
2242
+ * _400 Bad Request_
2243
+ *
2244
+ * * Invalid shard count
2245
+ * * The id query parameter is required.
2246
+ *
2247
+ * _401 Unauthorized_
2248
+ *
2249
+ * Authorization header required with an app access token.
2250
+ *
2251
+ * _404 Not Found_
2252
+ *
2253
+ * * Conduit not found.
2254
+ * * Conduit’s owner must match the client ID in the access token.
2255
+ *
2256
+ * @see https://dev.twitch.tv/docs/api/reference#update-conduits
2257
+ */
2258
+ updateConduits: async (
2259
+ body: UpdateConduitsBody,
2260
+ ...request: CallApiOptions['request']
2261
+ ) =>
2262
+ this.callApi<UpdateConduitsResponse, 200, 400 | 401 | 404>({
2263
+ path: '/eventsub/conduits',
2264
+ method: 'PATCH',
2265
+ body,
2266
+ request,
2267
+ }),
2268
+ /**
2269
+ * NEW Deletes a specified [conduit](https://dev.twitch.tv/docs/eventsub/handling-conduit-events/). Note that it may take some time for Eventsub subscriptions on a deleted [conduit](https://dev.twitch.tv/docs/eventsub/handling-conduit-events) to show as disabled when calling [Get Eventsub Subscriptions](https://dev.twitch.tv/docs/api/reference/#get-eventsub-subscriptions).
2270
+ *
2271
+ * __Authorization:__
2272
+ *
2273
+ * Requires an [app access token](https://dev.twitch.tv/docs/authentication#app-access-tokens).
2274
+ *
2275
+ * __URL:__
2276
+ *
2277
+ * `DELETE https://api.twitch.tv/helix/eventsub/conduits`
2278
+ *
2279
+ * __Response Codes:__
2280
+ *
2281
+ * _204 No Content_
2282
+ *
2283
+ * Successfully deleted the conduit.
2284
+ *
2285
+ * _400 Bad Request_
2286
+ *
2287
+ * The id query parameter is required.
2288
+ *
2289
+ * _401 Unauthorized_
2290
+ *
2291
+ * Authorization header required with an app access token.
2292
+ *
2293
+ * _404 Not Found_
2294
+ *
2295
+ * * Conduit not found.
2296
+ * * Conduit’s owner must match the client ID in the access token.
2297
+ *
2298
+ * @see https://dev.twitch.tv/docs/api/reference#delete-conduit
2299
+ */
2300
+ deleteConduit: async (
2301
+ params: DeleteConduitParams,
2302
+ ...request: CallApiOptions['request']
2303
+ ) =>
2304
+ this.callApi<void, 204, 400 | 401 | 404>({
2305
+ path: '/eventsub/conduits',
2306
+ method: 'DELETE',
2307
+ params,
2308
+ request,
2309
+ }),
2310
+ /**
2311
+ * NEW Gets a lists of all shards for a [conduit](https://dev.twitch.tv/docs/eventsub/handling-conduit-events).
2312
+ *
2313
+ * __Authorization:__
2314
+ *
2315
+ * Requires an [app access token](https://dev.twitch.tv/docs/authentication#app-access-tokens).
2316
+ *
2317
+ * __URL:__
2318
+ *
2319
+ * `GET https://api.twitch.tv/helix/eventsub/conduits/shards`
2320
+ *
2321
+ * __Response Codes:__
2322
+ *
2323
+ * _200 OK_
2324
+ *
2325
+ * Successfully retrieved shards.
2326
+ *
2327
+ * _400 Bad Request_
2328
+ *
2329
+ * The id query parameter is required.
2330
+ *
2331
+ * _401 Unauthorized_
2332
+ *
2333
+ * Authorization header required with an app access token.
2334
+ *
2335
+ * _404 Not Found_
2336
+ *
2337
+ * * Conduit not found.
2338
+ * * Conduit’s owner must match the client ID in the access token.
2339
+ *
2340
+ * @see https://dev.twitch.tv/docs/api/reference#get-conduit-shards
2341
+ */
2342
+ getConduitShards: async (
2343
+ params: GetConduitShardsParams,
2344
+ ...request: CallApiOptions['request']
2345
+ ) =>
2346
+ this.callApi<GetConduitShardsResponse, 200, 400 | 401 | 404>({
2347
+ path: '/eventsub/conduits/shards',
2348
+ params,
2349
+ request,
2350
+ }),
2351
+ /**
2352
+ * NEW Updates shard(s) for a [conduit](https://dev.twitch.tv/docs/eventsub/handling-conduit-events).
2353
+ *
2354
+ * **NOTE:** Shard IDs are indexed starting at 0, so a conduit with a `shard_count` of 5 will have shards with IDs 0 through 4.
2355
+ *
2356
+ * __Authorization:__
2357
+ *
2358
+ * Requires an [app access token](https://dev.twitch.tv/docs/authentication#app-access-tokens).
2359
+ *
2360
+ * __URL:__
2361
+ *
2362
+ * `PATCH https://api.twitch.tv/helix/eventsub/conduits/shards`
2363
+ *
2364
+ * __Response Codes:__
2365
+ *
2366
+ * _202 Accepted_
2367
+ *
2368
+ * Successfully retrieved shards.
2369
+ *
2370
+ * _400 Bad Request_
2371
+ *
2372
+ * The id query parameter is required.
2373
+ *
2374
+ * _401 Unauthorized_
2375
+ *
2376
+ * Authorization header required with an app access token.
2377
+ *
2378
+ * _404 Not Found_
2379
+ *
2380
+ * * Conduit not found.
2381
+ * * Conduit’s owner must match the client ID in the access token.
2382
+ *
2383
+ * @see https://dev.twitch.tv/docs/api/reference#update-conduit-shards
2384
+ */
2385
+ updateConduitShards: async (
2386
+ body: UpdateConduitShardsBody,
2387
+ ...request: CallApiOptions['request']
2388
+ ) =>
2389
+ this.callApi<UpdateConduitShardsResponse, 202, 400 | 401 | 404>({
2390
+ path: '/eventsub/conduits/shards',
2391
+ method: 'PATCH',
2392
+ body,
2393
+ request,
2394
+ }),
2395
+ };
2090
2396
  ccls = {
2091
2397
  /**
2092
2398
  * Gets information about Twitch content classification labels.
@@ -2762,7 +3068,7 @@ export class TwitchApi {
2762
3068
  * * The value in the `sku` field is not valid. The SKU may contain only alphanumeric characters, dashes (-), underscores (\_), and periods (.).
2763
3069
  * * The `cost` object's `amount` field is required.
2764
3070
  * * The value in the `cost` object's `amount` field is not valid.
2765
- * * The cost object's `type` field is required.
3071
+ * * The `cost` object's `type` field is required.
2766
3072
  * * The value in the `cost` object's `type` field is not valid.
2767
3073
  * * The `display_name` field is required.
2768
3074
  * * The ID in the Client-Id header must belong to the extension.
@@ -2796,6 +3102,8 @@ export class TwitchApi {
2796
3102
  *
2797
3103
  * If you use [WebSockets to receive events](https://dev.twitch.tv/docs/eventsub/handling-websocket-events), the request must specify a user access token. The request will fail if you use an app access token. If the subscription type requires user authorization, the token must include the required scope. However, if the subscription type doesn’t include user authorization, the token may include any scopes or no scopes.
2798
3104
  *
3105
+ * If you use [Conduits](https://dev.twitch.tv/docs/eventsub/handling-conduit-events) to receive events, the request must specify an app access token. The request will fail if you use a user access token.
3106
+ *
2799
3107
  * __URL:__
2800
3108
  *
2801
3109
  * `POST https://api.twitch.tv/helix/eventsub/subscriptions`
@@ -2818,6 +3126,7 @@ export class TwitchApi {
2818
3126
  * * The `callback` field is required if you specify the webhook transport method.
2819
3127
  * * The `session_id` field is required if you specify the WebSocket transport method.
2820
3128
  * * The combination of subscription type and version is not valid.
3129
+ * * The `conduit_id` field is required if you specify the Conduit transport method.
2821
3130
  *
2822
3131
  * _401 Unauthorized_
2823
3132
  *
@@ -2828,15 +3137,15 @@ export class TwitchApi {
2828
3137
  *
2829
3138
  * _403 Forbidden_
2830
3139
  *
2831
- * * The access token is missing the required scopes.
3140
+ * The access token is missing the required scopes.
2832
3141
  *
2833
3142
  * _409 Conflict_
2834
3143
  *
2835
- * * A subscription already exists for the specified event type and condition combination.
3144
+ * A subscription already exists for the specified event type and `condition` combination.
2836
3145
  *
2837
3146
  * _429 Too Many Requests_
2838
3147
  *
2839
- * * The request exceeds the number of subscriptions that you may create with the same combination of `type` and `condition` values.
3148
+ * The request exceeds the number of subscriptions that you may create with the same combination of `type` and `condition` values.
2840
3149
  *
2841
3150
  * @see https://dev.twitch.tv/docs/api/reference#create-eventsub-subscription
2842
3151
  */