Skip to content

Commit 92281aa

Browse files
committed
Add Advanced Usage to README
1 parent d6d175b commit 92281aa

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,67 @@ const seam = SeamHttp.fromConsoleSessionToken(
166166
)
167167
```
168168

169+
### Advanced Usage
170+
171+
In addition the various authentication options,
172+
the constructor takes some additional options that affect behavior.
173+
174+
```ts
175+
const seam = new SeamHttp({
176+
apiKey: 'your-api-key',
177+
endpoint: 'https://example.com',
178+
axiosOptions: {},
179+
axiosRetryOptions: {},
180+
})
181+
```
182+
183+
When using the static factory methods,
184+
these options may be passed in as the last argument.
185+
186+
```ts
187+
const seam = SeamHttp.fromApiKey('some-api-key', {
188+
endpoint: 'https://example.com',
189+
axiosOptions: {},
190+
axiosRetryOptions: {},
191+
})
192+
```
193+
194+
#### Setting the endpoint
195+
196+
Some contexts may need to override the API endpoint,
197+
e.g., testing or proxy setup.
198+
This option corresponds to the setting Axios `baseURL`.
199+
200+
Either pass the `endpoint` option, or set the `SEAM_ENDPOINT` environment variable.
201+
202+
#### Configuring the Axios Client
203+
204+
The Axios client and retry behavior may be configured with custom initiation options
205+
via `axiosOptions` and `axiosRetryOptions`.
206+
Options are deep merged with the default options.
207+
208+
#### Using the Axios Client
209+
210+
The Axios client is exposed and may be used or configured directly:
211+
212+
```ts
213+
import { SeamHttp, DevicesListResponse } from '@seamapi/http'
214+
215+
const seam = new SeamHttp()
216+
217+
seam.client.interceptors.response.use((response) => {
218+
console.log(response)
219+
return response
220+
})
221+
222+
const devices = await seam.client.get<DevicesListResponse>('/devices/list')
223+
```
224+
225+
#### Overriding the Client
226+
227+
An Axios compatible client may be provided to create a `SeamHttp` instance.
228+
This API is used internally and is not directly supported.
229+
169230
## Development and Testing
170231

171232
### Quickstart

0 commit comments

Comments
 (0)