{"id":24764507,"url":"https://github.com/seamapi/javascript-http","last_synced_at":"2026-04-08T08:02:35.388Z","repository":{"id":193386101,"uuid":"688698056","full_name":"seamapi/javascript-http","owner":"seamapi","description":"JavaScript HTTP client for the Seam API written in TypeScript.","archived":false,"fork":false,"pushed_at":"2026-03-31T06:36:18.000Z","size":3652,"stargazers_count":1,"open_issues_count":11,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-31T08:43:22.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://javascript-http.seam.vc","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seamapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-09-07T23:11:34.000Z","updated_at":"2026-03-31T06:36:22.000Z","dependencies_parsed_at":"2023-09-08T01:00:46.337Z","dependency_job_id":"96a3a867-dfb3-4227-9015-e4cd7ff8c951","html_url":"https://github.com/seamapi/javascript-http","commit_stats":null,"previous_names":["seamapi/javascript-http"],"tags_count":191,"template":false,"template_full_name":null,"purl":"pkg:github/seamapi/javascript-http","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Fjavascript-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Fjavascript-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Fjavascript-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Fjavascript-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seamapi","download_url":"https://codeload.github.com/seamapi/javascript-http/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Fjavascript-http/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31545909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"online","status_checked_at":"2026-04-08T02:00:06.127Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-28T22:32:00.727Z","updated_at":"2026-04-08T08:02:35.382Z","avatar_url":"https://github.com/seamapi.png","language":"TypeScript","readme":"# Seam HTTP Client\n\n[![npm](https://img.shields.io/npm/v/@seamapi/http.svg)](https://www.npmjs.com/package/@seamapi/http)\n[![Seam LTS Version](https://img.shields.io/badge/Seam_LTS-1.0.0-blue)](https://docs.seam.co/lts)\n[![GitHub Actions](https://github.com/seamapi/javascript-http/actions/workflows/check.yml/badge.svg)](https://github.com/seamapi/javascript-http/actions/workflows/check.yml)\n\nJavaScript HTTP client for the Seam API written in TypeScript.\n\n## Description\n\n[Seam] makes it easy to integrate IoT devices with your applications.\nThis is an official SDK for the Seam API.\nPlease refer to the official [Seam Docs] to get started.\n\nParts of this SDK are generated from always up-to-date type information\nprovided by [@seamapi/types].\nThis ensures all API methods, request shapes, and response shapes are\naccurate and fully typed.\n\nThe SDK contains minimal dependencies, is fully tree-shakeable,\nand optimized for use in both client and server applications.\nThe underlying HTTP client is [Axios].\n\n[Seam]: https://www.seam.co/\n[Seam Docs]: https://docs.seam.co/latest/\n[@seamapi/types]: https://github.com/seamapi/types/\n[Axios]: https://axios-http.com/\n\n## Installation\n\n\u003e [!IMPORTANT]\n\u003e This is a low-level package meant for applications and libraries with particular dependency requirements.\n\u003e Before using this package, ensure you understand the installation and updating instructions.\n\u003e This SDK is entirely contained in the [seam package].\n\u003e Seam recommends using that package instead for simpler dependency management.\n\nAdd this as a dependency to your project using [npm] with\n\n```\n$ npm install @seamapi/http\n```\n\n[npm]: https://www.npmjs.com/\n[seam package]: https://www.npmjs.com/package/seam\n\n### Optional Peer Dependencies for TypeScript\n\nThis package has optional peer dependencies for TypeScript users.\nRecent versions of npm will automatically install peer dependencies by default.\nFor those users, no additional steps are necessary for full TypeScript support,\nhowever users should still explicitly install the latest types (see the next section).\n\nOther package managers require peer dependencies to be added manually.\nRefer to any warnings generated by your package manager\nabout missing peer dependencies and install them as needed.\nRefer to the next section for keeping the types updated.\n\n#### Keeping up with the latest types\n\nThis package depends on [@seamapi/types] for the latest TypeScript types.\nNew versions of this SDK are generally not released when new types are published.\nUnless your project frequently runs a blanket `npm update`,\nthe types will become outdated with the Seam API over time.\nThus, users of this package should explicitly install the types with\n\n```\n$ npm install -D @seamapi/types\n```\n\nand update them when consuming new API features with\n\n```\n$ npm install -D @seamapi/types@latest\n```\n\n## Usage\n\n### Examples\n\n\u003e [!NOTE]\n\u003e These examples assume `SEAM_API_KEY` is set in your environment.\n\n#### List devices\n\n```ts\nimport { SeamHttp } from '@seamapi/http'\n\nconst seam = new SeamHttp()\nconst devices = await seam.devices.list()\n```\n\n#### Unlock a door\n\n```ts\nimport { SeamHttp } from '@seamapi/http'\n\nconst seam = new SeamHttp()\nconst lock = await seam.locks.get({ name: 'Front Door' })\nawait seam.locks.unlockDoor({ device_id: lock.device_id })\n```\n\n### Authentication Methods\n\nThe SDK supports several authentication mechanisms.\nAuthentication may be configured by passing the corresponding\noptions directly to the `SeamHttp` constructor,\nor with the more ergonomic static factory methods.\n\n\u003e [!NOTE]\n\u003e Publishable Key authentication is not supported by the constructor\n\u003e and must be configured using `SeamHttp.fromPublishableKey`.\n\n#### API Key\n\nAn API key is scoped to a single workspace and should only be used on the server.\nObtain one from the Seam Console.\n\n```ts\n// Set the `SEAM_API_KEY` environment variable\nconst seam = new SeamHttp()\n\n// Pass as the first argument to the constructor\nconst seam = new SeamHttp('your-api-key')\n\n// Pass as an option to the constructor\nconst seam = new SeamHttp({ apiKey: 'your-api-key' })\n\n// Use the factory method\nconst seam = SeamHttp.fromApiKey('your-api-key')\n```\n\n#### Client Session Token\n\nA Client Session Token is scoped to a client session and should only be used on the client.\n\n```ts\n// Pass as an option to the constructor\nconst seam = new SeamHttp({ clientSessionToken: 'some-client-session-token' })\n\n// Use the factory method\nconst seam = SeamHttp.fromClientSessionToken('some-client-session-token')\n```\n\nThe client session token may be updated using\n\n```ts\nconst seam = SeamHttp.fromClientSessionToken('some-client-session-token')\n\nawait seam.updateClientSessionToken('some-new-client-session-token')\n```\n\n#### Publishable Key\n\nA Publishable Key is used by the client to acquire Client Session Token for a workspace.\nObtain one from the Seam Console.\n\nUse the async factory method to return a client authenticated with a client session token:\n\n```ts\nconst seam = await SeamHttp.fromPublishableKey(\n  'your-publishable-key',\n  'some-user-identifier-key',\n)\n```\n\nThis will get an existing client session matching the user identifier key,\nor create a new empty client session.\n\n#### Personal Access Token\n\nA Personal Access Token is scoped to a Seam Console user.\nObtain one from the Seam Console.\nA workspace ID must be provided when using this method\nand all requests will be scoped to that workspace.\n\n```ts\n// Set the `SEAM_PERSONAL_ACCESS_TOKEN` and `SEAM_WORKSPACE_ID` environment variables\nconst seam = new SeamHttp()\n\n// Pass as an option to the constructor\nconst seam = new SeamHttp({\n  personalAccessToken: 'your-personal-access-token',\n  workspaceId: 'your-workspace-id',\n})\n\n// Use the factory method\nconst seam = SeamHttp.fromPersonalAccessToken(\n  'some-console-session-token',\n  'your-workspace-id',\n)\n```\n\n#### Console Session Token\n\nA Console Session Token is used by the Seam Console.\nThis authentication method is only used by internal Seam applications.\nA workspace ID must be provided when using this method\nand all requests will be scoped to that workspace.\n\n```ts\n// Pass as an option to the constructor\nconst seam = new SeamHttp({\n  consoleSessionToken: 'some-console-session-token',\n  workspaceId: 'your-workspace-id',\n})\n\n// Use the factory method\nconst seam = SeamHttp.fromConsoleSessionToken(\n  'some-console-session-token',\n  'your-workspace-id',\n)\n```\n\n### Action Attempts\n\nSome asynchronous operations, e.g., unlocking a door, return an [action attempt].\nSeam tracks the progress of the requested operation and updates the action attempt\nwhen it succeeds or fails.\n\nTo make working with action attempts more convenient for applications,\nthis library provides the `waitForActionAttempt` option and enables it by default.\n\nWhen the `waitForActionAttempt` option is enabled, the SDK:\n\n- Polls the action attempt up to the `timeout`\n  at the `pollingInterval` (both in milliseconds).\n- Resolves with a fresh copy of the successful action attempt.\n- Rejects with a `SeamActionAttemptFailedError` if the action attempt is unsuccessful.\n- Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached.\n- Both errors expose an `actionAttempt` property.\n\nIf you already have an action attempt ID\nand want to wait for it to resolve, simply use\n\n```ts\nawait seam.actionAttempts.get({ action_attempt_id })\n```\n\nOr, to get the current state of an action attempt by ID without waiting:\n\n```ts\nawait seam.actionAttempts.get(\n  { action_attempt_id },\n  {\n    waitForActionAttempt: false,\n  },\n)\n```\n\nTo disable this behavior, set the default option for the client:\n\n```ts\nconst seam = new SeamHttp({\n  apiKey: 'your-api-key',\n  waitForActionAttempt: false,\n})\n\nawait seam.locks.unlockDoor({ device_id })\n```\n\nor the behavior may be configured per-request:\n\n```ts\nawait seam.locks.unlockDoor(\n  { device_id },\n  {\n    waitForActionAttempt: false,\n  },\n)\n```\n\nThe `pollingInterval` and `timeout` may be configured for the client or per-request.\nFor example:\n\n```ts\nimport {\n  SeamHttp,\n  isSeamActionAttemptFailedError,\n  isSeamActionAttemptTimeoutError,\n} from '@seamapi/http'\n\nconst seam = new SeamHttp('your-api-key', {\n  waitForActionAttempt: {\n    pollingInterval: 1000,\n    timeout: 5000,\n  },\n})\n\nconst [lock] = await seam.locks.list()\n\nif (lock == null) throw new Error('No locks in this workspace')\n\ntry {\n  await seam.locks.unlockDoor({ device_id: lock.device_id })\n  console.log('Door unlocked')\n} catch (err: unknown) {\n  if (isSeamActionAttemptFailedError(err)) {\n    console.log('Could not unlock the door')\n    return\n  }\n\n  if (isSeamActionAttemptTimeoutError(err)) {\n    console.log('Door took too long to unlock')\n    return\n  }\n\n  throw err\n}\n```\n\n[action attempt]: https://docs.seam.co/latest/core-concepts/action-attempts\n\n### Pagination\n\nSome Seam API endpoints that return lists of resources support pagination.\nUse the `SeamPaginator` class to fetch and process resources across multiple pages.\n\n#### Manually fetch pages with the nextPageCursor\n\n```ts\nconst pages = seam.createPaginator(\n  seam.devices.list({\n    limit: 20,\n  }),\n)\n\nconst [devices, { hasNextPage, nextPageCursor }] = await pages.firstPage()\n\nif (hasNextPage) {\n  const [moreDevices] = await pages.nextPage(nextPageCursor)\n}\n```\n\n#### Resume pagination\n\nGet the first page on initial load:\n\n```ts\nconst params = { limit: 20 }\n\nconst pages = seam.createPaginator(seam.devices.list(params))\n\nconst [devices, pagination] = await pages.firstPage()\n\nlocalStorage.setItem('/seam/devices/list', JSON.stringify([params, pagination]))\n```\n\nGet the next page at a later time:\n\n```ts\nconst [params = {}, { hasNextPage = false, nextPageCursor = null } = {}] =\n  JSON.parse(localStorage.getItem('/seam/devices/list') ?? '[]')\n\nif (hasNextPage) {\n  const pages = seam.createPaginator(seam.devices.list(params))\n  const [moreDevices] = await pages.nextPage(nextPageCursor)\n}\n```\n\n#### Iterate over all pages\n\n```ts\nconst pages = seam.createPaginator(\n  seam.devices.list({\n    limit: 20,\n  }),\n)\n\nfor await (const devices of pages) {\n  console.log(`There are ${devices.length} devices on this page.`)\n}\n```\n\n#### Iterate over all resources\n\n```ts\nconst pages = seam.createPaginator(\n  seam.devices.list({\n    limit: 20,\n  }),\n)\n\nfor await (const device of pages.flatten()) {\n  console.log(devices.name)\n}\n```\n\n#### Return all resources across all pages as an array\n\n```ts\nconst pages = seam.createPaginator(\n  seam.devices.list({\n    limit: 20,\n  }),\n)\n\nconst devices = await pages.flattenToArray()\n```\n\n### Requests without a Workspace in scope\n\nSome Seam API endpoints do not require a workspace in scope.\nThe `SeamHttpWithoutWorkspace` client is not bound to a specific workspace\nand may use those endpoints with an appropriate authentication method.\n\n#### Personal Access Token\n\nA Personal Access Token is scoped to a Seam Console user.\nObtain one from the Seam Console.\n\n```ts\n// Set the `SEAM_PERSONAL_ACCESS_TOKEN` environment variable\nconst seam = new SeamHttpWithoutWorkspace()\n\n// Pass as an option to the constructor\nconst seam = new SeamHttpWithoutWorkspace({\n  personalAccessToken: 'your-personal-access-token',\n})\n\n// Use the factory method\nconst seam = SeamHttpWithoutWorkspace.fromPersonalAccessToken(\n  'some-console-session-token',\n)\n\n// List workspaces authorized for this Personal Access Token\nconst workspaces = await seam.workspaces.list()\n```\n\n#### Console Session Token\n\nA Console Session Token is used by the Seam Console.\nThis authentication method is only used by internal Seam applications.\n\n```ts\n// Pass as an option to the constructor\nconst seam = new SeamHttpWithoutWorkspace({\n  consoleSessionToken: 'some-console-session-token',\n})\n\n// Use the factory method\nconst seam = SeamHttpWithoutWorkspace.fromConsoleSessionToken(\n  'some-console-session-token',\n)\n\n// List workspaces authorized for this Seam Console user\nconst workspaces = await seam.workspaces.list()\n```\n\n### Advanced Usage\n\n#### Additional Options\n\nIn addition to the various authentication options,\nthe constructor takes some advanced options that affect behavior.\n\n```ts\nconst seam = new SeamHttp({\n  apiKey: 'your-api-key',\n  endpoint: 'https://example.com',\n  axiosOptions: {},\n  axiosRetryOptions: {},\n})\n```\n\nWhen using the static factory methods,\nthese options may be passed in as the last argument.\n\n```ts\nconst seam = SeamHttp.fromApiKey('some-api-key', {\n  endpoint: 'https://example.com',\n  axiosOptions: {},\n  axiosRetryOptions: {},\n})\n```\n\n#### Setting the endpoint\n\nSome contexts may need to override the API endpoint,\ne.g., testing or proxy setups.\nThis option corresponds to the Axios `baseURL` setting.\n\nEither pass the `endpoint` option, or set the `SEAM_ENDPOINT` environment variable.\n\n#### Configuring the Axios Client\n\nThe Axios client and retry behavior may be configured with custom initiation options\nvia [`axiosOptions`][axiosOptions] and [`axiosRetryOptions`][axiosRetryOptions].\nOptions are deep merged with the default options.\n\n[axiosOptions]: https://axios-http.com/docs/config_defaults\n[axiosRetryOptions]: https://github.com/softonic/axios-retry\n\n#### Using the Axios Client\n\nThe Axios client is exposed and may be used or configured directly:\n\n```ts\nimport { SeamHttp, DevicesListResponse } from '@seamapi/http'\n\nconst seam = new SeamHttp()\n\nseam.client.interceptors.response.use((response) =\u003e {\n  console.log(response)\n  return response\n})\n\nconst devices = await seam.client.get\u003cDevicesListResponse\u003e('/devices/list')\n```\n\n#### Overriding the Client\n\nAn Axios compatible client may be provided to create a `SeamHttp` instance.\nThis API is used internally and is not directly supported.\n\n#### Alternative endpoint path interface\n\nThe `SeamHttpEndpoints` class offers an alternative path-based interface to every API endpoint.\nEach endpoint is exposed as simple property that returns the corresponding method from `SeamHttp`.\n\n```ts\nimport { SeamHttpEndpoints } from '@seamapi/http'\n\nconst seam = new SeamHttpEndpoints()\nconst devices = await seam['/devices/list']()\n```\n\n#### Enable undocumented API\n\nPass the `isUndocumentedApiEnabled` option to allow using the undocumented API.\nThis API is used internally and is not directly supported.\nDo not use the undocumented API in production environments.\nSeam is not responsible for any issues you may encounter with the undocumented API.\n\n```ts\nimport { SeamHttp } from '@seamapi/http'\n\nconst seam = new SeamHttp({ isUndocumentedApiEnabled: true })\n```\n\n#### Inspecting the Request\n\nAll client methods return an instance of `SeamHttpRequest`.\nInspect the request before it is sent to the server by intentionally not awaiting the `SeamHttpRequest`:\n\n```ts\nconst seam = new SeamHttp('your-api-key')\n\nconst request = seam.devices.list()\n\nconsole.log(`${request.method} ${request.url}`, JSON.stringify(request.body))\n\nconst devices = await request.execute()\n```\n\n## Development and Testing\n\n### Quickstart\n\n```\n$ git clone https://github.com/seamapi/javascript-http.git\n$ cd javascript-http\n$ nvm install\n$ npm install\n$ npm run test:watch\n```\n\nPrimary development tasks are defined under `scripts` in `package.json`\nand available via `npm run`.\nView them with\n\n```\n$ npm run\n```\n\n### Source code\n\nThe [source code] is hosted on GitHub.\nClone the project with\n\n```\n$ git clone git@github.com:seamapi/javascript-http.git\n```\n\n[source code]: https://github.com/seamapi/javascript-http\n\n### Requirements\n\nYou will need [Node.js] with [npm] and a [Node.js debugging] client.\n\nBe sure that all commands run under the correct Node version, e.g.,\nif using [nvm], install the correct version with\n\n```\n$ nvm install\n```\n\nSet the active version for each shell session with\n\n```\n$ nvm use\n```\n\nInstall the development dependencies with\n\n```\n$ npm install\n```\n\n[Node.js]: https://nodejs.org/\n[Node.js debugging]: https://nodejs.org/en/docs/guides/debugging-getting-started/\n[npm]: https://www.npmjs.com/\n[nvm]: https://github.com/creationix/nvm\n\n### Publishing\n\n#### Automatic\n\nNew versions are released automatically with [semantic-release]\nas long as commits follow the [Angular Commit Message Conventions].\n\n[Angular Commit Message Conventions]: https://semantic-release.gitbook.io/semantic-release/#commit-message-format\n[semantic-release]: https://semantic-release.gitbook.io/\n\n#### Manual\n\nPublish a new version by triggering a [version workflow_dispatch on GitHub Actions].\nThe `version` input will be passed as the first argument to [npm-version].\n\nThis may be done on the web or using the [GitHub CLI] with\n\n```\n$ gh workflow run version.yml --raw-field version=\u003cversion\u003e\n```\n\n[GitHub CLI]: https://cli.github.com/\n[npm-version]: https://docs.npmjs.com/cli/version\n[version workflow_dispatch on GitHub Actions]: https://github.com/seamapi/javascript-http/actions?query=workflow%3Aversion\n\n## GitHub Actions\n\n_GitHub Actions should already be configured: this section is for reference only._\n\nThe following repository secrets must be set on [GitHub Actions]:\n\n- `GH_TOKEN`: A personal access token for the bot user with\n  `packages:write` and `contents:write` permission.\n- `GIT_USER_NAME`: The GitHub bot user's real name.\n- `GIT_USER_EMAIL`: The GitHub bot user's email.\n- `GPG_PRIVATE_KEY`: The GitHub bot user's [GPG private key].\n- `GPG_PASSPHRASE`: The GitHub bot user's GPG passphrase.\n\n[GitHub Actions]: https://github.com/features/actions\n[GPG private key]: https://github.com/marketplace/actions/import-gpg#prerequisites\n\n## Contributing\n\n\u003e If using squash merge, edit and ensure the commit message follows the [Angular Commit Message Conventions] specification.\n\u003e Otherwise, each individual commit must follow the [Angular Commit Message Conventions] specification.\n\n1. Create your feature branch (`git checkout -b my-new-feature`).\n2. Make changes.\n3. Commit your changes (`git commit -am 'Add some feature'`).\n4. Push to the branch (`git push origin my-new-feature`).\n5. Create a new draft pull request.\n6. Ensure all checks pass.\n7. Mark your pull request ready for review.\n8. Wait for the required approval from the code owners.\n9. Merge when ready.\n\n[Angular Commit Message Conventions]: https://semantic-release.gitbook.io/semantic-release/#commit-message-format\n\n## License\n\nThis npm package is licensed under the MIT license.\n\n## Warranty\n\nThis software is provided by the copyright holders and contributors \"as is\" and\nany express or implied warranties, including, but not limited to, the implied\nwarranties of merchantability and fitness for a particular purpose are\ndisclaimed. In no event shall the copyright holder or contributors be liable for\nany direct, indirect, incidental, special, exemplary, or consequential damages\n(including, but not limited to, procurement of substitute goods or services;\nloss of use, data, or profits; or business interruption) however caused and on\nany theory of liability, whether in contract, strict liability, or tort\n(including negligence or otherwise) arising in any way out of the use of this\nsoftware, even if advised of the possibility of such damage.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseamapi%2Fjavascript-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseamapi%2Fjavascript-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseamapi%2Fjavascript-http/lists"}