@restless-stream/node 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +93 -1
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -8,7 +8,7 @@ Use this package for server-side Node.js applications. Use `@restless-stream/cor
8
8
 
9
9
  ## Requirements
10
10
 
11
- - Node.js `>=20.19.0`.
11
+ - Node.js `>=24`.
12
12
  - A Restless Stream account and API key.
13
13
 
14
14
  ## Installation
@@ -301,6 +301,98 @@ for await (const event of client.streams.subscribeWs({ wsUrl: session.wsUrl }))
301
301
  | `NodeSseHelperOptions` | Standalone SSE helper options. |
302
302
  | Core exports | Everything exported by `@restless-stream/core` is re-exported. |
303
303
 
304
+ ## Appendix: Creating an API Key
305
+
306
+ API keys authenticate requests to the Restless Stream management API and runtime streams. Keys start with `rs_` followed by a hex string:
307
+
308
+ ```
309
+ rs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
310
+ ```
311
+
312
+ ### Create a key in the dashboard
313
+
314
+ 1. Sign in at [restlessapi.stream](https://restlessapi.stream) and go to **API Keys** in the dashboard.
315
+
316
+ ![API Keys dashboard showing existing keys](docs/api-keys-dashboard.png)
317
+
318
+ 2. Click **Create API Key**, enter a name and optional description, and set an optional expiry date.
319
+
320
+ ![Create API Key modal form](docs/api-keys-create-modal.png)
321
+
322
+ 3. Copy the key immediately — it is shown only once after creation.
323
+
324
+ ```bash
325
+ export RESTLESS_API_KEY="rs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
326
+ ```
327
+
328
+ ### Pass the key to the client
329
+
330
+ ```ts
331
+ import { createNodeRestlessClient } from '@restless-stream/node';
332
+
333
+ const client = createNodeRestlessClient({
334
+ apiKey: process.env.RESTLESS_API_KEY,
335
+ });
336
+ ```
337
+
338
+ ## Sample Responses
339
+
340
+ ### `streams.validateApiKey()`
341
+
342
+ ```ts
343
+ const result = await client.streams.validateApiKey();
344
+ ```
345
+
346
+ **Response:**
347
+
348
+ ```json
349
+ {
350
+ "id": "rs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
351
+ "affected": true
352
+ }
353
+ ```
354
+
355
+ ### `client.direct.subscribeWebSocket()` — live event via WebSocket
356
+
357
+ ```ts
358
+ import { createNodeRestlessClient } from '@restless-stream/node';
359
+
360
+ const client = createNodeRestlessClient({ apiKey: process.env.RESTLESS_API_KEY });
361
+
362
+ for await (const event of client.direct.subscribeWebSocket(
363
+ { url: 'https://httpbin.org/get', method: 'GET', pollingInterval: 15 },
364
+ { reconnect: false },
365
+ )) {
366
+ console.log(event);
367
+ break; // receive one event then stop
368
+ }
369
+ ```
370
+
371
+ **Event received:**
372
+
373
+ ```json
374
+ {
375
+ "type": "update",
376
+ "meta": {
377
+ "timestamp": "2026-06-07T00:51:51.604+00:00",
378
+ "attempt_id": "f73b83fc-be23-4d38-a72d-bd9b0759bbc6",
379
+ "status": 200,
380
+ "latency_ms": 42
381
+ },
382
+ "data": {
383
+ "args": {},
384
+ "headers": {
385
+ "Accept": "*/*",
386
+ "Host": "httpbin.org",
387
+ "User-Agent": "Mozilla/5.0 (compatible; OurInternalService/1.0)",
388
+ "X-Amzn-Trace-Id": "Root=1-6a24c0a7-2d5742db01f24a04641abab9"
389
+ },
390
+ "origin": "140.82.14.127",
391
+ "url": "https://httpbin.org/get"
392
+ }
393
+ }
394
+ ```
395
+
304
396
  ## Development
305
397
 
306
398
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restless-stream/node",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Node.js SDK helpers for Restless Stream.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,13 +39,13 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "ws": "^8.18.0",
42
- "@restless-stream/core": "0.1.1"
42
+ "@restless-stream/core": "0.1.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/ws": "^8.18.1"
46
46
  },
47
47
  "engines": {
48
- "node": ">=20.19.0"
48
+ "node": ">=24"
49
49
  },
50
50
  "sideEffects": false,
51
51
  "scripts": {