@rixl/sdk 0.40.0 → 0.43.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/README.md CHANGED
@@ -15,21 +15,18 @@ Published on npm as [`@rixl/sdk`](https://www.npmjs.com/package/@rixl/sdk).
15
15
  | bun | `bun i @rixl/sdk` |
16
16
  | vite plus | `vp i @rixl/sdk` |
17
17
 
18
- Requires Node.js 18+. ESM only.
18
+ Requires Node.js 24+. ESM only.
19
19
 
20
20
  ## Quick Start
21
21
 
22
22
  ```ts
23
- import {createClient, imagesV1ImageServiceListImages} from "@rixl/sdk";
23
+ import {client, connect, imagesV1ImageServiceListImages} from "@rixl/sdk";
24
24
 
25
- const client = createClient({
26
- baseUrl: "https://api.rixl.com",
27
- auth: process.env.RIXL_API_KEY,
28
- });
25
+ await connect({baseUrl: "https://api.rixl.com"});
26
+ client.setConfig({headers: {"X-API-Key": process.env.RIXL_API_KEY!}});
29
27
 
30
28
  const {data, error} = await imagesV1ImageServiceListImages({
31
- client,
32
- path: {project_id: "your_project_id"},
29
+ path: {project_id: process.env.RIXL_PROJECT_ID!},
33
30
  query: {"pagination.limit": 10},
34
31
  });
35
32
 
@@ -40,24 +37,26 @@ if (error) {
40
37
  }
41
38
  ```
42
39
 
43
- `auth` can be either a string or a function, so you can plug in API keys, bearer tokens, or runtime token refresh logic.
40
+ `connect()` configures every generated request function, so calls don't take a `client` argument. Send server-side API keys in the `X-API-Key` header as shown. Don't use `connect({apiKey})`: the gateway rejects the token it exchanges the key for. Pass `token` to `connect()` to use a bearer token you already hold. Most project-scoped operations need a `project_id`; copy it from the dashboard into `RIXL_PROJECT_ID`.
44
41
 
45
42
  ## Feed API
46
43
 
47
44
  Fetch a feed and read posts:
48
45
 
49
46
  ```ts
50
- import {createClient, postsV1PostServiceListPosts3} from "@rixl/sdk";
47
+ import {connect, postsV1PostServiceListPosts3} from "@rixl/sdk";
51
48
 
52
- const client = createClient({
53
- baseUrl: "https://api.rixl.com",
54
- });
49
+ // Public feeds need no API key.
50
+ await connect({baseUrl: "https://api.rixl.com"});
55
51
 
56
52
  const {data, error} = await postsV1PostServiceListPosts3({
57
- client,
58
53
  path: {feed_id: "FD4y3QB38S"},
59
54
  });
60
55
 
56
+ if (error) {
57
+ console.error("Failed to list posts:", error);
58
+ }
59
+
61
60
  for (const post of data?.posts ?? []) {
62
61
  console.log(post.id, post.creator_id);
63
62
  }
@@ -68,21 +67,17 @@ for (const post of data?.posts ?? []) {
68
67
  List images and fetch one by ID:
69
68
 
70
69
  ```ts
71
- import {createClient, imagesV1ImageServiceGetImage, imagesV1ImageServiceListImages} from "@rixl/sdk";
70
+ import {client, connect, imagesV1ImageServiceGetImage, imagesV1ImageServiceListImages} from "@rixl/sdk";
72
71
 
73
- const client = createClient({
74
- baseUrl: "https://api.rixl.com",
75
- auth: process.env.RIXL_API_KEY,
76
- });
72
+ await connect({baseUrl: "https://api.rixl.com"});
73
+ client.setConfig({headers: {"X-API-Key": process.env.RIXL_API_KEY!}});
77
74
 
78
75
  const list = await imagesV1ImageServiceListImages({
79
- client,
80
- path: {project_id: "your_project_id"},
76
+ path: {project_id: process.env.RIXL_PROJECT_ID!},
81
77
  query: {"pagination.limit": 25},
82
78
  });
83
79
 
84
80
  const image = await imagesV1ImageServiceGetImage({
85
- client,
86
81
  path: {image_id: "PS5IMKoFLm"},
87
82
  });
88
83
 
@@ -92,16 +87,13 @@ console.log(list.data?.images?.length, image.data?.image?.id);
92
87
  Initialize an upload and PUT the bytes to storage:
93
88
 
94
89
  ```ts
95
- import {createClient, imagesV1ImageServiceCreateImageUpload} from "@rixl/sdk";
90
+ import {client, connect, imagesV1ImageServiceCreateImageUpload} from "@rixl/sdk";
96
91
 
97
- const client = createClient({
98
- baseUrl: "https://api.rixl.com",
99
- auth: process.env.RIXL_API_KEY,
100
- });
92
+ await connect({baseUrl: "https://api.rixl.com"});
93
+ client.setConfig({headers: {"X-API-Key": process.env.RIXL_API_KEY!}});
101
94
 
102
95
  const init = await imagesV1ImageServiceCreateImageUpload({
103
- client,
104
- path: {project_id: "your_project_id"},
96
+ path: {project_id: process.env.RIXL_PROJECT_ID!},
105
97
  body: {name: "photo.jpg"},
106
98
  });
107
99
 
@@ -119,40 +111,35 @@ console.log(`Image ${init.data?.image_id} uploaded.`);
119
111
  List videos and fetch one by ID:
120
112
 
121
113
  ```ts
122
- import {createClient, videosV1VideoServiceGetVideo, videosV1VideoServiceListVideos} from "@rixl/sdk";
114
+ import {client, connect, videosV1VideoServiceGetVideo, videosV1VideoServiceListVideos} from "@rixl/sdk";
123
115
 
124
- const client = createClient({
125
- baseUrl: "https://api.rixl.com",
126
- auth: process.env.RIXL_API_KEY,
127
- });
116
+ await connect({baseUrl: "https://api.rixl.com"});
117
+ client.setConfig({headers: {"X-API-Key": process.env.RIXL_API_KEY!}});
128
118
 
129
119
  const page = await videosV1VideoServiceListVideos({
130
- client,
131
- path: {project_id: "your_project_id"},
120
+ path: {project_id: process.env.RIXL_PROJECT_ID!},
132
121
  query: {"pagination.limit": 25},
133
122
  });
134
123
 
135
124
  const video = await videosV1VideoServiceGetVideo({
136
- client,
137
125
  path: {video_id: "VI9VXQxWXQ"},
138
126
  });
139
127
 
140
128
  console.log(page.data?.videos?.length, video.data?.video?.id, video.data?.video?.duration);
141
129
  ```
142
130
 
131
+ To walk every page, advance `pagination.offset` until `offset + videos.length >= total`; see [examples/10-pagination.ts](examples/10-pagination.ts).
132
+
143
133
  Video uploads request presigned URLs for both the video and its poster:
144
134
 
145
135
  ```ts
146
- import {createClient, videosV1VideoServiceCreateVideoUpload} from "@rixl/sdk";
136
+ import {client, connect, videosV1VideoServiceCreateVideoUpload} from "@rixl/sdk";
147
137
 
148
- const client = createClient({
149
- baseUrl: "https://api.rixl.com",
150
- auth: process.env.RIXL_API_KEY,
151
- });
138
+ await connect({baseUrl: "https://api.rixl.com"});
139
+ client.setConfig({headers: {"X-API-Key": process.env.RIXL_API_KEY!}});
152
140
 
153
141
  const init = await videosV1VideoServiceCreateVideoUpload({
154
- client,
155
- path: {project_id: "your_project_id"},
142
+ path: {project_id: process.env.RIXL_PROJECT_ID!},
156
143
  body: {
157
144
  name: "clip.mp4",
158
145
  video_quality: "VIDEO_QUALITY_PRO",
@@ -175,6 +162,18 @@ await Promise.all([
175
162
  console.log(`Video ${init.data?.video_id} uploaded.`);
176
163
  ```
177
164
 
165
+ More runnable scripts live in [examples/](examples/README.md).
166
+
167
+ ## Compatibility
168
+
169
+ `@rixl/sdk` is the supported Rixl SDK. It targets Rixl API **v1** and is generated from [rixlhq/openapi](https://github.com/rixlhq/openapi). While the package is 0.x, a minor release may contain breaking changes; check the [CHANGELOG](CHANGELOG.md) before upgrading.
170
+
171
+ The API contract is documented once, in the Rixl docs:
172
+
173
+ - [Versioning and deprecation](https://docs.rixl.com/en/home/platform/api-documentation/versioning)
174
+ - [Errors, retries and idempotency](https://docs.rixl.com/en/home/platform/api-documentation/error-handling)
175
+ - [Pagination](https://docs.rixl.com/en/home/platform/api-documentation/pagination)
176
+
178
177
  ## Development
179
178
 
180
179
  This repository uses [Vite+](https://viteplus.dev/guide/) as the unified toolchain and package manager wrapper, with Bun underneath.