tentacle-sdk 0.0.1
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/LICENSE +21 -0
- package/README.md +169 -0
- package/dist/index.cjs +889 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1562 -0
- package/dist/index.d.ts +1562 -0
- package/dist/index.js +884 -0
- package/dist/index.js.map +1 -0
- package/docs/api/classes/DeviceAuthFlow.md +107 -0
- package/docs/api/classes/FileCredentialStore.md +95 -0
- package/docs/api/classes/TentacleClient.md +118 -0
- package/docs/api/classes/TentacleError.md +69 -0
- package/docs/api/index.md +117 -0
- package/docs/api/interfaces/AppJson.md +20 -0
- package/docs/api/interfaces/ChatMessageEmoji.md +16 -0
- package/docs/api/interfaces/ChatMessageEmote.md +16 -0
- package/docs/api/interfaces/ChatMessagePosition.md +14 -0
- package/docs/api/interfaces/CommonChatMessage.md +27 -0
- package/docs/api/interfaces/CommonEventJson.md +32 -0
- package/docs/api/interfaces/CredentialStore.md +55 -0
- package/docs/api/interfaces/DeviceAuthInitResult.md +17 -0
- package/docs/api/interfaces/DeviceAuthOptions.md +18 -0
- package/docs/api/interfaces/DeviceAuthPollResult.md +14 -0
- package/docs/api/interfaces/DonationUnlock.md +16 -0
- package/docs/api/interfaces/FileCredentialStoreOptions.md +13 -0
- package/docs/api/interfaces/GiftedSubUnlock.md +15 -0
- package/docs/api/interfaces/KickBadge.md +15 -0
- package/docs/api/interfaces/KickChatMessageJson.md +35 -0
- package/docs/api/interfaces/KickEventJson_ChannelFollow.md +25 -0
- package/docs/api/interfaces/KickEventJson_ChannelSubscriptionGifts.md +25 -0
- package/docs/api/interfaces/KickEventJson_ChannelSubscriptionNew.md +25 -0
- package/docs/api/interfaces/KickEventJson_ChannelSubscriptionRenewal.md +25 -0
- package/docs/api/interfaces/KickEventJson_LivestreamStatusUpdated.md +24 -0
- package/docs/api/interfaces/RealtimeEvent_StreamChatMessage.md +14 -0
- package/docs/api/interfaces/RealtimeEvent_StreamEvent.md +14 -0
- package/docs/api/interfaces/RealtimeEvent_StreamViewerActivity.md +14 -0
- package/docs/api/interfaces/RealtimeSubscribeOptions.md +16 -0
- package/docs/api/interfaces/StreamViewerActivityJson.md +16 -0
- package/docs/api/interfaces/SubUnlock.md +15 -0
- package/docs/api/interfaces/SubathonStats_Donations.md +23 -0
- package/docs/api/interfaces/SubathonStats_GiftedSubscriptions.md +22 -0
- package/docs/api/interfaces/SubathonStats_Subscriptions.md +20 -0
- package/docs/api/interfaces/TentacleClientConfig.md +14 -0
- package/docs/api/interfaces/TentacleClientCreateOptions.md +15 -0
- package/docs/api/interfaces/TwitchChatMessageJson.md +41 -0
- package/docs/api/interfaces/TwitchEventJson_Cheer.md +29 -0
- package/docs/api/interfaces/TwitchEventJson_Follow.md +27 -0
- package/docs/api/interfaces/TwitchEventJson_Raid.md +27 -0
- package/docs/api/interfaces/TwitchEventJson_RedemptionAdd.md +34 -0
- package/docs/api/interfaces/TwitchEventJson_StreamOnline.md +26 -0
- package/docs/api/interfaces/TwitchEventJson_Subscription.md +28 -0
- package/docs/api/interfaces/TwitchEventJson_SubscriptionGift.md +30 -0
- package/docs/api/interfaces/TwitchUserInfo.md +24 -0
- package/docs/api/interfaces/ViewerActionJson.md +18 -0
- package/docs/api/interfaces/ViewerJson.md +23 -0
- package/docs/api/interfaces/ViewerKickJson.md +25 -0
- package/docs/api/interfaces/ViewerMiniJson.md +21 -0
- package/docs/api/interfaces/ViewerPropertyJsonBase.md +22 -0
- package/docs/api/interfaces/ViewerPropertyJson_Bool.md +22 -0
- package/docs/api/interfaces/ViewerPropertyJson_Number.md +22 -0
- package/docs/api/interfaces/ViewerPropertyJson_String.md +22 -0
- package/docs/api/interfaces/ViewerTwitchJson.md +24 -0
- package/docs/api/interfaces/ViewersByPropertyOutput.md +17 -0
- package/docs/api/type-aliases/DateIsoString.md +9 -0
- package/docs/api/type-aliases/KickEventJson.md +9 -0
- package/docs/api/type-aliases/OrderDirection.md +9 -0
- package/docs/api/type-aliases/RealtimeEvent.md +36 -0
- package/docs/api/type-aliases/StreamChatMessageJson.md +9 -0
- package/docs/api/type-aliases/StreamEventJson.md +9 -0
- package/docs/api/type-aliases/StreamPlatform.md +9 -0
- package/docs/api/type-aliases/TwitchEventJson.md +9 -0
- package/docs/api/type-aliases/TwitchEventType.md +9 -0
- package/docs/api/type-aliases/UnsubscribeFunction.md +22 -0
- package/docs/api/type-aliases/ViewerPropertyJson.md +9 -0
- package/docs/api/type-aliases/ViewerPropertyType.md +9 -0
- package/docs/overview.md +160 -0
- package/package.json +54 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[**tentacle-sdk**](../index.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Type Alias: UnsubscribeFunction()
|
|
6
|
+
|
|
7
|
+
> **UnsubscribeFunction** = () => `void`
|
|
8
|
+
|
|
9
|
+
Function to unsubscribe from realtime events.
|
|
10
|
+
Call this to close the SSE connection and stop receiving events.
|
|
11
|
+
|
|
12
|
+
## Returns
|
|
13
|
+
|
|
14
|
+
`void`
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
const unsubscribe = client.realtime.subscribe({ onEvent: ... })
|
|
20
|
+
// Later, when done:
|
|
21
|
+
unsubscribe()
|
|
22
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[**tentacle-sdk**](../index.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Type Alias: ViewerPropertyJson
|
|
6
|
+
|
|
7
|
+
> **ViewerPropertyJson** = [`ViewerPropertyJson_Number`](../interfaces/ViewerPropertyJson_Number.md) \| [`ViewerPropertyJson_Bool`](../interfaces/ViewerPropertyJson_Bool.md) \| [`ViewerPropertyJson_String`](../interfaces/ViewerPropertyJson_String.md)
|
|
8
|
+
|
|
9
|
+
Viewer property.
|
package/docs/overview.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Tentacle SDK Documentation
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the Tentacle streaming platform API. Provides type-safe access to REST endpoints and realtime events from Twitch and Kick.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install tentacle-sdk
|
|
9
|
+
# or
|
|
10
|
+
pnpm add tentacle-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { TentacleClient } from "tentacle-sdk"
|
|
17
|
+
|
|
18
|
+
const client = new TentacleClient({
|
|
19
|
+
baseUrl: "https://api.tentacle.live",
|
|
20
|
+
accessToken: "your-access-token",
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// Subscribe to realtime events (Twitch + Kick)
|
|
24
|
+
const unsubscribe = client.realtime.subscribe({
|
|
25
|
+
onEvent: (event) => {
|
|
26
|
+
if (event.kind === "StreamChatMessage") {
|
|
27
|
+
console.log(`Chat: ${event.payload.$text}`)
|
|
28
|
+
} else if (event.kind === "StreamEvent") {
|
|
29
|
+
console.log(`Event: ${event.payload.$type}`)
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Get recent chat messages
|
|
35
|
+
const messages = await client.stream.getChatMessages({ take: 10 })
|
|
36
|
+
|
|
37
|
+
// When done, unsubscribe
|
|
38
|
+
unsubscribe()
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API Reference
|
|
42
|
+
|
|
43
|
+
Full API documentation is auto-generated from JSDoc comments in the source code.
|
|
44
|
+
|
|
45
|
+
- [API Reference Index](./api/index.md) - Complete API documentation
|
|
46
|
+
- [TentacleClient](./api/classes/TentacleClient.md) - Main client class
|
|
47
|
+
- [TentacleError](./api/classes/TentacleError.md) - Error handling
|
|
48
|
+
- [RealtimeEvent](./api/type-aliases/RealtimeEvent.md) - Realtime event types
|
|
49
|
+
|
|
50
|
+
## SDK Structure
|
|
51
|
+
|
|
52
|
+
### TentacleClient
|
|
53
|
+
|
|
54
|
+
The main entry point. Provides access to all API namespaces:
|
|
55
|
+
|
|
56
|
+
| Namespace | Description |
|
|
57
|
+
|-----------|-------------|
|
|
58
|
+
| `client.realtime` | Subscribe to live Twitch/Kick events via SSE |
|
|
59
|
+
| `client.account` | Manage user accounts |
|
|
60
|
+
| `client.apps` | Manage apps and viewer properties |
|
|
61
|
+
| `client.auth` | Authentication and access tokens |
|
|
62
|
+
| `client.customEvents` | Manage custom event triggers |
|
|
63
|
+
| `client.dashboard` | Manage dashboards |
|
|
64
|
+
| `client.settings` | Manage user settings |
|
|
65
|
+
| `client.stream` | Access chat messages and events history |
|
|
66
|
+
| `client.subathonStats` | Access subathon statistics |
|
|
67
|
+
| `client.viewer` | Access viewer data |
|
|
68
|
+
|
|
69
|
+
### Realtime Events
|
|
70
|
+
|
|
71
|
+
The SDK uses Server-Sent Events (SSE) for realtime updates. Three event types are supported:
|
|
72
|
+
|
|
73
|
+
| Event Kind | Description |
|
|
74
|
+
|------------|-------------|
|
|
75
|
+
| `StreamChatMessage` | Chat messages from Twitch or Kick |
|
|
76
|
+
| `StreamEvent` | Stream events (follows, subs, raids, cheers, etc.) |
|
|
77
|
+
| `StreamViewerActivity` | Viewer activity updates |
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
client.realtime.subscribe({
|
|
81
|
+
onEvent: (event) => {
|
|
82
|
+
switch (event.kind) {
|
|
83
|
+
case "StreamChatMessage":
|
|
84
|
+
// event.payload is TwitchChatMessageJson | KickChatMessageJson
|
|
85
|
+
console.log(`[${event.payload.$platform}] ${event.payload.$text}`)
|
|
86
|
+
break
|
|
87
|
+
|
|
88
|
+
case "StreamEvent":
|
|
89
|
+
// event.payload is TwitchEventJson | KickEventJson
|
|
90
|
+
if (event.payload.$platform === "twitch") {
|
|
91
|
+
switch (event.payload.$type) {
|
|
92
|
+
case "channel.follow":
|
|
93
|
+
console.log(`New follower: ${event.payload.userDisplayName}`)
|
|
94
|
+
break
|
|
95
|
+
case "channel.subscribe":
|
|
96
|
+
console.log(`New sub: ${event.payload.userDisplayName}`)
|
|
97
|
+
break
|
|
98
|
+
case "channel.raid":
|
|
99
|
+
console.log(`Raid from ${event.payload.fromBroadcasterUserName}`)
|
|
100
|
+
break
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
break
|
|
104
|
+
|
|
105
|
+
case "StreamViewerActivity":
|
|
106
|
+
console.log(`Viewer ${event.payload.viewerId} active`)
|
|
107
|
+
break
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
onError: (error) => console.error("Connection error:", error),
|
|
111
|
+
onOpen: () => console.log("Connected!"),
|
|
112
|
+
onClose: () => console.log("Disconnected"),
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Error Handling
|
|
117
|
+
|
|
118
|
+
API errors throw `TentacleError` with HTTP status and optional error code:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { TentacleError } from "tentacle-sdk"
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
await client.settings.get()
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (error instanceof TentacleError) {
|
|
127
|
+
console.error(`Error ${error.status}: ${error.message}`)
|
|
128
|
+
if (error.code) {
|
|
129
|
+
console.error(`Code: ${error.code}`)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Authentication
|
|
136
|
+
|
|
137
|
+
Most endpoints require an access token. You can obtain one from:
|
|
138
|
+
|
|
139
|
+
1. **Tentacle Dashboard** - For user tokens
|
|
140
|
+
2. **Auth API** - For programmatic access
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
// Get or create an access token
|
|
144
|
+
const token = await client.auth.getOrCreateAccessToken()
|
|
145
|
+
console.log(`Token: ${token.jwt}`)
|
|
146
|
+
|
|
147
|
+
// Check token validity
|
|
148
|
+
const { isValid } = await client.auth.getAccessTokenStatus({ jwt: token.jwt })
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Platform Support
|
|
152
|
+
|
|
153
|
+
The SDK normalizes data from both Twitch and Kick. All messages and events include:
|
|
154
|
+
|
|
155
|
+
- `$platform`: `"twitch"` or `"kick"`
|
|
156
|
+
- `$type`: Platform-specific event type
|
|
157
|
+
- `$viewerId`: Unified viewer ID (when available)
|
|
158
|
+
- `$createdAt`: ISO 8601 timestamp
|
|
159
|
+
|
|
160
|
+
This allows you to handle both platforms with unified logic while still accessing platform-specific fields when needed.
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tentacle-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "SDK for the Tentacle platform",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18.0.0"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"docs",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"tentacle",
|
|
29
|
+
"streaming",
|
|
30
|
+
"twitch",
|
|
31
|
+
"kick",
|
|
32
|
+
"api",
|
|
33
|
+
"sdk",
|
|
34
|
+
"typescript",
|
|
35
|
+
"realtime",
|
|
36
|
+
"sse"
|
|
37
|
+
],
|
|
38
|
+
"homepage": "https://www.tentacle.live",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"prepublishOnly": "just build"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@tentacle/common": "workspace:*",
|
|
44
|
+
"@types/node": "catalog:",
|
|
45
|
+
"dotenv-cli": "catalog:",
|
|
46
|
+
"tsup": "~8.5.1",
|
|
47
|
+
"tsx": "catalog:",
|
|
48
|
+
"typedoc": "catalog:",
|
|
49
|
+
"typedoc-plugin-markdown": "catalog:",
|
|
50
|
+
"typescript": "catalog:",
|
|
51
|
+
"vitest": "catalog:"
|
|
52
|
+
},
|
|
53
|
+
"packageManager": "pnpm@10.12.1"
|
|
54
|
+
}
|