rozod 6.7.1 → 6.9.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 +1 -1
- package/README.md +75 -451
- package/lib/endpoints/accountinformationv1.d.ts +92 -95
- package/lib/endpoints/accountsettingsv1.d.ts +88 -110
- package/lib/endpoints/adconfigurationv2.d.ts +108 -215
- package/lib/endpoints/assetdeliveryv1.d.ts +267 -230
- package/lib/endpoints/assetdeliveryv1.js +38 -0
- package/lib/endpoints/assetdeliveryv2.d.ts +201 -176
- package/lib/endpoints/assetdeliveryv2.js +26 -0
- package/lib/endpoints/authv1.d.ts +480 -517
- package/lib/endpoints/authv1.js +3 -1
- package/lib/endpoints/authv2.d.ts +210 -222
- package/lib/endpoints/authv2.js +1 -1
- package/lib/endpoints/authv3.d.ts +32 -35
- package/lib/endpoints/avatarv1.d.ts +112 -117
- package/lib/endpoints/avatarv2.d.ts +71 -76
- package/lib/endpoints/avatarv3.d.ts +27 -33
- package/lib/endpoints/badgesv1.d.ts +96 -99
- package/lib/endpoints/badgesv1.js +4 -0
- package/lib/endpoints/catalogv1.d.ts +209 -234
- package/lib/endpoints/catalogv1.js +2 -1
- package/lib/endpoints/catalogv2.d.ts +106 -136
- package/lib/endpoints/catalogv2.js +21 -17
- package/lib/endpoints/chatv2.d.ts +778 -778
- package/lib/endpoints/clientsettingsv1.d.ts +33 -35
- package/lib/endpoints/clientsettingsv2.d.ts +62 -68
- package/lib/endpoints/contactsv1.d.ts +18 -20
- package/lib/endpoints/developv1.d.ts +233 -293
- package/lib/endpoints/developv1.js +3 -0
- package/lib/endpoints/developv2.d.ts +87 -138
- package/lib/endpoints/developv2.js +3 -1
- package/lib/endpoints/economycreatorstatsv1.d.ts +12 -12
- package/lib/endpoints/economyv1.d.ts +6 -6
- package/lib/endpoints/engagementpayoutsv1.d.ts +9 -9
- package/lib/endpoints/followingsv1.d.ts +33 -34
- package/lib/endpoints/followingsv2.d.ts +9 -9
- package/lib/endpoints/friendsv1.d.ts +416 -545
- package/lib/endpoints/friendsv1.js +213 -313
- package/lib/endpoints/gameinternationalizationv1.d.ts +1509 -1642
- package/lib/endpoints/gameinternationalizationv2.d.ts +62 -64
- package/lib/endpoints/gamejoinv1.d.ts +458 -458
- package/lib/endpoints/gamesv1.d.ts +183 -143
- package/lib/endpoints/gamesv1.js +2 -0
- package/lib/endpoints/gamesv2.d.ts +161 -158
- package/lib/endpoints/gamesv2.js +9 -0
- package/lib/endpoints/groupsv1.d.ts +967 -976
- package/lib/endpoints/groupsv1.js +48 -4
- package/lib/endpoints/groupsv2.d.ts +259 -277
- package/lib/endpoints/groupsv2.js +1 -0
- package/lib/endpoints/inventoryv1.d.ts +93 -122
- package/lib/endpoints/inventoryv1.js +3 -1
- package/lib/endpoints/inventoryv2.d.ts +163 -178
- package/lib/endpoints/inventoryv2.js +2 -0
- package/lib/endpoints/itemconfigurationv1.d.ts +33 -40
- package/lib/endpoints/localev1.d.ts +47 -48
- package/lib/endpoints/localizationtablesv1.d.ts +315 -353
- package/lib/endpoints/matchmakingv1.d.ts +184 -190
- package/lib/endpoints/metricsv1.d.ts +88 -88
- package/lib/endpoints/notificationsv2.d.ts +144 -158
- package/lib/endpoints/premiumfeaturesv1.d.ts +14 -14
- package/lib/endpoints/presencev1.d.ts +7 -12
- package/lib/endpoints/privatemessagesv1.d.ts +56 -64
- package/lib/endpoints/publishv1.d.ts +32 -32
- package/lib/endpoints/thumbnailsresizerv1.d.ts +52 -53
- package/lib/endpoints/thumbnailsv1.d.ts +317 -361
- package/lib/endpoints/thumbnailsv1.js +25 -0
- package/lib/endpoints/tradesv1.d.ts +92 -104
- package/lib/endpoints/tradesv2.d.ts +81 -84
- package/lib/endpoints/translationrolesv1.d.ts +46 -51
- package/lib/endpoints/twostepverificationv1.d.ts +233 -237
- package/lib/endpoints/usersv1.d.ts +110 -114
- package/lib/index.d.ts +152 -4
- package/lib/index.js +273 -4
- package/lib/opencloud/v1/asset-permissions.d.ts +1 -1
- package/lib/opencloud/v1/assets.d.ts +9 -9
- package/lib/opencloud/v1/datastores-ordered.d.ts +6 -6
- package/lib/opencloud/v1/datastores.d.ts +8 -8
- package/lib/opencloud/v1/developer-products.d.ts +4 -4
- package/lib/opencloud/v1/game-passes.d.ts +4 -4
- package/lib/opencloud/v1/messaging.d.ts +1 -1
- package/lib/opencloud/v1/open-eval.d.ts +2 -2
- package/lib/opencloud/v1/secrets-store.d.ts +5 -5
- package/lib/opencloud/v1/toolbox.d.ts +2 -2
- package/lib/opencloud/v1/universes.d.ts +1 -1
- package/lib/opencloud/v2/cloud.d.ts +172 -84
- package/lib/opencloud/v2/cloud.js +25 -9
- package/package.json +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,451 +1,75 @@
|
|
|
1
|
-
<h1 align="center" style="height: 200; overflow: 'hidden'">
|
|
2
|
-
<img src="https://github.com/alexop1000/RoZod/assets/46445843/1c2a6cb5-b1d6-4784-b084-0679d81109c3" alt="RoZod" width="400" />
|
|
3
|
-
<br>
|
|
4
|
-
</h1>
|
|
5
|
-
|
|
6
|
-
<h4 align="center">Type-safe Roblox API and OpenCloud client for TypeScript</h4>
|
|
7
|
-
|
|
8
|
-
<p align="center">
|
|
9
|
-
<a href="https://www.npmjs.com/package/rozod"><img alt="npm bundle size" src="https://img.shields.io/bundlephobia/min/rozod?style=for-the-badge"></a>
|
|
10
|
-
<a href="https://www.npmjs.com/package/rozod"><img alt="npm" src="https://img.shields.io/npm/v/rozod?style=for-the-badge"></a>
|
|
11
|
-
<a href="https://www.npmjs.com/package/rozod"><img alt="npm" src="https://img.shields.io/npm/dt/rozod?style=for-the-badge"></a>
|
|
12
|
-
</p>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<a href="
|
|
16
|
-
<a href="
|
|
17
|
-
<a href="
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
##
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
##
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
import { getGamesIcons } from 'rozod/endpoints/thumbnailsv1';
|
|
77
|
-
|
|
78
|
-
const response = await fetchApi(getGamesIcons, { universeIds: [1534453623, 65241] });
|
|
79
|
-
if (!isAnyErrorResponse(response)) {
|
|
80
|
-
console.log(response.data);
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Handle Paginated Responses
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
import { fetchApiPages, isAnyErrorResponse } from 'rozod';
|
|
88
|
-
import { getGroupsGroupidWallPosts } from 'rozod/endpoints/groupsv2';
|
|
89
|
-
|
|
90
|
-
// Automatically fetches all pages
|
|
91
|
-
const pages = await fetchApiPages(getGroupsGroupidWallPosts, { groupId: 11479637 });
|
|
92
|
-
if (!isAnyErrorResponse(pages)) {
|
|
93
|
-
console.log(`Fetched ${pages.length} pages of wall posts`);
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Process Pages One at a Time
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
import { fetchApiPagesGenerator, isAnyErrorResponse } from 'rozod';
|
|
101
|
-
import { getGroupsGroupidWallPosts } from 'rozod/endpoints/groupsv2';
|
|
102
|
-
|
|
103
|
-
// Process pages as they arrive
|
|
104
|
-
const pages = fetchApiPagesGenerator(getGroupsGroupidWallPosts, { groupId: 11479637 });
|
|
105
|
-
for await (const page of pages) {
|
|
106
|
-
if (isAnyErrorResponse(page)) break;
|
|
107
|
-
console.log(`Processing page with ${page.data.length} posts`);
|
|
108
|
-
// Do something with this page
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Batch Processing Large Requests
|
|
113
|
-
|
|
114
|
-
```ts
|
|
115
|
-
import { fetchApiSplit } from 'rozod';
|
|
116
|
-
import { getGamesIcons } from 'rozod/endpoints/thumbnailsv1';
|
|
117
|
-
|
|
118
|
-
// Will automatically split into smaller batches of 100 universeIds per request
|
|
119
|
-
const data = await fetchApiSplit(
|
|
120
|
-
getGamesIcons,
|
|
121
|
-
{ universeIds: [1, 2, 3, 4, 5 /* many more IDs */] },
|
|
122
|
-
{ universeIds: 100 },
|
|
123
|
-
);
|
|
124
|
-
console.log(data);
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Handling Errors
|
|
128
|
-
|
|
129
|
-
By default, requests return either the success type or a simple `AnyError`. Use the tiny helper to check:
|
|
130
|
-
|
|
131
|
-
```ts
|
|
132
|
-
import { fetchApi, isAnyErrorResponse } from 'rozod';
|
|
133
|
-
import { getGamesIcons } from 'rozod/endpoints/thumbnailsv1';
|
|
134
|
-
|
|
135
|
-
const res = await fetchApi(getGamesIcons, { universeIds: [1534453623] });
|
|
136
|
-
if (isAnyErrorResponse(res)) {
|
|
137
|
-
console.error(res.message);
|
|
138
|
-
} else {
|
|
139
|
-
console.log(res.data);
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Prefer a straight try/catch? Enable throwing:
|
|
144
|
-
|
|
145
|
-
```ts
|
|
146
|
-
try {
|
|
147
|
-
const res = await fetchApi(getGamesIcons, { universeIds: [1534453623] }, { throwOnError: true });
|
|
148
|
-
console.log(res.data);
|
|
149
|
-
} catch (err) {
|
|
150
|
-
console.error((err as Error).message);
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Need the raw Response? Use `returnRaw: true`:
|
|
155
|
-
|
|
156
|
-
```ts
|
|
157
|
-
const resp = await fetchApi(getGamesIcons, { universeIds: [1534453623] }, { returnRaw: true });
|
|
158
|
-
const json = await resp.json();
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## OpenCloud
|
|
162
|
-
|
|
163
|
-
RoZod supports Roblox's newer OpenCloud APIs with the same easy interface:
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
import { fetchApi, isAnyErrorResponse } from 'rozod';
|
|
167
|
-
import { v2 } from 'rozod/opencloud';
|
|
168
|
-
|
|
169
|
-
// Get universe details through OpenCloud
|
|
170
|
-
const universeInfo = await fetchApi(v2.getCloudV2UniversesUniverseId, {
|
|
171
|
-
universe_id: '123456789',
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
if (!isAnyErrorResponse(universeInfo)) {
|
|
175
|
-
// Access typed properties
|
|
176
|
-
console.log(universeInfo.displayName);
|
|
177
|
-
console.log(universeInfo.description);
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Access DataStores via OpenCloud
|
|
182
|
-
|
|
183
|
-
```ts
|
|
184
|
-
import { fetchApi } from 'rozod';
|
|
185
|
-
import { getCloudV2UniversesUniverseIdDataStoresDataStoreIdEntries } from 'rozod/opencloud/v2/cloud';
|
|
186
|
-
|
|
187
|
-
// Get DataStore entries with type safety
|
|
188
|
-
const dataStoreEntries = await fetchApi(getCloudV2UniversesUniverseIdDataStoresDataStoreIdEntries, {
|
|
189
|
-
universe_id: '123456789',
|
|
190
|
-
data_store_id: 'MyStore',
|
|
191
|
-
});
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Authentication
|
|
195
|
-
|
|
196
|
-
RoZod handles Roblox authentication automatically with comprehensive security features:
|
|
197
|
-
|
|
198
|
-
### Browser Environments
|
|
199
|
-
|
|
200
|
-
In browsers, authentication works automatically when users are logged into Roblox:
|
|
201
|
-
|
|
202
|
-
```ts
|
|
203
|
-
import { fetchApi } from 'rozod';
|
|
204
|
-
import { getUsersUserid } from 'rozod/endpoints/usersv1';
|
|
205
|
-
|
|
206
|
-
// Cookies are sent automatically - no setup required!
|
|
207
|
-
const userInfo = await fetchApi(getUsersUserid, { userId: 123456 });
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Server Environments (Node.js/Bun/Deno)
|
|
211
|
-
|
|
212
|
-
For server environments, use `configureServer()` to set up authentication once:
|
|
213
|
-
|
|
214
|
-
```ts
|
|
215
|
-
import { configureServer, fetchApi } from 'rozod';
|
|
216
|
-
import { getUsersUserid } from 'rozod/endpoints/usersv1';
|
|
217
|
-
|
|
218
|
-
// Configure once at startup
|
|
219
|
-
configureServer({ cookies: 'your_roblosecurity_cookie_here' });
|
|
220
|
-
|
|
221
|
-
// All subsequent requests automatically include the cookie
|
|
222
|
-
const userInfo = await fetchApi(getUsersUserid, { userId: 123456 });
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
#### Multiple Accounts (Cookie Pool)
|
|
226
|
-
|
|
227
|
-
Use multiple Roblox accounts for load distribution or fallback:
|
|
228
|
-
|
|
229
|
-
```ts
|
|
230
|
-
import { configureServer } from 'rozod';
|
|
231
|
-
|
|
232
|
-
// Multiple accounts with round-robin rotation (default)
|
|
233
|
-
configureServer({
|
|
234
|
-
cookies: [
|
|
235
|
-
'account1_roblosecurity_cookie',
|
|
236
|
-
'account2_roblosecurity_cookie',
|
|
237
|
-
'account3_roblosecurity_cookie',
|
|
238
|
-
],
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// Requests automatically cycle through accounts: 1 → 2 → 3 → 1 → 2 → ...
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
#### Rotation Modes
|
|
245
|
-
|
|
246
|
-
Control how cookies and user agents are selected:
|
|
247
|
-
|
|
248
|
-
```ts
|
|
249
|
-
import { configureServer } from 'rozod';
|
|
250
|
-
|
|
251
|
-
configureServer({
|
|
252
|
-
cookies: ['cookie1', 'cookie2', 'cookie3'],
|
|
253
|
-
cookieRotation: 'round-robin', // Cycle sequentially (default for multiple)
|
|
254
|
-
// cookieRotation: 'random', // Pick randomly per request
|
|
255
|
-
// cookieRotation: 'none', // Always use first cookie
|
|
256
|
-
|
|
257
|
-
userAgents: ['CustomBot/1.0', 'CustomBot/2.0'], // Optional custom UAs
|
|
258
|
-
userAgentRotation: 'none', // Consistent per session (default)
|
|
259
|
-
// userAgentRotation: 'random',
|
|
260
|
-
// userAgentRotation: 'round-robin',
|
|
261
|
-
});
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
#### User Agent Pool
|
|
265
|
-
|
|
266
|
-
RoZod includes built-in browser user agents applied automatically in server environments. Customize or disable:
|
|
267
|
-
|
|
268
|
-
```ts
|
|
269
|
-
// Use custom user agents
|
|
270
|
-
configureServer({
|
|
271
|
-
cookies: '...',
|
|
272
|
-
userAgents: ['MyBot/1.0', 'MyService/2.0'],
|
|
273
|
-
userAgentRotation: 'round-robin',
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// Disable user agent injection
|
|
277
|
-
configureServer({ cookies: '...', userAgents: [] });
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
#### OpenCloud API Key
|
|
281
|
-
|
|
282
|
-
For OpenCloud endpoints (`apis.roblox.com`), set your API key once:
|
|
283
|
-
|
|
284
|
-
```ts
|
|
285
|
-
import { configureServer, fetchApi } from 'rozod';
|
|
286
|
-
import { v2 } from 'rozod/opencloud';
|
|
287
|
-
|
|
288
|
-
// Configure OpenCloud API key
|
|
289
|
-
configureServer({ cloudKey: 'your_opencloud_api_key_here' });
|
|
290
|
-
|
|
291
|
-
// All OpenCloud requests automatically include x-api-key header
|
|
292
|
-
const universeInfo = await fetchApi(v2.getCloudV2UniversesUniverseId, {
|
|
293
|
-
universe_id: '123456789',
|
|
294
|
-
});
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
You can configure both classic API cookies and OpenCloud keys together:
|
|
298
|
-
|
|
299
|
-
```ts
|
|
300
|
-
configureServer({
|
|
301
|
-
cookies: ['account1', 'account2'], // For classic *.roblox.com APIs
|
|
302
|
-
cloudKey: 'your_opencloud_key', // For apis.roblox.com
|
|
303
|
-
});
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
> **Note:** The API key is only applied to OpenCloud endpoints (URLs containing `/cloud/`). Cookies are applied to all other Roblox APIs, including undocumented cookie-based APIs on `apis.roblox.com`.
|
|
307
|
-
|
|
308
|
-
#### Configuration Management
|
|
309
|
-
|
|
310
|
-
```ts
|
|
311
|
-
import { configureServer, clearServerConfig, getServerConfig } from 'rozod';
|
|
312
|
-
|
|
313
|
-
// Check current configuration
|
|
314
|
-
const config = getServerConfig();
|
|
315
|
-
console.log(config.cookies, config.cloudKey);
|
|
316
|
-
|
|
317
|
-
// Clear all server configuration
|
|
318
|
-
clearServerConfig();
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
#### Manual Headers (Legacy)
|
|
322
|
-
|
|
323
|
-
You can still pass headers manually per-request if needed:
|
|
324
|
-
|
|
325
|
-
```ts
|
|
326
|
-
const userInfo = await fetchApi(
|
|
327
|
-
getUsersUserid,
|
|
328
|
-
{ userId: 123456 },
|
|
329
|
-
{
|
|
330
|
-
headers: {
|
|
331
|
-
'Cookie': '.ROBLOSECURITY=your_cookie_here'
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
);
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
> **Note:** Manual headers take precedence over `configureServer()` defaults.
|
|
338
|
-
|
|
339
|
-
### Security Features
|
|
340
|
-
|
|
341
|
-
RoZod automatically handles advanced Roblox security requirements:
|
|
342
|
-
|
|
343
|
-
- **✅ XCSRF Token Management** - Automatic CSRF token retrieval and caching
|
|
344
|
-
- **✅ Hardware-Backed Authentication** - Full HBA signature support
|
|
345
|
-
- **✅ Challenge Handling** - Captchas, 2FA, and other authentication challenges
|
|
346
|
-
- **✅ Cookie Security** - Secure cookie parsing and validation
|
|
347
|
-
- **✅ Cookie Rotation** - Automatic handling of Roblox's cookie rotation
|
|
348
|
-
|
|
349
|
-
### Cookie Rotation Handling
|
|
350
|
-
|
|
351
|
-
Roblox is gradually implementing `.ROBLOSECURITY` cookie rotation for improved security. RoZod automatically detects when cookies are rotated and can notify you to persist the new values:
|
|
352
|
-
|
|
353
|
-
```ts
|
|
354
|
-
import { configureServer, refreshCookie, getCookies } from 'rozod';
|
|
355
|
-
|
|
356
|
-
configureServer({
|
|
357
|
-
cookies: process.env.ROBLOX_COOKIE,
|
|
358
|
-
onCookieRefresh: async ({ oldCookie, newCookie, poolIndex }) => {
|
|
359
|
-
// Roblox rotated the cookie - persist the new value
|
|
360
|
-
await db.updateCookie(poolIndex, newCookie);
|
|
361
|
-
console.log('Cookie rotated and saved!');
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
The internal cookie pool updates automatically, so the callback is only needed if you want to persist cookies across restarts.
|
|
367
|
-
|
|
368
|
-
You can also proactively refresh cookies before they expire:
|
|
369
|
-
|
|
370
|
-
```ts
|
|
371
|
-
// Refresh on a schedule or before important operations
|
|
372
|
-
const result = await refreshCookie(0);
|
|
373
|
-
if (result.success) {
|
|
374
|
-
await db.updateCookie(0, result.newCookie);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Utility functions
|
|
378
|
-
const allCookies = getCookies(); // Get current cookie values
|
|
379
|
-
updateCookie(0, 'new_value'); // Manually update a cookie
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
### Challenge Handling
|
|
383
|
-
|
|
384
|
-
For advanced authentication challenges (captchas, 2FA), set up a global challenge handler:
|
|
385
|
-
|
|
386
|
-
```ts
|
|
387
|
-
import { setHandleGenericChallenge } from 'rozod';
|
|
388
|
-
|
|
389
|
-
setHandleGenericChallenge(async (challenge) => {
|
|
390
|
-
// Handle captcha, 2FA, or other challenges
|
|
391
|
-
// Return the challenge response or undefined to skip
|
|
392
|
-
if (challenge.challengeType === 'captcha') {
|
|
393
|
-
const solution = await solveCaptcha(challenge.challengeId);
|
|
394
|
-
return {
|
|
395
|
-
challengeType: challenge.challengeType,
|
|
396
|
-
challengeId: challenge.challengeId,
|
|
397
|
-
challengeBase64Metadata: solution
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
### Hardware-Backed Authentication (Advanced)
|
|
404
|
-
|
|
405
|
-
For Node.js environments requiring custom HBA keys:
|
|
406
|
-
|
|
407
|
-
```ts
|
|
408
|
-
import { changeHBAKeys } from 'rozod';
|
|
409
|
-
|
|
410
|
-
// Provide your own crypto key pair for HBA signatures
|
|
411
|
-
const keyPair = await crypto.subtle.generateKey(
|
|
412
|
-
{ name: 'ECDSA', namedCurve: 'P-256' },
|
|
413
|
-
true,
|
|
414
|
-
['sign', 'verify']
|
|
415
|
-
);
|
|
416
|
-
|
|
417
|
-
changeHBAKeys(keyPair);
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
## Custom Endpoints
|
|
421
|
-
|
|
422
|
-
You can define custom endpoints for your specific needs:
|
|
423
|
-
|
|
424
|
-
```ts
|
|
425
|
-
import { z } from 'zod';
|
|
426
|
-
import { endpoint, fetchApi } from 'rozod';
|
|
427
|
-
|
|
428
|
-
const myCustomEndpoint = endpoint({
|
|
429
|
-
method: 'GET',
|
|
430
|
-
path: '/v1/custom/:customId',
|
|
431
|
-
baseUrl: 'https://my-api.example.com',
|
|
432
|
-
parameters: {
|
|
433
|
-
customId: z.string(),
|
|
434
|
-
optional: z.string().optional(),
|
|
435
|
-
},
|
|
436
|
-
response: z.object({
|
|
437
|
-
success: z.boolean(),
|
|
438
|
-
data: z.array(z.string()),
|
|
439
|
-
}),
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
const response = await fetchApi(myCustomEndpoint, { customId: '123' });
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
## Credits
|
|
446
|
-
|
|
447
|
-
This repository is maintained by Alrovi ApS, the company behind RoGold.
|
|
448
|
-
|
|
449
|
-
## Disclaimer
|
|
450
|
-
|
|
451
|
-
RoZod is not affiliated with, maintained, authorized, endorsed, or sponsored by Roblox Corporation or any of its affiliates.
|
|
1
|
+
<h1 align="center" style="height: 200; overflow: 'hidden'">
|
|
2
|
+
<img src="https://github.com/alexop1000/RoZod/assets/46445843/1c2a6cb5-b1d6-4784-b084-0679d81109c3" alt="RoZod" width="400" />
|
|
3
|
+
<br>
|
|
4
|
+
</h1>
|
|
5
|
+
|
|
6
|
+
<h4 align="center">Type-safe Roblox API and OpenCloud client for TypeScript</h4>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://www.npmjs.com/package/rozod"><img alt="npm bundle size" src="https://img.shields.io/bundlephobia/min/rozod?style=for-the-badge"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/rozod"><img alt="npm" src="https://img.shields.io/npm/v/rozod?style=for-the-badge"></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/rozod"><img alt="npm" src="https://img.shields.io/npm/dt/rozod?style=for-the-badge"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://rozod.alrovi.com">Documentation</a> •
|
|
16
|
+
<a href="https://rozod.alrovi.com/getting-started/quick-start/">Quick Start</a> •
|
|
17
|
+
<a href="https://rozod.alrovi.com/reference/core-api/">API Reference</a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
RoZod makes working with Roblox APIs simple and type-safe. **695+ classic web API endpoints** and **115+ OpenCloud endpoints**, all code-generated from official Roblox documentation, with authentication, CSRF tokens, cookie rotation, pagination, batching, and error parsing handled for you.
|
|
23
|
+
|
|
24
|
+
Works in Node.js, Bun, Deno, browsers, and browser extensions. Battle-tested in [RoGold](https://rogold.live), serving 800,000+ users with millions of API requests daily.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install rozod
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { fetchApi, isAnyErrorResponse } from 'rozod';
|
|
36
|
+
import { getUsersUserid } from 'rozod/endpoints/usersv1';
|
|
37
|
+
|
|
38
|
+
const user = await fetchApi(getUsersUserid, { userId: 1 });
|
|
39
|
+
if (!isAnyErrorResponse(user)) {
|
|
40
|
+
console.log(user.displayName); // fully typed!
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
On a server, configure authentication once and every request uses it:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { configureServer } from 'rozod';
|
|
48
|
+
|
|
49
|
+
configureServer({
|
|
50
|
+
cookies: process.env.ROBLOX_COOKIE, // classic *.roblox.com APIs
|
|
51
|
+
cloudKey: process.env.ROBLOX_CLOUD_KEY, // OpenCloud APIs
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
Full guides and reference at **[rozod.alrovi.com](https://rozod.alrovi.com)**:
|
|
58
|
+
|
|
59
|
+
- [Installation & Setup](https://rozod.alrovi.com/getting-started/installation/)
|
|
60
|
+
- [Authentication](https://rozod.alrovi.com/guides/authentication/) — cookie pools, rotation, OpenCloud keys, challenges
|
|
61
|
+
- [Error Handling](https://rozod.alrovi.com/guides/error-handling/)
|
|
62
|
+
- [Pagination](https://rozod.alrovi.com/guides/pagination/) & [Batch Requests](https://rozod.alrovi.com/guides/batch-requests/)
|
|
63
|
+
- [Caching](https://rozod.alrovi.com/guides/caching/)
|
|
64
|
+
- [OpenCloud](https://rozod.alrovi.com/guides/opencloud/) & [Long-Running Operations](https://rozod.alrovi.com/guides/long-running-operations/)
|
|
65
|
+
- [Custom Endpoints](https://rozod.alrovi.com/guides/custom-endpoints/)
|
|
66
|
+
- [Core API Reference](https://rozod.alrovi.com/reference/core-api/) — every exported function and type
|
|
67
|
+
- [Coming from noblox.js?](https://rozod.alrovi.com/getting-started/migration-from-nobloxjs/)
|
|
68
|
+
|
|
69
|
+
## Credits
|
|
70
|
+
|
|
71
|
+
Maintained by Alrovi ApS, the company behind RoGold.
|
|
72
|
+
|
|
73
|
+
## Disclaimer
|
|
74
|
+
|
|
75
|
+
RoZod is not affiliated with, maintained, authorized, endorsed, or sponsored by Roblox Corporation or any of its affiliates.
|