{"id":13809777,"url":"https://github.com/seamapi/typed-axios","last_synced_at":"2025-10-11T14:30:40.297Z","repository":{"id":65281392,"uuid":"588786577","full_name":"seamapi/typed-axios","owner":"seamapi","description":"A simple way to create an Axios instance that is fully typed with the routes from an API","archived":false,"fork":false,"pushed_at":"2025-03-08T11:31:14.000Z","size":903,"stargazers_count":6,"open_issues_count":7,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-10-01T15:56:19.884Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/seamapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2023-01-14T02:09:24.000Z","updated_at":"2024-05-16T13:16:35.000Z","dependencies_parsed_at":"2024-02-27T23:29:42.363Z","dependency_job_id":"e480f5fb-8ab7-4a84-b6fd-9cae632beb6f","html_url":"https://github.com/seamapi/typed-axios","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/seamapi/typed-axios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Ftyped-axios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Ftyped-axios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Ftyped-axios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Ftyped-axios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seamapi","download_url":"https://codeload.github.com/seamapi/typed-axios/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Ftyped-axios/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007457,"owners_count":26084313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"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":"2024-08-04T02:00:35.908Z","updated_at":"2025-10-11T14:30:40.001Z","avatar_url":"https://github.com/seamapi.png","language":"TypeScript","funding_links":[],"categories":["Official Projects"],"sub_categories":[],"readme":"# Typed Axios `typed-axios-instance`\n\n![](https://user-images.githubusercontent.com/1910070/212500697-38b99c4f-6022-4c82-8615-846c50b77b6a.png)\n\nTyped Axios Instance is a simple way to create an Axios instance that is fully typed with the routes from an API.\n\nThe benefit of using TypedAxiosInstance is you don't need to create or import a client\nfor a third party API, you can just apply types (generated from [OpenAPI](#) or\n[Nextlove](https://github.com/seamapi/nextlove)) to an existing Axios instance.\n\n```ts\nimport type { TypedAxios } from \"typed-axios-instance\"\nimport axios from \"axios\"\n\n// Need help generating these routes? You can generate them from...\n// nextlove: https://github.com/seamapi/nextlove\n// openapi: TODO\ntype Routes = [\n  {\n    route: \"/things/create\"\n    method: \"POST\"\n    jsonBody: {\n      name?: string | undefined\n    }\n    jsonResponse: {\n      thing: {\n        thing_id: string\n        name: string\n        created_at: string | Date\n      }\n    }\n  }\n]\n\nconst myAxiosInstance: TypedAxios\u003cRoutes\u003e = axios.create({\n  baseURL: \"http://example-api.com\",\n})\n\n// myAxiosInstance now has intelligent autocomplete!\n```\n\n![](https://user-images.githubusercontent.com/1910070/212500619-5d2f4568-7e8a-4a9f-9a4b-0c7c4fa4227a.png)\n\n![](https://user-images.githubusercontent.com/1910070/212500659-9c9ff64d-5ffa-4033-81bb-c84a780587ad.png)\n\n## Installation\n\n```\nnpm add --dev typed-axios-instance\n\n# yarn add --dev typed-axios-instance\n```\n\n## Route Definition\n\nThere are two ways of specifying routes for `TypedAxios\u003cRoutes\u003e`\n\n- `type Routes = RouteDef[]`\n- `type Routes = { [route:string]: RouteDef }`\n\n\u003e Using `RouteDef[]` allows you to do [HTTP Method Discrimination](#http-method-discrimination)\n\u003e and is the recommended method.\n\nThis is the type for `RouteDef`:\n\n```ts\nexport type RouteDef = {\n  route: string\n  method: HTTPMethod // you can supply multiple e.g. `\"PATCH\" | \"POST\"`\n\n  // INPUTS\n  queryParams?: Record\u003cstring, any\u003e\n  jsonBody?: Record\u003cstring, any\u003e\n  commonParams?: Record\u003cstring, any\u003e\n  formData?: Record\u003cstring, any\u003e\n\n  // RESPONSES\n  jsonResponse?: Record\u003cstring, any\u003e\n}\n```\n\n## HTTP Method Discrimination\n\nThere are two ways of specifying route definitions, if you specify the route\ndefinitions as an array (default for OpenAPI schemas), you'll get more specific\nautocomplete results, e.g. the response or request type will be based on what\nmethod is being used.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseamapi%2Ftyped-axios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseamapi%2Ftyped-axios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseamapi%2Ftyped-axios/lists"}