{"id":46747287,"url":"https://github.com/skiftle/sorbus","last_synced_at":"2026-03-23T21:00:55.901Z","repository":{"id":341367195,"uuid":"1167721285","full_name":"skiftle/sorbus","owner":"skiftle","description":"The typed fetch client","archived":false,"fork":false,"pushed_at":"2026-03-19T17:13:19.000Z","size":216,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-20T09:04:12.580Z","etag":null,"topics":["contract","fetch","rest-api","type-safe","typescript","zod"],"latest_commit_sha":null,"homepage":"https://sorbus.dev","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/skiftle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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-02-26T15:58:27.000Z","updated_at":"2026-03-19T17:14:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/skiftle/sorbus","commit_stats":null,"previous_names":["skiftle/sorbus"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/skiftle/sorbus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiftle%2Fsorbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiftle%2Fsorbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiftle%2Fsorbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiftle%2Fsorbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skiftle","download_url":"https://codeload.github.com/skiftle/sorbus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiftle%2Fsorbus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30866581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-23T18:35:51.002Z","status":"ssl_error","status_checked_at":"2026-03-23T18:35:42.451Z","response_time":59,"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":["contract","fetch","rest-api","type-safe","typescript","zod"],"created_at":"2026-03-09T20:00:32.386Z","updated_at":"2026-03-23T21:00:55.896Z","avatar_url":"https://github.com/skiftle.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Sorbus\n\n![Sorbus](docs/public/logo-light.svg#gh-light-mode-only)\n![Sorbus](docs/public/logo-dark.svg#gh-dark-mode-only)\n\n[![npm version](https://img.shields.io/npm/v/sorbus)](https://www.npmjs.com/package/sorbus)\n[![CI](https://github.com/skiftle/sorbus/actions/workflows/ci.yml/badge.svg)](https://github.com/skiftle/sorbus/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nSorbus is a typed fetch client for APIs where you can't share types directly — Rails, Django, Go, Laravel. Instead of verbose OpenAPI specs and opaque code generators, you define your API as a contract: endpoints with Zod schemas. Params, responses, and errors are all inferred.\n\nThe contract is just TypeScript — compose schemas, pick fields for forms, reuse them for validation. Write contracts by hand, or generate them with [Apiwork](https://github.com/skiftle/apiwork) from your Rails API.\n\nA thin layer over `fetch`. No codegen. No opaque output.\n\nSee https://sorbus.dev for full documentation.\n\n## Install\n\n```bash\nnpm install sorbus zod\n# or\npnpm add sorbus zod\n```\n\n## The Contract\n\n```typescript\nimport { z } from 'zod';\n\nconst InvoiceSchema = z.object({\n  id: z.string(),\n  number: z.string(),\n  total: z.number(),\n});\n\nexport const contract = {\n  endpoints: {\n    invoices: {\n      show: {\n        method: 'GET',\n        path: '/invoices/:id',\n        pathParams: z.object({\n          id: z.string(),\n        }),\n        response: {\n          body: z.object({\n            invoice: InvoiceSchema,\n          }),\n        },\n      },\n      create: {\n        method: 'POST',\n        path: '/invoices',\n        request: {\n          body: z.object({\n            invoice: InvoiceSchema.pick({\n              number: true,\n              total: true,\n            }),\n          }),\n        },\n        response: {\n          body: z.object({\n            invoice: InvoiceSchema,\n          }),\n        },\n        errors: [422],\n      },\n    },\n  },\n  error: z.object({\n    message: z.string(),\n    errors: z.record(z.string(), z.array(z.string())).optional(),\n  }),\n} as const;\n```\n\n## The Client\n\n```typescript\nimport { createClient } from 'sorbus';\nimport { contract } from './contract';\n\nconst api = createClient(contract, '/api');\n\n// Errors throw — just use the data\nconst { invoice } = await api.invoices.show({ id: '123' });\n\n// Catch specific status codes when you need to\nconst result = await api.invoices.create(\n  {\n    invoice: {\n      number: 'INV-001',\n      total: 1000,\n    },\n  },\n  { catch: [422] },\n);\n\nif (!result.ok) {\n  setErrors(result.data.errors);\n  return;\n}\n\nresult.data.invoice; // fully typed\n```\n\n## Status\n\nUnder active development.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskiftle%2Fsorbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskiftle%2Fsorbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskiftle%2Fsorbus/lists"}