You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library provides convenient access to the Stainless 2 REST API from server-side TypeScript or JavaScript.
5
+
This library provides convenient access to the Stainless REST API from server-side TypeScript or JavaScript.
6
6
7
7
The REST API documentation can be found on [app.stainlessapi.com](https://app.stainlessapi.com/docs). The full API of this library can be found in [api.md](api.md).
8
8
@@ -23,9 +23,9 @@ The full API of this library can be found in [api.md](api.md).
23
23
24
24
<!-- prettier-ignore -->
25
25
```js
26
-
importStainless2from'stainless';
26
+
importStainlessfrom'stainless';
27
27
28
-
constclient=newStainless2({
28
+
constclient=newStainless({
29
29
apiKey:process.env['API_KEY'], // This is the default and can be omitted
30
30
});
31
31
@@ -44,15 +44,15 @@ This library includes TypeScript definitions for all request params and response
44
44
45
45
<!-- prettier-ignore -->
46
46
```ts
47
-
importStainless2from'stainless';
47
+
importStainlessfrom'stainless';
48
48
49
-
const client =newStainless2({
49
+
const client =newStainless({
50
50
apiKey: process.env['API_KEY'], // This is the default and can be omitted
console.log('About to make a request', url, init);
243
243
const response =awaitfetch(url, init);
@@ -247,17 +247,17 @@ const client = new Stainless2({
247
247
});
248
248
```
249
249
250
-
Note that if given a `STAINLESS_2_LOG=debug` environment variable, this library will log all requests and responses automatically.
250
+
Note that if given a `STAINLESS_LOG=debug` environment variable, this library will log all requests and responses automatically.
251
251
This is intended for debugging purposes only and may change in the future without notice.
252
252
253
253
### Fetch options
254
254
255
255
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
* @param {string} [opts.baseURL=process.env['STAINLESS_2_BASE_URL'] ?? https://api.stainlessapi.com] - Override the default base URL for the API.
156
+
* @param {string} [opts.baseURL=process.env['STAINLESS_BASE_URL'] ?? https://api.stainlessapi.com] - Override the default base URL for the API.
157
157
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
158
158
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
159
159
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
@@ -162,13 +162,13 @@ export class Stainless2 {
162
162
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
163
163
*/
164
164
constructor({
165
-
baseURL =readEnv('STAINLESS_2_BASE_URL'),
165
+
baseURL =readEnv('STAINLESS_BASE_URL'),
166
166
apiKey =readEnv('API_KEY'),
167
167
...opts
168
168
}: ClientOptions={}){
169
169
if(apiKey===undefined){
170
-
thrownewErrors.Stainless2Error(
171
-
"The API_KEY environment variable is missing or empty; either provide it, or instantiate the Stainless2 client with an apiKey option, like new Stainless2({ apiKey: 'My API Key' }).",
170
+
thrownewErrors.StainlessError(
171
+
"The API_KEY environment variable is missing or empty; either provide it, or instantiate the Stainless client with an apiKey option, like new Stainless({ apiKey: 'My API Key' }).",
`Cannot stringify type ${typeofvalue}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
0 commit comments