@toktikhq/sdk-js 0.2.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/LICENSE +21 -0
- package/README.md +145 -0
- package/dist/http.js +117 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +1754 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/realtime.js +197 -0
- package/dist/realtime.js.map +1 -0
- package/dist/resources.js +208 -0
- package/dist/resources.js.map +1 -0
- package/package.json +45 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { HttpTransport } from "./http.js";
|
|
2
|
+
import { AccountResource, ContentResource, CreatorsResource, ExportsResource, GiftersResource, LiveResource, RankingsResource, TrendsResource } from "./resources.js";
|
|
3
|
+
import { RealtimeStream } from "./realtime.js";
|
|
4
|
+
export * from "./http.js";
|
|
5
|
+
export * from "./resources.js";
|
|
6
|
+
export * from "./realtime.js";
|
|
7
|
+
/**
|
|
8
|
+
* Typed client for the TokTik Developer API.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const client = new TokTikClient({ apiKey: process.env.TOKTIK_API_KEY! });
|
|
12
|
+
* const board = await client.rankings.official({ board: "hourly", region: "VN" });
|
|
13
|
+
* const stream = await client.live.stream(["@creator"], { onEvent: (e) => console.log(e.event) });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Most data methods return the provenance envelope **unchanged** — `data` alongside the `provenance`
|
|
17
|
+
* block describing how fresh the answer is and how it was obtained. The SDK never strips it, because
|
|
18
|
+
* for observed (rather than officially published) data that context is part of the answer.
|
|
19
|
+
* `exports.*` and `account.usage()` are the documented exceptions: the server does not envelope them.
|
|
20
|
+
*/
|
|
21
|
+
export class TokTikClient {
|
|
22
|
+
http;
|
|
23
|
+
live;
|
|
24
|
+
rankings;
|
|
25
|
+
creators;
|
|
26
|
+
content;
|
|
27
|
+
gifters;
|
|
28
|
+
trends;
|
|
29
|
+
exports;
|
|
30
|
+
account;
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this.http = new HttpTransport(options);
|
|
33
|
+
const live = new LiveResource(this.http);
|
|
34
|
+
this.live = Object.assign(live, {
|
|
35
|
+
stream: async (creatorIds, handlers, streamOptions = {}) => {
|
|
36
|
+
const stream = new RealtimeStream(async () => {
|
|
37
|
+
const minted = await live.streamToken();
|
|
38
|
+
return { token: minted.token, wsUrl: minted.wsUrl };
|
|
39
|
+
}, handlers, streamOptions);
|
|
40
|
+
await stream.connect(creatorIds);
|
|
41
|
+
return stream;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.rankings = new RankingsResource(this.http);
|
|
45
|
+
this.creators = new CreatorsResource(this.http);
|
|
46
|
+
this.content = new ContentResource(this.http);
|
|
47
|
+
this.gifters = new GiftersResource(this.http);
|
|
48
|
+
this.trends = new TrendsResource(this.http);
|
|
49
|
+
this.exports = new ExportsResource(this.http);
|
|
50
|
+
this.account = new AccountResource(this.http);
|
|
51
|
+
}
|
|
52
|
+
// --- Pre-D3.1 surface, kept so existing callers keep compiling. Prefer the namespaces above. ---
|
|
53
|
+
/** @deprecated Use `client.live.listSessions()`. */
|
|
54
|
+
listLiveSessions(options = {}) {
|
|
55
|
+
return this.live.listSessions(options);
|
|
56
|
+
}
|
|
57
|
+
/** @deprecated Use `client.live.getSession()`. */
|
|
58
|
+
getLiveSession(id) {
|
|
59
|
+
return this.live.getSession(id);
|
|
60
|
+
}
|
|
61
|
+
/** @deprecated Use `client.live.creatorPerformance()`. */
|
|
62
|
+
listCreatorPerformance(creatorUniqueId, options = {}) {
|
|
63
|
+
return this.live.creatorPerformance(creatorUniqueId, options);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aA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,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,kGAAkG;IAElG,oDAAoD;IACpD,gBAAgB,CACd,UAA+B,EAAE;QAEjC,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,kDAAkD;IAClD,cAAc,CAAC,EAAU;QACvB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,0DAA0D;IAC1D,sBAAsB,CACpB,eAAuB,EACvB,UAA6B,EAAE;QAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;CACF"}
|
package/dist/realtime.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
function defaultSocketFactory(url, token) {
|
|
2
|
+
const Ctor = globalThis.WebSocket;
|
|
3
|
+
if (!Ctor) {
|
|
4
|
+
throw new Error("No WebSocket implementation is available. Pass RealtimeStreamOptions.socketFactory (e.g. wrapping the `ws` package on Node).");
|
|
5
|
+
}
|
|
6
|
+
// Two values, in this order: the literal marker `bearer` then the token. The gateway selects and
|
|
7
|
+
// echoes `bearer` (never the token), and a WebSocket client that offered subprotocols closes the
|
|
8
|
+
// socket immediately if the server selects none — so the marker MUST be offered verbatim. The
|
|
9
|
+
// combined `bearer.<token>` form the gateway also parses does NOT satisfy that echo, which is how
|
|
10
|
+
// this manifests: the handshake authenticates, then the connection drops within milliseconds.
|
|
11
|
+
return new Ctor(url, ["bearer", token]);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A live subscription set over one WebSocket.
|
|
15
|
+
*
|
|
16
|
+
* Owns three things the caller should not have to: token lifetime (re-minted per connection, so an
|
|
17
|
+
* expiry mid-stream costs a reconnect rather than a dead socket), reconnection with exponential
|
|
18
|
+
* backoff + jitter (a fleet reconnecting in lockstep after a gateway restart is a self-inflicted
|
|
19
|
+
* thundering herd), and subscription resume — the gateway keeps no per-connection memory, so the
|
|
20
|
+
* new socket must re-subscribe or the caller silently receives nothing.
|
|
21
|
+
*/
|
|
22
|
+
export class RealtimeStream {
|
|
23
|
+
mintToken;
|
|
24
|
+
handlers;
|
|
25
|
+
socket = null;
|
|
26
|
+
creators = new Set();
|
|
27
|
+
closed = false;
|
|
28
|
+
attempt = 0;
|
|
29
|
+
/** True only between `onopen` and the socket going away — `send()` before this throws in real runtimes. */
|
|
30
|
+
opened = false;
|
|
31
|
+
reconnectTimer = null;
|
|
32
|
+
/**
|
|
33
|
+
* Bumped by `close()` and by each `open()`. An `open()` that started before the bump finds its
|
|
34
|
+
* generation stale and discards the socket it just created — otherwise `close()` racing an
|
|
35
|
+
* in-flight `open()` leaves a live, unreferenced socket behind (still billed, never closed).
|
|
36
|
+
*/
|
|
37
|
+
generation = 0;
|
|
38
|
+
options;
|
|
39
|
+
constructor(mintToken, handlers, options = {}) {
|
|
40
|
+
this.mintToken = mintToken;
|
|
41
|
+
this.handlers = handlers;
|
|
42
|
+
this.options = {
|
|
43
|
+
maxReconnectAttempts: options.maxReconnectAttempts ?? Infinity,
|
|
44
|
+
baseReconnectDelayMs: options.baseReconnectDelayMs ?? 500,
|
|
45
|
+
maxReconnectDelayMs: options.maxReconnectDelayMs ?? 30_000,
|
|
46
|
+
socketFactory: options.socketFactory ?? defaultSocketFactory,
|
|
47
|
+
setTimeoutImpl: options.setTimeoutImpl ?? ((handler, ms) => setTimeout(handler, ms)),
|
|
48
|
+
clearTimeoutImpl: options.clearTimeoutImpl ?? ((handle) => clearTimeout(handle)),
|
|
49
|
+
random: options.random ?? Math.random
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Creators currently subscribed (survives reconnects). */
|
|
53
|
+
get subscriptions() {
|
|
54
|
+
return [...this.creators];
|
|
55
|
+
}
|
|
56
|
+
/** True only once the socket is OPEN and accepting frames — not merely constructed. */
|
|
57
|
+
get isConnected() {
|
|
58
|
+
return this.socket !== null && this.opened;
|
|
59
|
+
}
|
|
60
|
+
async connect(creatorIds = []) {
|
|
61
|
+
for (const creatorId of creatorIds)
|
|
62
|
+
this.creators.add(normalizeCreatorId(creatorId));
|
|
63
|
+
await this.open();
|
|
64
|
+
}
|
|
65
|
+
subscribe(creatorId) {
|
|
66
|
+
const normalized = normalizeCreatorId(creatorId);
|
|
67
|
+
this.creators.add(normalized);
|
|
68
|
+
this.send({ type: "subscribe", creatorId: normalized });
|
|
69
|
+
}
|
|
70
|
+
unsubscribe(creatorId) {
|
|
71
|
+
const normalized = normalizeCreatorId(creatorId);
|
|
72
|
+
this.creators.delete(normalized);
|
|
73
|
+
this.send({ type: "unsubscribe", creatorId: normalized });
|
|
74
|
+
}
|
|
75
|
+
/** Stop for good. Cancels reconnection — this is not a transient drop. */
|
|
76
|
+
close() {
|
|
77
|
+
this.closed = true;
|
|
78
|
+
this.generation += 1;
|
|
79
|
+
this.opened = false;
|
|
80
|
+
if (this.reconnectTimer !== null) {
|
|
81
|
+
this.options.clearTimeoutImpl(this.reconnectTimer);
|
|
82
|
+
this.reconnectTimer = null;
|
|
83
|
+
}
|
|
84
|
+
const socket = this.socket;
|
|
85
|
+
this.socket = null;
|
|
86
|
+
socket?.close(1000, "client closed");
|
|
87
|
+
}
|
|
88
|
+
send(message) {
|
|
89
|
+
// Only a socket that has actually OPENED accepts frames — a real WebSocket throws
|
|
90
|
+
// `InvalidStateError` while CONNECTING. Mid-connect / mid-reconnect the intent already lives in
|
|
91
|
+
// `creators`, and the resume on the next open replays it, so dropping the frame here is correct.
|
|
92
|
+
if (!this.opened)
|
|
93
|
+
return;
|
|
94
|
+
this.socket?.send(JSON.stringify(message));
|
|
95
|
+
}
|
|
96
|
+
async open() {
|
|
97
|
+
if (this.closed)
|
|
98
|
+
return;
|
|
99
|
+
// A fresh token per connection is what makes expiry a non-event: the only way a token dies
|
|
100
|
+
// mid-stream is if the socket outlives it, and any reconnect re-mints.
|
|
101
|
+
// An explicit reconnect supersedes any armed retry; leaving it armed causes a second, pointless
|
|
102
|
+
// teardown + token mint moments later.
|
|
103
|
+
if (this.reconnectTimer !== null) {
|
|
104
|
+
this.options.clearTimeoutImpl(this.reconnectTimer);
|
|
105
|
+
this.reconnectTimer = null;
|
|
106
|
+
}
|
|
107
|
+
const generation = ++this.generation;
|
|
108
|
+
// A second `connect()`/reconnect supersedes whatever is live now — tear it down before building
|
|
109
|
+
// the replacement, or the old socket keeps streaming (and billing) with nobody holding it.
|
|
110
|
+
const superseded = this.socket;
|
|
111
|
+
this.socket = null;
|
|
112
|
+
this.opened = false;
|
|
113
|
+
superseded?.close(1000, "superseded");
|
|
114
|
+
const { token, wsUrl } = await this.mintToken();
|
|
115
|
+
// `close()` (or another open) may have happened while the token was in flight.
|
|
116
|
+
if (this.closed || generation !== this.generation)
|
|
117
|
+
return;
|
|
118
|
+
const socket = this.options.socketFactory(wsUrl, token);
|
|
119
|
+
if (this.closed || generation !== this.generation) {
|
|
120
|
+
socket.close(1000, "superseded");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.socket = socket;
|
|
124
|
+
socket.onopen = () => {
|
|
125
|
+
if (generation !== this.generation)
|
|
126
|
+
return;
|
|
127
|
+
const attemptThatSucceeded = this.attempt;
|
|
128
|
+
this.attempt = 0;
|
|
129
|
+
this.opened = true;
|
|
130
|
+
for (const creatorId of this.creators)
|
|
131
|
+
socket.send(JSON.stringify({ type: "subscribe", creatorId }));
|
|
132
|
+
// Report the attempt number that actually reconnected, not the reset counter.
|
|
133
|
+
if (attemptThatSucceeded > 0)
|
|
134
|
+
this.handlers.onReconnect?.(attemptThatSucceeded);
|
|
135
|
+
};
|
|
136
|
+
socket.onmessage = (event) => {
|
|
137
|
+
const raw = typeof event.data === "string" ? event.data : String(event.data);
|
|
138
|
+
let frame;
|
|
139
|
+
try {
|
|
140
|
+
frame = JSON.parse(raw);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
this.handlers.onError?.(new Error(`realtime frame was not JSON: ${raw.slice(0, 120)}`));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (frame.type === "event")
|
|
147
|
+
this.handlers.onEvent?.(frame);
|
|
148
|
+
else if (frame.type === "status")
|
|
149
|
+
this.handlers.onStatus?.(frame);
|
|
150
|
+
else if (frame.type === "error")
|
|
151
|
+
this.handlers.onError?.(frame);
|
|
152
|
+
};
|
|
153
|
+
socket.onerror = () => {
|
|
154
|
+
// `onclose` always follows; reconnecting from both would double-schedule.
|
|
155
|
+
this.handlers.onError?.(new Error("realtime socket error"));
|
|
156
|
+
};
|
|
157
|
+
socket.onclose = () => {
|
|
158
|
+
if (generation !== this.generation)
|
|
159
|
+
return;
|
|
160
|
+
this.socket = null;
|
|
161
|
+
this.opened = false;
|
|
162
|
+
if (this.closed)
|
|
163
|
+
return;
|
|
164
|
+
this.scheduleReconnect();
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
scheduleReconnect() {
|
|
168
|
+
// Reachable from the open() catch path after a close(), where retrying is not wanted.
|
|
169
|
+
if (this.closed)
|
|
170
|
+
return;
|
|
171
|
+
if (this.attempt >= this.options.maxReconnectAttempts) {
|
|
172
|
+
this.handlers.onError?.(new Error(`realtime reconnect gave up after ${this.attempt} attempts`));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.attempt += 1;
|
|
176
|
+
// Exponential backoff with FULL jitter: without jitter every client of a restarted gateway
|
|
177
|
+
// returns in the same instant and knocks it over again.
|
|
178
|
+
const ceiling = Math.min(this.options.maxReconnectDelayMs, this.options.baseReconnectDelayMs * 2 ** (this.attempt - 1));
|
|
179
|
+
const delay = Math.floor(this.options.random() * ceiling);
|
|
180
|
+
this.reconnectTimer = this.options.setTimeoutImpl(() => {
|
|
181
|
+
this.reconnectTimer = null;
|
|
182
|
+
if (this.closed)
|
|
183
|
+
return;
|
|
184
|
+
void this.open().catch((error) => {
|
|
185
|
+
this.handlers.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
186
|
+
// A failed re-mint (e.g. 402/403) must not end the loop silently; back off and retry.
|
|
187
|
+
this.scheduleReconnect();
|
|
188
|
+
});
|
|
189
|
+
}, delay);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/** Mirrors the gateway's own normalisation so the SDK and server agree on subscription identity. */
|
|
193
|
+
export function normalizeCreatorId(value) {
|
|
194
|
+
const trimmed = value.trim().replace(/^@/u, "");
|
|
195
|
+
return /^[a-zA-Z0-9._]{2,24}$/u.test(trimmed) ? trimmed.toLowerCase() : trimmed;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=realtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.js","sourceRoot":"","sources":["../src/realtime.ts"],"names":[],"mappings":"AAiDA,SAAS,oBAAoB,CAAC,GAAW,EAAE,KAAa;IACtD,MAAM,IAAI,GAAI,UAA0F,CAAC,SAAS,CAAC;IACnH,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,8HAA8H,CAC/H,CAAC;IACJ,CAAC;IACD,iGAAiG;IACjG,iGAAiG;IACjG,8FAA8F;IAC9F,kGAAk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AC,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;QACxH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE;YACrD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,IAAI,IAAI,CAAC,MAAM;gBAAE,OAAO;YACxB,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC/B,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACnF,sFAAsF;gBACtF,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC;CACF;AAED,oGAAoG;AACpG,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAChD,OAAO,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/** `live:read` + `live:stream` — LIVE sessions, per-creator performance, realtime handshake token. */
|
|
2
|
+
export class LiveResource {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
listSessions(options = {}) {
|
|
8
|
+
return this.http.get("/v1/live/sessions", { ...options });
|
|
9
|
+
}
|
|
10
|
+
getSession(id) {
|
|
11
|
+
return this.http.get(`/v1/live/sessions/${encodeURIComponent(id)}`);
|
|
12
|
+
}
|
|
13
|
+
creatorPerformance(creatorUniqueId, options = {}) {
|
|
14
|
+
return this.http.get(`/v1/live/creators/${encodeURIComponent(creatorUniqueId)}/performance`, { ...options });
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Mint a short-lived realtime handshake token (D2.3). `client.live.stream()` calls this for you —
|
|
18
|
+
* use it directly only when driving the WebSocket yourself.
|
|
19
|
+
*/
|
|
20
|
+
streamToken() {
|
|
21
|
+
return this.http.post("/v1/live/stream/token");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* LIVE video playback sources for a creator who is live now (D2.12). `live:stream`, not
|
|
25
|
+
* `live:read` — this is the video, not the metrics. The customer's runtime fetches the stream
|
|
26
|
+
* itself from TikTok's CDN. `status` is `live` (with `hlsUrl`/`flvUrl`), `no_playback`, or
|
|
27
|
+
* `offline`; a room still being resolved answers `202` (poll again).
|
|
28
|
+
*/
|
|
29
|
+
playback(creatorUniqueId) {
|
|
30
|
+
return this.http.get(`/v1/live/creators/${encodeURIComponent(creatorUniqueId)}/playback`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `rank:read`. Provenance-enveloped: `rankings-service.ts` returns
|
|
35
|
+
* `ProvenanceEnvelope<OfficialRankingResponse>` — `{ data: { board }, provenance }`.
|
|
36
|
+
*/
|
|
37
|
+
export class RankingsResource {
|
|
38
|
+
http;
|
|
39
|
+
constructor(http) {
|
|
40
|
+
this.http = http;
|
|
41
|
+
}
|
|
42
|
+
/** `board` is required by the server; there is no default. */
|
|
43
|
+
official(options) {
|
|
44
|
+
return this.http.get("/v1/rankings/official", { ...options });
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Region "movers" — the creators whose rank changed most since the board's previous period, split
|
|
48
|
+
* into `gainers` (moved up) and `losers` (moved down), each biggest-move-first and capped by
|
|
49
|
+
* `limit` (1–99, default 20). Identity is masked by your plan tier exactly as `official`.
|
|
50
|
+
*/
|
|
51
|
+
movers(options) {
|
|
52
|
+
return this.http.get("/v1/rankings/movers", { ...options });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Retained periods of a board, newest first — the source for a rank trend.
|
|
56
|
+
*
|
|
57
|
+
* `limit` counts PERIODS (1–24, default 12), not rows: each period carries the whole 99-rank
|
|
58
|
+
* board. Page with `cursor` (opaque). One request costs one credit regardless of how many
|
|
59
|
+
* periods come back.
|
|
60
|
+
*/
|
|
61
|
+
history(options) {
|
|
62
|
+
return this.http.get("/v1/rankings/history", { ...options });
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The regions a board can be read for, with each one's coverage and the boards it has captured.
|
|
66
|
+
*
|
|
67
|
+
* Call this instead of guessing: boards are keyed by BUCKET — `US+`, `MENA`, `LATAM`, `DE+` — and
|
|
68
|
+
* an ISO country code like `US` or `DE` matches no board at all, so it comes back coverage-gated
|
|
69
|
+
* rather than empty. The list reflects what has actually been captured, not what is configured.
|
|
70
|
+
*
|
|
71
|
+
* Each region also carries `notOfferedBoards`: the boards proven absent from TikTok's product
|
|
72
|
+
* there. Hide or disable only those. A board missing from `boards` may simply be one we have not
|
|
73
|
+
* captured yet, and it still answers for itself with an honest `not-covered`.
|
|
74
|
+
*/
|
|
75
|
+
regions() {
|
|
76
|
+
return this.http.get("/v1/rankings/regions");
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The per-game gaming boards a region offers — the source for the `game` parameter of a
|
|
80
|
+
* `board: "gaming_game"` read on `official` (and `movers` / `history`). Pass `games[].gameKey`
|
|
81
|
+
* verbatim; never hardcode a game list (the R5.7 lesson applied to games).
|
|
82
|
+
*
|
|
83
|
+
* `status` is `offered` (readable now) or `not_offered` (a game TikTok has pulled). An empty
|
|
84
|
+
* `games` array is a valid answer, not an error: the region runs only the aggregate gaming board,
|
|
85
|
+
* so show no game selector. `region` is a BUCKET key exactly as `regions` reports; omit it to
|
|
86
|
+
* accept the server default.
|
|
87
|
+
*/
|
|
88
|
+
games(options = {}) {
|
|
89
|
+
return this.http.get("/v1/rankings/gaming/games", { ...options });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** `creator:read` — profile, change history, analysis. Videos live on `content` (`content:read`). */
|
|
93
|
+
export class CreatorsResource {
|
|
94
|
+
http;
|
|
95
|
+
constructor(http) {
|
|
96
|
+
this.http = http;
|
|
97
|
+
}
|
|
98
|
+
/** Handle/name search. */
|
|
99
|
+
list(options = {}) {
|
|
100
|
+
return this.http.get("/v1/creators", { ...options });
|
|
101
|
+
}
|
|
102
|
+
get(uid) {
|
|
103
|
+
return this.http.get(`/v1/creators/${encodeURIComponent(uid)}`);
|
|
104
|
+
}
|
|
105
|
+
changes(uid, options = {}) {
|
|
106
|
+
return this.http.get(`/v1/creators/${encodeURIComponent(uid)}/changes`, { ...options });
|
|
107
|
+
}
|
|
108
|
+
analysis(uid) {
|
|
109
|
+
return this.http.get(`/v1/creators/${encodeURIComponent(uid)}/analysis`);
|
|
110
|
+
}
|
|
111
|
+
/** R4.5 — the same read in both directions; a real upstream walk bills the heavier SKU. */
|
|
112
|
+
following(uid, options = {}) {
|
|
113
|
+
return this.http.get(`/v1/creators/${encodeURIComponent(uid)}/following`, { ...options });
|
|
114
|
+
}
|
|
115
|
+
followers(uid, options = {}) {
|
|
116
|
+
return this.http.get(`/v1/creators/${encodeURIComponent(uid)}/followers`, { ...options });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** `content:read` — a creator's videos, one video, its comments. Sold separately from the profile. */
|
|
120
|
+
export class ContentResource {
|
|
121
|
+
http;
|
|
122
|
+
constructor(http) {
|
|
123
|
+
this.http = http;
|
|
124
|
+
}
|
|
125
|
+
/** Takes no query parameters — the route declares no querystring schema and the service uses a
|
|
126
|
+
* fixed internal limit. (A param passed here would be silently ignored, not rejected, which is why
|
|
127
|
+
* an acceptance run cannot catch it — the route has no schema to reject against.) */
|
|
128
|
+
creatorVideos(uid) {
|
|
129
|
+
return this.http.get(`/v1/creators/${encodeURIComponent(uid)}/videos`);
|
|
130
|
+
}
|
|
131
|
+
/** D6.1 — the creator's active story tray, fetched fresh through the signed mobile path. Empty
|
|
132
|
+
* tray (never an error) when no signed credential is configured. */
|
|
133
|
+
creatorStories(uid) {
|
|
134
|
+
return this.http.get(`/v1/creators/${encodeURIComponent(uid)}/stories`);
|
|
135
|
+
}
|
|
136
|
+
video(videoId) {
|
|
137
|
+
return this.http.get(`/v1/videos/${encodeURIComponent(videoId)}`);
|
|
138
|
+
}
|
|
139
|
+
videoComments(videoId, options = {}) {
|
|
140
|
+
return this.http.get(`/v1/videos/${encodeURIComponent(videoId)}/comments`, { ...options });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** `gifter:read` — whale intelligence. Its own SKU, hence its own namespace. */
|
|
144
|
+
export class GiftersResource {
|
|
145
|
+
http;
|
|
146
|
+
constructor(http) {
|
|
147
|
+
this.http = http;
|
|
148
|
+
}
|
|
149
|
+
list(options = {}) {
|
|
150
|
+
return this.http.get("/v1/gifters", { ...options });
|
|
151
|
+
}
|
|
152
|
+
get(gifterKey, options = {}) {
|
|
153
|
+
return this.http.get(`/v1/gifters/${encodeURIComponent(gifterKey)}`, { ...options });
|
|
154
|
+
}
|
|
155
|
+
forCreator(handle, options = {}) {
|
|
156
|
+
return this.http.get(`/v1/creators/${encodeURIComponent(handle)}/gifters`, { ...options });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/** `trend:read` */
|
|
160
|
+
export class TrendsResource {
|
|
161
|
+
http;
|
|
162
|
+
constructor(http) {
|
|
163
|
+
this.http = http;
|
|
164
|
+
}
|
|
165
|
+
/** Note: this route takes no `limit`. */
|
|
166
|
+
list(options = {}) {
|
|
167
|
+
return this.http.get("/v1/trends", { ...options });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** `export` — async bulk extracts. */
|
|
171
|
+
export class ExportsResource {
|
|
172
|
+
http;
|
|
173
|
+
constructor(http) {
|
|
174
|
+
this.http = http;
|
|
175
|
+
}
|
|
176
|
+
/** Takes no query parameters. */
|
|
177
|
+
list() {
|
|
178
|
+
return this.http.get("/v1/exports");
|
|
179
|
+
}
|
|
180
|
+
create(input) {
|
|
181
|
+
return this.http.post("/v1/exports", input);
|
|
182
|
+
}
|
|
183
|
+
get(id) {
|
|
184
|
+
return this.http.get(`/v1/exports/${encodeURIComponent(id)}`);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The finished extract itself — **`text/csv`, not JSON**, returned as a string. Parsing it as JSON
|
|
188
|
+
* (as an earlier version of this SDK did) silently yields `undefined`.
|
|
189
|
+
*/
|
|
190
|
+
download(id) {
|
|
191
|
+
return this.http.getText(`/v1/exports/${encodeURIComponent(id)}/download`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/** `keys:manage` — what this key may do, and what it has spent. */
|
|
195
|
+
export class AccountResource {
|
|
196
|
+
http;
|
|
197
|
+
constructor(http) {
|
|
198
|
+
this.http = http;
|
|
199
|
+
}
|
|
200
|
+
entitlements(options = {}) {
|
|
201
|
+
return this.http.get("/v1/entitlements", { ...options });
|
|
202
|
+
}
|
|
203
|
+
/** Not provenance-enveloped — `usage-service.ts` returns this shape directly. */
|
|
204
|
+
usage(options = {}) {
|
|
205
|
+
return this.http.get("/v1/usage", { ...options });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAkIA,sGAAsG;AACtG,MAAM,OAAO,YAAY;IACM;IAA7B,YAA6B,IAAmB;QA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,CAAC,OAAO,CAAC,eAAe,kBAAkB,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC7E,CAAC;CACF;AAED,mEAAmE;AACnE,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD,YAAY,CAAC,UAA+B,EAAE;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAsB,kBAAkB,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,iFAAiF;IACjF,KAAK,CAAC,UAAwB,EAAE;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAiB,WAAW,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toktikhq/sdk-js",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Typed JavaScript client for the TokTik Developer API (REST + realtime LIVE events)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tiktok",
|
|
7
|
+
"live",
|
|
8
|
+
"realtime",
|
|
9
|
+
"developer-api"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "https://docs.toktikhq.com/docs/sdks",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"provenance": true
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "npm run build --workspace @v2/contracts && node ./scripts/build.mjs",
|
|
35
|
+
"prepack": "npm run build && npm run test:package",
|
|
36
|
+
"test:package": "node ./scripts/verify-package.mjs",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"test": "node --import tsx --test tests/*.test.ts"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@v2/contracts": "0.1.0",
|
|
42
|
+
"rollup": "^4.60.1",
|
|
43
|
+
"rollup-plugin-dts": "^6.5.1"
|
|
44
|
+
}
|
|
45
|
+
}
|