@rngrow/sdk 0.1.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 +100 -0
- package/dist/index.cjs +150 -0
- package/dist/index.d.cts +241 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.js +124 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RnG - Recruit n' Grow (rngrow.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# rngrow
|
|
2
|
+
|
|
3
|
+
Official SDK for the [RnG TikTok LIVE Creator API](https://rngrow.com/api-docs).
|
|
4
|
+
|
|
5
|
+
Pull TikTok LIVE creator data straight into your own tools: recruitable creators verified by
|
|
6
|
+
RnG's checker pipeline, LIVE league boards, gaming and daily rankings, and real-time HOT
|
|
7
|
+
signals for creators spiking in diamonds right now.
|
|
8
|
+
|
|
9
|
+
- Typed responses, zero dependencies, Node.js 18+
|
|
10
|
+
- Automatic cursor pagination for the creators pool
|
|
11
|
+
- Clear, machine-readable errors with rate-limit awareness
|
|
12
|
+
|
|
13
|
+
API access is included with the [Radar plan](https://rngrow.com/pricing). Generate your key
|
|
14
|
+
in [Dashboard → API Access](https://rngrow.com/dashboard/api).
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install rngrow
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quickstart
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { Rngrow } from "rngrow";
|
|
26
|
+
|
|
27
|
+
const rng = new Rngrow(process.env.RNG_API_KEY!);
|
|
28
|
+
|
|
29
|
+
// Who am I? Countries, limits, usage.
|
|
30
|
+
console.log(await rng.me());
|
|
31
|
+
|
|
32
|
+
// One page of recruitable creators, newest checked first
|
|
33
|
+
const page = await rng.creators.list({ country: "RO", limit: 100 });
|
|
34
|
+
for (const c of page.creators) {
|
|
35
|
+
console.log(c.username, c.follower_count, c.checked_at);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Walk the whole pool with automatic pagination
|
|
39
|
+
for await (const creator of rng.creators.iterate({ country: "RO", maxItems: 1000 })) {
|
|
40
|
+
console.log(creator.username);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## League data
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
// Which divisions exist for your countries
|
|
48
|
+
const coverage = await rng.leagues.list();
|
|
49
|
+
|
|
50
|
+
// A division's full ranked board (top 99) with recruitability + HOT status
|
|
51
|
+
const board = await rng.leagues.board({ country: "RO", division: "A1" });
|
|
52
|
+
|
|
53
|
+
// Only the recruitable creators across all of a country's boards
|
|
54
|
+
const recruitable = await rng.leagues.available({ country: "RO", limit: 200 });
|
|
55
|
+
|
|
56
|
+
// Gaming and daily rankings
|
|
57
|
+
const games = await rng.leagues.games({ country: "US" });
|
|
58
|
+
const gaming = await rng.leagues.gaming({ country: "US", game: "all" });
|
|
59
|
+
const daily = await rng.leagues.daily({ country: "RO" });
|
|
60
|
+
|
|
61
|
+
// Creators spiking RIGHT NOW
|
|
62
|
+
const hot = await rng.leagues.hot({ country: "RO" });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Errors
|
|
66
|
+
|
|
67
|
+
Every failure throws a `RngrowError` with a stable `code`, the HTTP `status`, and
|
|
68
|
+
`retryAfter` (seconds) when rate limited:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { Rngrow, RngrowError } from "rngrow";
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
await rng.creators.list({ country: "US" });
|
|
75
|
+
} catch (e) {
|
|
76
|
+
if (e instanceof RngrowError) {
|
|
77
|
+
// e.code: missing_api_key | invalid_api_key | plan_required |
|
|
78
|
+
// country_not_in_plan | invalid_request | not_found |
|
|
79
|
+
// rate_limited | server_error
|
|
80
|
+
if (e.code === "rate_limited") {
|
|
81
|
+
console.log(`Backing off ${e.retryAfter ?? 60}s`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Rate limits
|
|
88
|
+
|
|
89
|
+
60 requests per minute and 10,000 per day per key. Responses carry
|
|
90
|
+
`X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` headers. Use
|
|
91
|
+
`since` and cursors to poll efficiently instead of re-downloading the pool.
|
|
92
|
+
|
|
93
|
+
## Links
|
|
94
|
+
|
|
95
|
+
- [API documentation](https://rngrow.com/api-docs)
|
|
96
|
+
- [Pricing](https://rngrow.com/pricing)
|
|
97
|
+
- Support: support@rngrow.com
|
|
98
|
+
|
|
99
|
+
RnG is an independent data platform and is not affiliated with, endorsed by, or sponsored by
|
|
100
|
+
TikTok or ByteDance.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Rngrow: () => Rngrow,
|
|
24
|
+
RngrowError: () => RngrowError,
|
|
25
|
+
default: () => index_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
var DEFAULT_BASE_URL = "https://rngrow.com/api/v1";
|
|
29
|
+
var RngrowError = class extends Error {
|
|
30
|
+
constructor(code, message, status, retryAfter) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "RngrowError";
|
|
33
|
+
this.code = code;
|
|
34
|
+
this.status = status;
|
|
35
|
+
this.retryAfter = retryAfter;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var Rngrow = class {
|
|
39
|
+
constructor(apiKey, options = {}) {
|
|
40
|
+
this.creators = {
|
|
41
|
+
/**
|
|
42
|
+
* One page of the available-creators pool, newest checked first.
|
|
43
|
+
* Paginate by passing next_cursor back as cursor.
|
|
44
|
+
*/
|
|
45
|
+
list: (params) => this.request("/creators", {
|
|
46
|
+
country: params.country,
|
|
47
|
+
limit: params.limit,
|
|
48
|
+
cursor: params.cursor,
|
|
49
|
+
since: params.since instanceof Date ? params.since.toISOString() : params.since,
|
|
50
|
+
include_diamonds: params.includeDiamonds ? "true" : void 0
|
|
51
|
+
}),
|
|
52
|
+
/** Discovery volume for a country. */
|
|
53
|
+
stats: (params) => this.request("/creators/stats", { country: params.country }),
|
|
54
|
+
/**
|
|
55
|
+
* Iterate the whole pool with automatic cursor pagination.
|
|
56
|
+
*
|
|
57
|
+
* for await (const creator of rng.creators.iterate({ country: "RO" })) { … }
|
|
58
|
+
*/
|
|
59
|
+
iterate: (params) => {
|
|
60
|
+
const self = this;
|
|
61
|
+
async function* gen() {
|
|
62
|
+
let cursor;
|
|
63
|
+
let yielded = 0;
|
|
64
|
+
for (; ; ) {
|
|
65
|
+
const page = await self.creators.list({
|
|
66
|
+
country: params.country,
|
|
67
|
+
since: params.since,
|
|
68
|
+
includeDiamonds: params.includeDiamonds,
|
|
69
|
+
limit: 200,
|
|
70
|
+
cursor
|
|
71
|
+
});
|
|
72
|
+
for (const c of page.creators) {
|
|
73
|
+
yield c;
|
|
74
|
+
yielded++;
|
|
75
|
+
if (params.maxItems && yielded >= params.maxItems) return;
|
|
76
|
+
}
|
|
77
|
+
if (!page.has_more || !page.next_cursor) return;
|
|
78
|
+
cursor = page.next_cursor;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return gen();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
this.leagues = {
|
|
85
|
+
/** Division coverage for every country on your plan. */
|
|
86
|
+
list: () => this.request("/leagues"),
|
|
87
|
+
/** One division's full ranked board (top 99), with recruitability + HOT status. */
|
|
88
|
+
board: (params) => this.request("/leagues/board", params),
|
|
89
|
+
/** Only the recruitable creators across a country's league boards. */
|
|
90
|
+
available: (params) => this.request("/leagues/available", params),
|
|
91
|
+
/** A country's gaming ranking, combined ("all") or per game slug. */
|
|
92
|
+
gaming: (params) => this.request("/leagues/gaming", params),
|
|
93
|
+
/** Which per-game boards exist for a country. */
|
|
94
|
+
games: (params) => this.request("/leagues/gaming/games", params),
|
|
95
|
+
/** The country's daily (hourly for MENA) diamond ranking. */
|
|
96
|
+
daily: (params) => this.request("/leagues/daily", params),
|
|
97
|
+
/** Creators spiking in diamonds right now, across all divisions. */
|
|
98
|
+
hot: (params) => this.request("/leagues/hot", params)
|
|
99
|
+
};
|
|
100
|
+
if (!apiKey || !apiKey.startsWith("rng_")) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
"Rngrow: an API key starting with rng_ is required. Generate one at https://rngrow.com/dashboard/api"
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
this.apiKey = apiKey;
|
|
106
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
107
|
+
const f = options.fetch ?? globalThis.fetch;
|
|
108
|
+
if (!f) {
|
|
109
|
+
throw new Error("Rngrow: global fetch not found (Node 18+ required) and no fetch option given.");
|
|
110
|
+
}
|
|
111
|
+
this.fetchImpl = f.bind(globalThis);
|
|
112
|
+
}
|
|
113
|
+
async request(path, query = {}) {
|
|
114
|
+
const url = new URL(this.baseUrl + path);
|
|
115
|
+
for (const [k, v] of Object.entries(query)) {
|
|
116
|
+
if (v !== void 0 && v !== null && v !== "") url.searchParams.set(k, String(v));
|
|
117
|
+
}
|
|
118
|
+
const res = await this.fetchImpl(url.toString(), {
|
|
119
|
+
headers: { "X-API-Key": this.apiKey, Accept: "application/json" }
|
|
120
|
+
});
|
|
121
|
+
let body;
|
|
122
|
+
try {
|
|
123
|
+
body = await res.json();
|
|
124
|
+
} catch {
|
|
125
|
+
body = void 0;
|
|
126
|
+
}
|
|
127
|
+
if (!res.ok) {
|
|
128
|
+
const err = body?.error;
|
|
129
|
+
const retryHeader = res.headers.get("Retry-After");
|
|
130
|
+
const retryAfter = retryHeader ? Number(retryHeader) || void 0 : void 0;
|
|
131
|
+
throw new RngrowError(
|
|
132
|
+
err?.code ?? "server_error",
|
|
133
|
+
err?.message ?? `Request failed with HTTP ${res.status}`,
|
|
134
|
+
res.status,
|
|
135
|
+
retryAfter
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
return body;
|
|
139
|
+
}
|
|
140
|
+
/** Key introspection: plan, countries, rate limits, usage today. */
|
|
141
|
+
me() {
|
|
142
|
+
return this.request("/me");
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var index_default = Rngrow;
|
|
146
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
0 && (module.exports = {
|
|
148
|
+
Rngrow,
|
|
149
|
+
RngrowError
|
|
150
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official SDK for the RnG TikTok LIVE Creator API.
|
|
3
|
+
*
|
|
4
|
+
* npm install rngrow
|
|
5
|
+
*
|
|
6
|
+
* import { Rngrow } from "rngrow";
|
|
7
|
+
* const rng = new Rngrow(process.env.RNG_API_KEY!);
|
|
8
|
+
* const page = await rng.creators.list({ country: "RO" });
|
|
9
|
+
*
|
|
10
|
+
* Docs: https://rngrow.com/api-docs
|
|
11
|
+
* API access is included with the Radar plan; generate a key at
|
|
12
|
+
* https://rngrow.com/dashboard/api.
|
|
13
|
+
*/
|
|
14
|
+
interface Me {
|
|
15
|
+
key: {
|
|
16
|
+
name: string;
|
|
17
|
+
prefix: string;
|
|
18
|
+
created_at: string;
|
|
19
|
+
};
|
|
20
|
+
plan: "radar" | "admin";
|
|
21
|
+
countries: string[] | "all";
|
|
22
|
+
rate_limit: {
|
|
23
|
+
per_minute: number;
|
|
24
|
+
per_day: number;
|
|
25
|
+
};
|
|
26
|
+
usage_today: number;
|
|
27
|
+
}
|
|
28
|
+
interface Creator {
|
|
29
|
+
id: number | string;
|
|
30
|
+
username: string;
|
|
31
|
+
display_name: string | null;
|
|
32
|
+
invitation_type: string | null;
|
|
33
|
+
checked_at: string | null;
|
|
34
|
+
viewer_count: string | number | null;
|
|
35
|
+
follower_count: number | null;
|
|
36
|
+
/** Present only when include_diamonds was requested. */
|
|
37
|
+
diamonds?: number | null;
|
|
38
|
+
}
|
|
39
|
+
interface CreatorsPage {
|
|
40
|
+
country: string;
|
|
41
|
+
count: number;
|
|
42
|
+
/** Present only on the first page (no cursor). */
|
|
43
|
+
total?: number;
|
|
44
|
+
has_more: boolean;
|
|
45
|
+
next_cursor: string | null;
|
|
46
|
+
creators: Creator[];
|
|
47
|
+
}
|
|
48
|
+
interface CreatorStats {
|
|
49
|
+
country: string;
|
|
50
|
+
total_scraped: number;
|
|
51
|
+
available_now: number;
|
|
52
|
+
last_30_days: number;
|
|
53
|
+
last_24_hours: number;
|
|
54
|
+
}
|
|
55
|
+
interface LeagueDivision {
|
|
56
|
+
division: string;
|
|
57
|
+
captured_at: string | null;
|
|
58
|
+
board_age_minutes: number | null;
|
|
59
|
+
}
|
|
60
|
+
interface LeagueCoverage {
|
|
61
|
+
countries: {
|
|
62
|
+
country: string;
|
|
63
|
+
divisions: LeagueDivision[];
|
|
64
|
+
}[];
|
|
65
|
+
}
|
|
66
|
+
interface LeagueBoardRow {
|
|
67
|
+
rank: number;
|
|
68
|
+
username: string | null;
|
|
69
|
+
nickname: string | null;
|
|
70
|
+
score: number | null;
|
|
71
|
+
follower_count: number | null;
|
|
72
|
+
league_letter: string | null;
|
|
73
|
+
was_live: boolean | null;
|
|
74
|
+
recruit_status: "available" | "contacted" | "not_available" | "unknown" | string;
|
|
75
|
+
check_age_minutes: number | null;
|
|
76
|
+
hot_status: "none" | "hot" | "diamond" | string;
|
|
77
|
+
}
|
|
78
|
+
interface LeagueBoard {
|
|
79
|
+
country: string;
|
|
80
|
+
division: string;
|
|
81
|
+
board_age_minutes: number | null;
|
|
82
|
+
count: number;
|
|
83
|
+
rows: LeagueBoardRow[];
|
|
84
|
+
}
|
|
85
|
+
interface LeagueAvailableCreator {
|
|
86
|
+
division: string;
|
|
87
|
+
rank: number;
|
|
88
|
+
username: string | null;
|
|
89
|
+
nickname: string | null;
|
|
90
|
+
score: number | null;
|
|
91
|
+
follower_count: number | null;
|
|
92
|
+
league_letter: string | null;
|
|
93
|
+
check_age_minutes: number | null;
|
|
94
|
+
}
|
|
95
|
+
interface LeagueAvailablePage {
|
|
96
|
+
country: string;
|
|
97
|
+
division?: string;
|
|
98
|
+
total: number;
|
|
99
|
+
limit: number;
|
|
100
|
+
offset: number;
|
|
101
|
+
count: number;
|
|
102
|
+
creators: LeagueAvailableCreator[];
|
|
103
|
+
}
|
|
104
|
+
interface RankingRow {
|
|
105
|
+
rank: number;
|
|
106
|
+
username: string | null;
|
|
107
|
+
nickname: string | null;
|
|
108
|
+
diamonds: number | null;
|
|
109
|
+
follower_count: number | null;
|
|
110
|
+
was_live: boolean | null;
|
|
111
|
+
recruit_status: string;
|
|
112
|
+
check_age_minutes: number | null;
|
|
113
|
+
creator_country: string | null;
|
|
114
|
+
/** Gaming board only: creator's tracked country equals the board's country. */
|
|
115
|
+
is_home?: boolean;
|
|
116
|
+
}
|
|
117
|
+
interface GamingBoard {
|
|
118
|
+
country: string;
|
|
119
|
+
game: string;
|
|
120
|
+
board_age_minutes: number | null;
|
|
121
|
+
count: number;
|
|
122
|
+
rows: RankingRow[];
|
|
123
|
+
}
|
|
124
|
+
interface DailyBoard {
|
|
125
|
+
country: string;
|
|
126
|
+
board_type: "daily" | "hourly" | string;
|
|
127
|
+
board_age_minutes: number | null;
|
|
128
|
+
count: number;
|
|
129
|
+
rows: RankingRow[];
|
|
130
|
+
}
|
|
131
|
+
interface GamingGame {
|
|
132
|
+
game: string;
|
|
133
|
+
label: string;
|
|
134
|
+
captured_at: string | null;
|
|
135
|
+
}
|
|
136
|
+
interface HotCreator {
|
|
137
|
+
division: string;
|
|
138
|
+
username: string | null;
|
|
139
|
+
nickname: string | null;
|
|
140
|
+
status: "hot" | "diamond" | string;
|
|
141
|
+
diamonds_gained: number | null;
|
|
142
|
+
score: number | null;
|
|
143
|
+
follower_count: number | null;
|
|
144
|
+
hot_since: string | null;
|
|
145
|
+
}
|
|
146
|
+
interface HotCreators {
|
|
147
|
+
country: string;
|
|
148
|
+
count: number;
|
|
149
|
+
creators: HotCreator[];
|
|
150
|
+
}
|
|
151
|
+
declare class RngrowError extends Error {
|
|
152
|
+
/** Machine-readable error code, e.g. "country_not_in_plan" or "rate_limited". */
|
|
153
|
+
readonly code: string;
|
|
154
|
+
/** HTTP status of the failed response. */
|
|
155
|
+
readonly status: number;
|
|
156
|
+
/** Seconds to wait before retrying (rate_limited only). */
|
|
157
|
+
readonly retryAfter?: number;
|
|
158
|
+
constructor(code: string, message: string, status: number, retryAfter?: number);
|
|
159
|
+
}
|
|
160
|
+
interface RngrowOptions {
|
|
161
|
+
/** Override the API base URL. Default: https://rngrow.com/api/v1 */
|
|
162
|
+
baseUrl?: string;
|
|
163
|
+
/** Custom fetch implementation (default: globalThis.fetch, Node 18+). */
|
|
164
|
+
fetch?: typeof globalThis.fetch;
|
|
165
|
+
}
|
|
166
|
+
declare class Rngrow {
|
|
167
|
+
private readonly apiKey;
|
|
168
|
+
private readonly baseUrl;
|
|
169
|
+
private readonly fetchImpl;
|
|
170
|
+
constructor(apiKey: string, options?: RngrowOptions);
|
|
171
|
+
private request;
|
|
172
|
+
/** Key introspection: plan, countries, rate limits, usage today. */
|
|
173
|
+
me(): Promise<Me>;
|
|
174
|
+
readonly creators: {
|
|
175
|
+
/**
|
|
176
|
+
* One page of the available-creators pool, newest checked first.
|
|
177
|
+
* Paginate by passing next_cursor back as cursor.
|
|
178
|
+
*/
|
|
179
|
+
list: (params: {
|
|
180
|
+
country: string;
|
|
181
|
+
limit?: number;
|
|
182
|
+
cursor?: string;
|
|
183
|
+
since?: string | Date;
|
|
184
|
+
includeDiamonds?: boolean;
|
|
185
|
+
}) => Promise<CreatorsPage>;
|
|
186
|
+
/** Discovery volume for a country. */
|
|
187
|
+
stats: (params: {
|
|
188
|
+
country: string;
|
|
189
|
+
}) => Promise<CreatorStats>;
|
|
190
|
+
/**
|
|
191
|
+
* Iterate the whole pool with automatic cursor pagination.
|
|
192
|
+
*
|
|
193
|
+
* for await (const creator of rng.creators.iterate({ country: "RO" })) { … }
|
|
194
|
+
*/
|
|
195
|
+
iterate: (params: {
|
|
196
|
+
country: string;
|
|
197
|
+
since?: string | Date;
|
|
198
|
+
includeDiamonds?: boolean;
|
|
199
|
+
/** Stop after this many creators (default: no limit). */
|
|
200
|
+
maxItems?: number;
|
|
201
|
+
}) => AsyncGenerator<Creator, void, undefined>;
|
|
202
|
+
};
|
|
203
|
+
readonly leagues: {
|
|
204
|
+
/** Division coverage for every country on your plan. */
|
|
205
|
+
list: () => Promise<LeagueCoverage>;
|
|
206
|
+
/** One division's full ranked board (top 99), with recruitability + HOT status. */
|
|
207
|
+
board: (params: {
|
|
208
|
+
country: string;
|
|
209
|
+
division: string;
|
|
210
|
+
}) => Promise<LeagueBoard>;
|
|
211
|
+
/** Only the recruitable creators across a country's league boards. */
|
|
212
|
+
available: (params: {
|
|
213
|
+
country: string;
|
|
214
|
+
division?: string;
|
|
215
|
+
limit?: number;
|
|
216
|
+
offset?: number;
|
|
217
|
+
}) => Promise<LeagueAvailablePage>;
|
|
218
|
+
/** A country's gaming ranking, combined ("all") or per game slug. */
|
|
219
|
+
gaming: (params: {
|
|
220
|
+
country: string;
|
|
221
|
+
game?: string;
|
|
222
|
+
}) => Promise<GamingBoard>;
|
|
223
|
+
/** Which per-game boards exist for a country. */
|
|
224
|
+
games: (params: {
|
|
225
|
+
country: string;
|
|
226
|
+
}) => Promise<{
|
|
227
|
+
country: string;
|
|
228
|
+
games: GamingGame[];
|
|
229
|
+
}>;
|
|
230
|
+
/** The country's daily (hourly for MENA) diamond ranking. */
|
|
231
|
+
daily: (params: {
|
|
232
|
+
country: string;
|
|
233
|
+
}) => Promise<DailyBoard>;
|
|
234
|
+
/** Creators spiking in diamonds right now, across all divisions. */
|
|
235
|
+
hot: (params: {
|
|
236
|
+
country: string;
|
|
237
|
+
}) => Promise<HotCreators>;
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export { type Creator, type CreatorStats, type CreatorsPage, type DailyBoard, type GamingBoard, type GamingGame, type HotCreator, type HotCreators, type LeagueAvailableCreator, type LeagueAvailablePage, type LeagueBoard, type LeagueBoardRow, type LeagueCoverage, type LeagueDivision, type Me, type RankingRow, Rngrow, RngrowError, type RngrowOptions, Rngrow as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official SDK for the RnG TikTok LIVE Creator API.
|
|
3
|
+
*
|
|
4
|
+
* npm install rngrow
|
|
5
|
+
*
|
|
6
|
+
* import { Rngrow } from "rngrow";
|
|
7
|
+
* const rng = new Rngrow(process.env.RNG_API_KEY!);
|
|
8
|
+
* const page = await rng.creators.list({ country: "RO" });
|
|
9
|
+
*
|
|
10
|
+
* Docs: https://rngrow.com/api-docs
|
|
11
|
+
* API access is included with the Radar plan; generate a key at
|
|
12
|
+
* https://rngrow.com/dashboard/api.
|
|
13
|
+
*/
|
|
14
|
+
interface Me {
|
|
15
|
+
key: {
|
|
16
|
+
name: string;
|
|
17
|
+
prefix: string;
|
|
18
|
+
created_at: string;
|
|
19
|
+
};
|
|
20
|
+
plan: "radar" | "admin";
|
|
21
|
+
countries: string[] | "all";
|
|
22
|
+
rate_limit: {
|
|
23
|
+
per_minute: number;
|
|
24
|
+
per_day: number;
|
|
25
|
+
};
|
|
26
|
+
usage_today: number;
|
|
27
|
+
}
|
|
28
|
+
interface Creator {
|
|
29
|
+
id: number | string;
|
|
30
|
+
username: string;
|
|
31
|
+
display_name: string | null;
|
|
32
|
+
invitation_type: string | null;
|
|
33
|
+
checked_at: string | null;
|
|
34
|
+
viewer_count: string | number | null;
|
|
35
|
+
follower_count: number | null;
|
|
36
|
+
/** Present only when include_diamonds was requested. */
|
|
37
|
+
diamonds?: number | null;
|
|
38
|
+
}
|
|
39
|
+
interface CreatorsPage {
|
|
40
|
+
country: string;
|
|
41
|
+
count: number;
|
|
42
|
+
/** Present only on the first page (no cursor). */
|
|
43
|
+
total?: number;
|
|
44
|
+
has_more: boolean;
|
|
45
|
+
next_cursor: string | null;
|
|
46
|
+
creators: Creator[];
|
|
47
|
+
}
|
|
48
|
+
interface CreatorStats {
|
|
49
|
+
country: string;
|
|
50
|
+
total_scraped: number;
|
|
51
|
+
available_now: number;
|
|
52
|
+
last_30_days: number;
|
|
53
|
+
last_24_hours: number;
|
|
54
|
+
}
|
|
55
|
+
interface LeagueDivision {
|
|
56
|
+
division: string;
|
|
57
|
+
captured_at: string | null;
|
|
58
|
+
board_age_minutes: number | null;
|
|
59
|
+
}
|
|
60
|
+
interface LeagueCoverage {
|
|
61
|
+
countries: {
|
|
62
|
+
country: string;
|
|
63
|
+
divisions: LeagueDivision[];
|
|
64
|
+
}[];
|
|
65
|
+
}
|
|
66
|
+
interface LeagueBoardRow {
|
|
67
|
+
rank: number;
|
|
68
|
+
username: string | null;
|
|
69
|
+
nickname: string | null;
|
|
70
|
+
score: number | null;
|
|
71
|
+
follower_count: number | null;
|
|
72
|
+
league_letter: string | null;
|
|
73
|
+
was_live: boolean | null;
|
|
74
|
+
recruit_status: "available" | "contacted" | "not_available" | "unknown" | string;
|
|
75
|
+
check_age_minutes: number | null;
|
|
76
|
+
hot_status: "none" | "hot" | "diamond" | string;
|
|
77
|
+
}
|
|
78
|
+
interface LeagueBoard {
|
|
79
|
+
country: string;
|
|
80
|
+
division: string;
|
|
81
|
+
board_age_minutes: number | null;
|
|
82
|
+
count: number;
|
|
83
|
+
rows: LeagueBoardRow[];
|
|
84
|
+
}
|
|
85
|
+
interface LeagueAvailableCreator {
|
|
86
|
+
division: string;
|
|
87
|
+
rank: number;
|
|
88
|
+
username: string | null;
|
|
89
|
+
nickname: string | null;
|
|
90
|
+
score: number | null;
|
|
91
|
+
follower_count: number | null;
|
|
92
|
+
league_letter: string | null;
|
|
93
|
+
check_age_minutes: number | null;
|
|
94
|
+
}
|
|
95
|
+
interface LeagueAvailablePage {
|
|
96
|
+
country: string;
|
|
97
|
+
division?: string;
|
|
98
|
+
total: number;
|
|
99
|
+
limit: number;
|
|
100
|
+
offset: number;
|
|
101
|
+
count: number;
|
|
102
|
+
creators: LeagueAvailableCreator[];
|
|
103
|
+
}
|
|
104
|
+
interface RankingRow {
|
|
105
|
+
rank: number;
|
|
106
|
+
username: string | null;
|
|
107
|
+
nickname: string | null;
|
|
108
|
+
diamonds: number | null;
|
|
109
|
+
follower_count: number | null;
|
|
110
|
+
was_live: boolean | null;
|
|
111
|
+
recruit_status: string;
|
|
112
|
+
check_age_minutes: number | null;
|
|
113
|
+
creator_country: string | null;
|
|
114
|
+
/** Gaming board only: creator's tracked country equals the board's country. */
|
|
115
|
+
is_home?: boolean;
|
|
116
|
+
}
|
|
117
|
+
interface GamingBoard {
|
|
118
|
+
country: string;
|
|
119
|
+
game: string;
|
|
120
|
+
board_age_minutes: number | null;
|
|
121
|
+
count: number;
|
|
122
|
+
rows: RankingRow[];
|
|
123
|
+
}
|
|
124
|
+
interface DailyBoard {
|
|
125
|
+
country: string;
|
|
126
|
+
board_type: "daily" | "hourly" | string;
|
|
127
|
+
board_age_minutes: number | null;
|
|
128
|
+
count: number;
|
|
129
|
+
rows: RankingRow[];
|
|
130
|
+
}
|
|
131
|
+
interface GamingGame {
|
|
132
|
+
game: string;
|
|
133
|
+
label: string;
|
|
134
|
+
captured_at: string | null;
|
|
135
|
+
}
|
|
136
|
+
interface HotCreator {
|
|
137
|
+
division: string;
|
|
138
|
+
username: string | null;
|
|
139
|
+
nickname: string | null;
|
|
140
|
+
status: "hot" | "diamond" | string;
|
|
141
|
+
diamonds_gained: number | null;
|
|
142
|
+
score: number | null;
|
|
143
|
+
follower_count: number | null;
|
|
144
|
+
hot_since: string | null;
|
|
145
|
+
}
|
|
146
|
+
interface HotCreators {
|
|
147
|
+
country: string;
|
|
148
|
+
count: number;
|
|
149
|
+
creators: HotCreator[];
|
|
150
|
+
}
|
|
151
|
+
declare class RngrowError extends Error {
|
|
152
|
+
/** Machine-readable error code, e.g. "country_not_in_plan" or "rate_limited". */
|
|
153
|
+
readonly code: string;
|
|
154
|
+
/** HTTP status of the failed response. */
|
|
155
|
+
readonly status: number;
|
|
156
|
+
/** Seconds to wait before retrying (rate_limited only). */
|
|
157
|
+
readonly retryAfter?: number;
|
|
158
|
+
constructor(code: string, message: string, status: number, retryAfter?: number);
|
|
159
|
+
}
|
|
160
|
+
interface RngrowOptions {
|
|
161
|
+
/** Override the API base URL. Default: https://rngrow.com/api/v1 */
|
|
162
|
+
baseUrl?: string;
|
|
163
|
+
/** Custom fetch implementation (default: globalThis.fetch, Node 18+). */
|
|
164
|
+
fetch?: typeof globalThis.fetch;
|
|
165
|
+
}
|
|
166
|
+
declare class Rngrow {
|
|
167
|
+
private readonly apiKey;
|
|
168
|
+
private readonly baseUrl;
|
|
169
|
+
private readonly fetchImpl;
|
|
170
|
+
constructor(apiKey: string, options?: RngrowOptions);
|
|
171
|
+
private request;
|
|
172
|
+
/** Key introspection: plan, countries, rate limits, usage today. */
|
|
173
|
+
me(): Promise<Me>;
|
|
174
|
+
readonly creators: {
|
|
175
|
+
/**
|
|
176
|
+
* One page of the available-creators pool, newest checked first.
|
|
177
|
+
* Paginate by passing next_cursor back as cursor.
|
|
178
|
+
*/
|
|
179
|
+
list: (params: {
|
|
180
|
+
country: string;
|
|
181
|
+
limit?: number;
|
|
182
|
+
cursor?: string;
|
|
183
|
+
since?: string | Date;
|
|
184
|
+
includeDiamonds?: boolean;
|
|
185
|
+
}) => Promise<CreatorsPage>;
|
|
186
|
+
/** Discovery volume for a country. */
|
|
187
|
+
stats: (params: {
|
|
188
|
+
country: string;
|
|
189
|
+
}) => Promise<CreatorStats>;
|
|
190
|
+
/**
|
|
191
|
+
* Iterate the whole pool with automatic cursor pagination.
|
|
192
|
+
*
|
|
193
|
+
* for await (const creator of rng.creators.iterate({ country: "RO" })) { … }
|
|
194
|
+
*/
|
|
195
|
+
iterate: (params: {
|
|
196
|
+
country: string;
|
|
197
|
+
since?: string | Date;
|
|
198
|
+
includeDiamonds?: boolean;
|
|
199
|
+
/** Stop after this many creators (default: no limit). */
|
|
200
|
+
maxItems?: number;
|
|
201
|
+
}) => AsyncGenerator<Creator, void, undefined>;
|
|
202
|
+
};
|
|
203
|
+
readonly leagues: {
|
|
204
|
+
/** Division coverage for every country on your plan. */
|
|
205
|
+
list: () => Promise<LeagueCoverage>;
|
|
206
|
+
/** One division's full ranked board (top 99), with recruitability + HOT status. */
|
|
207
|
+
board: (params: {
|
|
208
|
+
country: string;
|
|
209
|
+
division: string;
|
|
210
|
+
}) => Promise<LeagueBoard>;
|
|
211
|
+
/** Only the recruitable creators across a country's league boards. */
|
|
212
|
+
available: (params: {
|
|
213
|
+
country: string;
|
|
214
|
+
division?: string;
|
|
215
|
+
limit?: number;
|
|
216
|
+
offset?: number;
|
|
217
|
+
}) => Promise<LeagueAvailablePage>;
|
|
218
|
+
/** A country's gaming ranking, combined ("all") or per game slug. */
|
|
219
|
+
gaming: (params: {
|
|
220
|
+
country: string;
|
|
221
|
+
game?: string;
|
|
222
|
+
}) => Promise<GamingBoard>;
|
|
223
|
+
/** Which per-game boards exist for a country. */
|
|
224
|
+
games: (params: {
|
|
225
|
+
country: string;
|
|
226
|
+
}) => Promise<{
|
|
227
|
+
country: string;
|
|
228
|
+
games: GamingGame[];
|
|
229
|
+
}>;
|
|
230
|
+
/** The country's daily (hourly for MENA) diamond ranking. */
|
|
231
|
+
daily: (params: {
|
|
232
|
+
country: string;
|
|
233
|
+
}) => Promise<DailyBoard>;
|
|
234
|
+
/** Creators spiking in diamonds right now, across all divisions. */
|
|
235
|
+
hot: (params: {
|
|
236
|
+
country: string;
|
|
237
|
+
}) => Promise<HotCreators>;
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export { type Creator, type CreatorStats, type CreatorsPage, type DailyBoard, type GamingBoard, type GamingGame, type HotCreator, type HotCreators, type LeagueAvailableCreator, type LeagueAvailablePage, type LeagueBoard, type LeagueBoardRow, type LeagueCoverage, type LeagueDivision, type Me, type RankingRow, Rngrow, RngrowError, type RngrowOptions, Rngrow as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var DEFAULT_BASE_URL = "https://rngrow.com/api/v1";
|
|
3
|
+
var RngrowError = class extends Error {
|
|
4
|
+
constructor(code, message, status, retryAfter) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "RngrowError";
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.retryAfter = retryAfter;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var Rngrow = class {
|
|
13
|
+
constructor(apiKey, options = {}) {
|
|
14
|
+
this.creators = {
|
|
15
|
+
/**
|
|
16
|
+
* One page of the available-creators pool, newest checked first.
|
|
17
|
+
* Paginate by passing next_cursor back as cursor.
|
|
18
|
+
*/
|
|
19
|
+
list: (params) => this.request("/creators", {
|
|
20
|
+
country: params.country,
|
|
21
|
+
limit: params.limit,
|
|
22
|
+
cursor: params.cursor,
|
|
23
|
+
since: params.since instanceof Date ? params.since.toISOString() : params.since,
|
|
24
|
+
include_diamonds: params.includeDiamonds ? "true" : void 0
|
|
25
|
+
}),
|
|
26
|
+
/** Discovery volume for a country. */
|
|
27
|
+
stats: (params) => this.request("/creators/stats", { country: params.country }),
|
|
28
|
+
/**
|
|
29
|
+
* Iterate the whole pool with automatic cursor pagination.
|
|
30
|
+
*
|
|
31
|
+
* for await (const creator of rng.creators.iterate({ country: "RO" })) { … }
|
|
32
|
+
*/
|
|
33
|
+
iterate: (params) => {
|
|
34
|
+
const self = this;
|
|
35
|
+
async function* gen() {
|
|
36
|
+
let cursor;
|
|
37
|
+
let yielded = 0;
|
|
38
|
+
for (; ; ) {
|
|
39
|
+
const page = await self.creators.list({
|
|
40
|
+
country: params.country,
|
|
41
|
+
since: params.since,
|
|
42
|
+
includeDiamonds: params.includeDiamonds,
|
|
43
|
+
limit: 200,
|
|
44
|
+
cursor
|
|
45
|
+
});
|
|
46
|
+
for (const c of page.creators) {
|
|
47
|
+
yield c;
|
|
48
|
+
yielded++;
|
|
49
|
+
if (params.maxItems && yielded >= params.maxItems) return;
|
|
50
|
+
}
|
|
51
|
+
if (!page.has_more || !page.next_cursor) return;
|
|
52
|
+
cursor = page.next_cursor;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return gen();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
this.leagues = {
|
|
59
|
+
/** Division coverage for every country on your plan. */
|
|
60
|
+
list: () => this.request("/leagues"),
|
|
61
|
+
/** One division's full ranked board (top 99), with recruitability + HOT status. */
|
|
62
|
+
board: (params) => this.request("/leagues/board", params),
|
|
63
|
+
/** Only the recruitable creators across a country's league boards. */
|
|
64
|
+
available: (params) => this.request("/leagues/available", params),
|
|
65
|
+
/** A country's gaming ranking, combined ("all") or per game slug. */
|
|
66
|
+
gaming: (params) => this.request("/leagues/gaming", params),
|
|
67
|
+
/** Which per-game boards exist for a country. */
|
|
68
|
+
games: (params) => this.request("/leagues/gaming/games", params),
|
|
69
|
+
/** The country's daily (hourly for MENA) diamond ranking. */
|
|
70
|
+
daily: (params) => this.request("/leagues/daily", params),
|
|
71
|
+
/** Creators spiking in diamonds right now, across all divisions. */
|
|
72
|
+
hot: (params) => this.request("/leagues/hot", params)
|
|
73
|
+
};
|
|
74
|
+
if (!apiKey || !apiKey.startsWith("rng_")) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
"Rngrow: an API key starting with rng_ is required. Generate one at https://rngrow.com/dashboard/api"
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
this.apiKey = apiKey;
|
|
80
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
81
|
+
const f = options.fetch ?? globalThis.fetch;
|
|
82
|
+
if (!f) {
|
|
83
|
+
throw new Error("Rngrow: global fetch not found (Node 18+ required) and no fetch option given.");
|
|
84
|
+
}
|
|
85
|
+
this.fetchImpl = f.bind(globalThis);
|
|
86
|
+
}
|
|
87
|
+
async request(path, query = {}) {
|
|
88
|
+
const url = new URL(this.baseUrl + path);
|
|
89
|
+
for (const [k, v] of Object.entries(query)) {
|
|
90
|
+
if (v !== void 0 && v !== null && v !== "") url.searchParams.set(k, String(v));
|
|
91
|
+
}
|
|
92
|
+
const res = await this.fetchImpl(url.toString(), {
|
|
93
|
+
headers: { "X-API-Key": this.apiKey, Accept: "application/json" }
|
|
94
|
+
});
|
|
95
|
+
let body;
|
|
96
|
+
try {
|
|
97
|
+
body = await res.json();
|
|
98
|
+
} catch {
|
|
99
|
+
body = void 0;
|
|
100
|
+
}
|
|
101
|
+
if (!res.ok) {
|
|
102
|
+
const err = body?.error;
|
|
103
|
+
const retryHeader = res.headers.get("Retry-After");
|
|
104
|
+
const retryAfter = retryHeader ? Number(retryHeader) || void 0 : void 0;
|
|
105
|
+
throw new RngrowError(
|
|
106
|
+
err?.code ?? "server_error",
|
|
107
|
+
err?.message ?? `Request failed with HTTP ${res.status}`,
|
|
108
|
+
res.status,
|
|
109
|
+
retryAfter
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
return body;
|
|
113
|
+
}
|
|
114
|
+
/** Key introspection: plan, countries, rate limits, usage today. */
|
|
115
|
+
me() {
|
|
116
|
+
return this.request("/me");
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var index_default = Rngrow;
|
|
120
|
+
export {
|
|
121
|
+
Rngrow,
|
|
122
|
+
RngrowError,
|
|
123
|
+
index_default as default
|
|
124
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rngrow/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official SDK for the RnG TikTok LIVE Creator API (rngrow.com): recruitable TikTok creators, LIVE league boards, gaming and daily rankings, and real-time HOT signals.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tiktok",
|
|
7
|
+
"tiktok-api",
|
|
8
|
+
"tiktok-live",
|
|
9
|
+
"tiktok-creators",
|
|
10
|
+
"creator-data",
|
|
11
|
+
"live-leagues",
|
|
12
|
+
"recruiting",
|
|
13
|
+
"rngrow"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://rngrow.com/api-docs",
|
|
16
|
+
"bugs": { "email": "support@rngrow.com" },
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "RnG - Recruit n' Grow (https://rngrow.com)",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": ["dist", "README.md"],
|
|
31
|
+
"engines": { "node": ">=18" },
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
34
|
+
"prepublishOnly": "npm run build"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"tsup": "^8.2.4",
|
|
38
|
+
"typescript": "^5.5.4"
|
|
39
|
+
}
|
|
40
|
+
}
|