{"id":48789540,"url":"https://github.com/speakeasy-api/examples-downstream-spec-sdk-typescript","last_synced_at":"2026-04-13T19:30:41.043Z","repository":{"id":334033638,"uuid":"1139764630","full_name":"speakeasy-api/examples-downstream-spec-sdk-typescript","owner":"speakeasy-api","description":"Example TypeScript SDK generated from spec repo workflow","archived":false,"fork":false,"pushed_at":"2026-01-22T12:05:29.000Z","size":132,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-23T02:34:09.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/speakeasy-api.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"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":"2026-01-22T11:39:00.000Z","updated_at":"2026-01-22T12:05:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/speakeasy-api/examples-downstream-spec-sdk-typescript","commit_stats":null,"previous_names":["speakeasy-api/examples-downstream-spec-sdk-typescript"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/speakeasy-api/examples-downstream-spec-sdk-typescript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fexamples-downstream-spec-sdk-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fexamples-downstream-spec-sdk-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fexamples-downstream-spec-sdk-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fexamples-downstream-spec-sdk-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/speakeasy-api","download_url":"https://codeload.github.com/speakeasy-api/examples-downstream-spec-sdk-typescript/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fexamples-downstream-spec-sdk-typescript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31768606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-04-13T19:30:38.165Z","updated_at":"2026-04-13T19:30:41.032Z","avatar_url":"https://github.com/speakeasy-api.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example API TypeScript SDK\n\nThis SDK is generated from the [spec-repo-downstream-sdks](https://github.com/speakeasy-api/examples/tree/main/spec-repo-downstream-sdks) example.\n\n## Overview\n\nThis repository demonstrates a downstream SDK that is automatically generated when changes are made to a central spec repository. The workflow:\n\n1. A PR is created in the spec repo with OpenAPI spec changes\n2. The spec repo workflow triggers this repo's `generate-sdk-from-spec.yaml` workflow\n3. This workflow generates the SDK and creates a PR for review\n\n## Installation\n\n```bash\nnpm install @speakeasy-sdks/example-api\n```\n\n## Usage\n\n```typescript\nimport { ExampleAPI } from \"@speakeasy-sdks/example-api\";\n\nconst client = new ExampleAPI();\n\n// List users\nconst users = await client.users.listUsers();\n\n// Get a specific user\nconst user = await client.users.getUser({ id: \"user-123\" });\n```\n\n## Related\n\n- [Spec repo example](https://github.com/speakeasy-api/examples/tree/main/spec-repo-downstream-sdks)\n- [Python SDK](https://github.com/speakeasy-api/examples-downstream-spec-sdk-python)\n\n\u003c!-- Start Summary [summary] --\u003e\n## Summary\n\nExample API: A simple example API to demonstrate spec repo SDK generation workflow\n\u003c!-- End Summary [summary] --\u003e\n\n\u003c!-- Start Table of Contents [toc] --\u003e\n## Table of Contents\n\u003c!-- $toc-max-depth=2 --\u003e\n* [Example API TypeScript SDK](#example-api-typescript-sdk)\n  * [Overview](#overview)\n  * [Installation](#installation)\n  * [Usage](#usage)\n  * [Related](#related)\n  * [SDK Installation](#sdk-installation)\n  * [Requirements](#requirements)\n  * [SDK Example Usage](#sdk-example-usage)\n  * [Available Resources and Operations](#available-resources-and-operations)\n  * [Standalone functions](#standalone-functions)\n  * [Retries](#retries)\n  * [Error Handling](#error-handling)\n  * [Server Selection](#server-selection)\n  * [Custom HTTP Client](#custom-http-client)\n  * [Debugging](#debugging)\n\n\u003c!-- End Table of Contents [toc] --\u003e\n\n\u003c!-- Start SDK Installation [installation] --\u003e\n## SDK Installation\n\n\u003e [!TIP]\n\u003e To finish publishing your SDK to npm and others you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).\n\n\nThe SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.\n\n### NPM\n\n```bash\nnpm add https://github.com/speakeasy-api/examples-downstream-spec-sdk-typescript\n```\n\n### PNPM\n\n```bash\npnpm add https://github.com/speakeasy-api/examples-downstream-spec-sdk-typescript\n```\n\n### Bun\n\n```bash\nbun add https://github.com/speakeasy-api/examples-downstream-spec-sdk-typescript\n```\n\n### Yarn\n\n```bash\nyarn add https://github.com/speakeasy-api/examples-downstream-spec-sdk-typescript\n```\n\n\u003e [!NOTE]\n\u003e This package is published as an ES Module (ESM) only. For applications using\n\u003e CommonJS, use `await import()` to import and use this package.\n\u003c!-- End SDK Installation [installation] --\u003e\n\n\u003c!-- Start Requirements [requirements] --\u003e\n## Requirements\n\nFor supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).\n\u003c!-- End Requirements [requirements] --\u003e\n\n\u003c!-- Start SDK Example Usage [usage] --\u003e\n## SDK Example Usage\n\n### Example\n\n```typescript\nimport { ExampleAPI } from \"@speakeasy-sdks/example-api\";\n\nconst exampleAPI = new ExampleAPI();\n\nasync function run() {\n  const result = await exampleAPI.listUsers();\n\n  console.log(result);\n}\n\nrun();\n\n```\n\u003c!-- End SDK Example Usage [usage] --\u003e\n\n\u003c!-- Start Available Resources and Operations [operations] --\u003e\n## Available Resources and Operations\n\n\u003cdetails open\u003e\n\u003csummary\u003eAvailable methods\u003c/summary\u003e\n\n### [ExampleAPI SDK](docs/sdks/exampleapi/README.md)\n\n* [listUsers](docs/sdks/exampleapi/README.md#listusers) - List all users\n* [createUser](docs/sdks/exampleapi/README.md#createuser) - Create a user\n* [getUser](docs/sdks/exampleapi/README.md#getuser) - Get a user\n\n\u003c/details\u003e\n\u003c!-- End Available Resources and Operations [operations] --\u003e\n\n\u003c!-- Start Standalone functions [standalone-funcs] --\u003e\n## Standalone functions\n\nAll the methods listed above are available as standalone functions. These\nfunctions are ideal for use in applications running in the browser, serverless\nruntimes or other environments where application bundle size is a primary\nconcern. When using a bundler to build your application, all unused\nfunctionality will be either excluded from the final bundle or tree-shaken away.\n\nTo read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).\n\n\u003cdetails\u003e\n\n\u003csummary\u003eAvailable standalone functions\u003c/summary\u003e\n\n- [`createUser`](docs/sdks/exampleapi/README.md#createuser) - Create a user\n- [`getUser`](docs/sdks/exampleapi/README.md#getuser) - Get a user\n- [`listUsers`](docs/sdks/exampleapi/README.md#listusers) - List all users\n\n\u003c/details\u003e\n\u003c!-- End Standalone functions [standalone-funcs] --\u003e\n\n\u003c!-- Start Retries [retries] --\u003e\n## Retries\n\nSome of the endpoints in this SDK support retries.  If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API.  However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.\n\nTo change the default retry strategy for a single API call, simply provide a retryConfig object to the call:\n```typescript\nimport { ExampleAPI } from \"@speakeasy-sdks/example-api\";\n\nconst exampleAPI = new ExampleAPI();\n\nasync function run() {\n  const result = await exampleAPI.listUsers({\n    retries: {\n      strategy: \"backoff\",\n      backoff: {\n        initialInterval: 1,\n        maxInterval: 50,\n        exponent: 1.1,\n        maxElapsedTime: 100,\n      },\n      retryConnectionErrors: false,\n    },\n  });\n\n  console.log(result);\n}\n\nrun();\n\n```\n\nIf you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:\n```typescript\nimport { ExampleAPI } from \"@speakeasy-sdks/example-api\";\n\nconst exampleAPI = new ExampleAPI({\n  retryConfig: {\n    strategy: \"backoff\",\n    backoff: {\n      initialInterval: 1,\n      maxInterval: 50,\n      exponent: 1.1,\n      maxElapsedTime: 100,\n    },\n    retryConnectionErrors: false,\n  },\n});\n\nasync function run() {\n  const result = await exampleAPI.listUsers();\n\n  console.log(result);\n}\n\nrun();\n\n```\n\u003c!-- End Retries [retries] --\u003e\n\n\u003c!-- Start Error Handling [errors] --\u003e\n## Error Handling\n\n[`ExampleAPIError`](./src/models/errors/exampleapierror.ts) is the base class for all HTTP error responses. It has the following properties:\n\n| Property            | Type       | Description                                            |\n| ------------------- | ---------- | ------------------------------------------------------ |\n| `error.message`     | `string`   | Error message                                          |\n| `error.statusCode`  | `number`   | HTTP response status code eg `404`                     |\n| `error.headers`     | `Headers`  | HTTP response headers                                  |\n| `error.body`        | `string`   | HTTP body. Can be empty string if no body is returned. |\n| `error.rawResponse` | `Response` | Raw HTTP response                                      |\n\n### Example\n```typescript\nimport { ExampleAPI } from \"@speakeasy-sdks/example-api\";\nimport * as errors from \"@speakeasy-sdks/example-api/models/errors\";\n\nconst exampleAPI = new ExampleAPI();\n\nasync function run() {\n  try {\n    const result = await exampleAPI.listUsers();\n\n    console.log(result);\n  } catch (error) {\n    if (error instanceof errors.ExampleAPIError) {\n      console.log(error.message);\n      console.log(error.statusCode);\n      console.log(error.body);\n      console.log(error.headers);\n    }\n  }\n}\n\nrun();\n\n```\n\n### Error Classes\n**Primary error:**\n* [`ExampleAPIError`](./src/models/errors/exampleapierror.ts): The base class for HTTP error responses.\n\n\u003cdetails\u003e\u003csummary\u003eLess common errors (6)\u003c/summary\u003e\n\n\u003cbr /\u003e\n\n**Network errors:**\n* [`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.\n* [`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.\n* [`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.\n* [`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.\n* [`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.\n\n\n**Inherit from [`ExampleAPIError`](./src/models/errors/exampleapierror.ts)**:\n* [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.\n\n\u003c/details\u003e\n\u003c!-- End Error Handling [errors] --\u003e\n\n\u003c!-- Start Server Selection [server] --\u003e\n## Server Selection\n\n### Override Server URL Per-Client\n\nThe default server can be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example:\n```typescript\nimport { ExampleAPI } from \"@speakeasy-sdks/example-api\";\n\nconst exampleAPI = new ExampleAPI({\n  serverURL: \"https://api.example.com\",\n});\n\nasync function run() {\n  const result = await exampleAPI.listUsers();\n\n  console.log(result);\n}\n\nrun();\n\n```\n\u003c!-- End Server Selection [server] --\u003e\n\n\u003c!-- Start Custom HTTP Client [http-client] --\u003e\n## Custom HTTP Client\n\nThe TypeScript SDK makes API calls using an `HTTPClient` that wraps the native\n[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This\nclient is a thin wrapper around `fetch` and provides the ability to attach hooks\naround the request lifecycle that can be used to modify the request or handle\nerrors and response.\n\nThe `HTTPClient` constructor takes an optional `fetcher` argument that can be\nused to integrate a third-party HTTP client or when writing tests to mock out\nthe HTTP client and feed in fixtures.\n\nThe following example shows how to use the `\"beforeRequest\"` hook to to add a\ncustom header and a timeout to requests and how to use the `\"requestError\"` hook\nto log errors:\n\n```typescript\nimport { ExampleAPI } from \"@speakeasy-sdks/example-api\";\nimport { HTTPClient } from \"@speakeasy-sdks/example-api/lib/http\";\n\nconst httpClient = new HTTPClient({\n  // fetcher takes a function that has the same signature as native `fetch`.\n  fetcher: (request) =\u003e {\n    return fetch(request);\n  }\n});\n\nhttpClient.addHook(\"beforeRequest\", (request) =\u003e {\n  const nextRequest = new Request(request, {\n    signal: request.signal || AbortSignal.timeout(5000)\n  });\n\n  nextRequest.headers.set(\"x-custom-header\", \"custom value\");\n\n  return nextRequest;\n});\n\nhttpClient.addHook(\"requestError\", (error, request) =\u003e {\n  console.group(\"Request Error\");\n  console.log(\"Reason:\", `${error}`);\n  console.log(\"Endpoint:\", `${request.method} ${request.url}`);\n  console.groupEnd();\n});\n\nconst sdk = new ExampleAPI({ httpClient: httpClient });\n```\n\u003c!-- End Custom HTTP Client [http-client] --\u003e\n\n\u003c!-- Start Debugging [debug] --\u003e\n## Debugging\n\nYou can setup your SDK to emit debug logs for SDK requests and responses.\n\nYou can pass a logger that matches `console`'s interface as an SDK option.\n\n\u003e [!WARNING]\n\u003e Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.\n\n```typescript\nimport { ExampleAPI } from \"@speakeasy-sdks/example-api\";\n\nconst sdk = new ExampleAPI({ debugLogger: console });\n```\n\u003c!-- End Debugging [debug] --\u003e\n\n\u003c!-- Placeholder for Future Speakeasy SDK Sections --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspeakeasy-api%2Fexamples-downstream-spec-sdk-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspeakeasy-api%2Fexamples-downstream-spec-sdk-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspeakeasy-api%2Fexamples-downstream-spec-sdk-typescript/lists"}