{"id":21238699,"url":"https://github.com/shahradelahi/zod-request","last_synced_at":"2025-05-16T09:05:03.299Z","repository":{"id":279459995,"uuid":"749529052","full_name":"shahradelahi/zod-request","owner":"shahradelahi","description":"🛡️ Type-safe and Validated HTTP requests using Zod","archived":false,"fork":false,"pushed_at":"2025-05-09T04:19:35.000Z","size":141,"stargazers_count":178,"open_issues_count":11,"forks_count":0,"subscribers_count":3,"default_branch":"canary","last_synced_at":"2025-05-14T00:41:53.961Z","etag":null,"topics":["browser","fetch","node","typescript","zod"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/zod-request","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/shahradelahi.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-01-28T20:42:44.000Z","updated_at":"2025-04-09T21:12:27.000Z","dependencies_parsed_at":"2025-03-13T08:23:13.423Z","dependency_job_id":"6aa9ea88-bf1f-4939-a94c-4ef9c86df2c5","html_url":"https://github.com/shahradelahi/zod-request","commit_stats":null,"previous_names":["shahradelahi/zod-request"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fzod-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fzod-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fzod-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fzod-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shahradelahi","download_url":"https://codeload.github.com/shahradelahi/zod-request/tar.gz/refs/heads/canary","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254501557,"owners_count":22081528,"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","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":["browser","fetch","node","typescript","zod"],"created_at":"2024-11-21T00:37:48.139Z","updated_at":"2025-05-16T09:04:58.282Z","avatar_url":"https://github.com/shahradelahi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zod-request\n\n[![npm](https://img.shields.io/npm/v/zod-request)](https://www.npmjs.com/package/zod-request)\n[![install size](https://packagephobia.com/badge?p=zod-request)](https://packagephobia.com/result?p=zod-request)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://choosealicense.com/licenses/mit/)\n[![GitHub stars](https://img.shields.io/github/stars/shahradelahi/zod-request?style=social)](https://github.com/shahradelahi/zod-request/stargazers)\n\n\u003e Validated and Type-safe HTTP requests using Zod\n\n## Notable Features\n\n- Exact API as Native `fetch` with extra features\n- Supports every environment (**Node.js**, **Browser**, Bun, etc.)\n\n## 📦 Installation\n\n```bash\nnpm install zod-request zod\n```\n\n## 📖 Usage\n\n```typescript\nimport { fetch } from 'zod-request';\nimport { z } from 'zod';\n\nconst todoSchema = z.object({\n  userId: z.number(),\n  id: z.number(),\n  title: z.string(),\n  completed: z.boolean()\n});\n\nconst response = await fetch('https://jsonplaceholder.typicode.com/todos', {\n  method: 'GET',\n  headers: {\n    Accept: 'application/json'\n  },\n  schema: {\n    response: z.array(todoSchema)\n  }\n});\n\n// type of data is [{ userId: number, id: number, title: string, completed: boolean }, ...]\nconst data = await response.json();\n\nconsole.log(Array.isArray(data)); // true\nconsole.log(data.length); // 200\n```\n\n## 📚 Documentation\n\nFor all configuration options, please see [the API docs](https://paka.dev/npm/zod-request@canary/api).\n\n## 🤝 Contributing\n\nYou can contribute to this project by opening an issue or a pull request\non [GitHub](https://github.com/shahradelahi/zod-request). Feel free to contribute, we care about your ideas and\nsuggestions.\n\n## Examples\n\n\u003cdetails\u003e\n  \u003csummary\u003eSend a Post request with a FormData body\u003c/summary\u003e\n\n```typescript\nimport { fetch } from 'zod-request';\nimport { z } from 'zod';\n\nconst schema = {\n  body: z.object({\n    name: z.string(),\n    age: z.number()\n  }),\n  response: z.object({\n    form: z.record(z.any()),\n    headers: z.record(z.string())\n  })\n};\n\nconst response = await fetch('https://httpbin.org/post', {\n  method: 'POST',\n  form: {\n    name: 'John',\n    age: 20\n  },\n  schema: schema\n});\n\nconst { form, headers } = await response.json();\nconsole.log(form); // { name: 'John', age: '20' }\nconsole.log(headers); // { 'Content-Type': 'multipart/form-data; boundary=---- ...\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eSkip body validation for a request\u003c/summary\u003e\n\n```typescript\nconst response = await fetch('https://jsonplaceholder.typicode.com/todos', {\n  method: 'GET',\n  headers: {\n    Accept: 'application/json'\n  }\n});\n\nconst data = await response.unsafeJson(); // Throws an error if the response is not a valid JSON\n\nconsole.log(Array.isArray(data)); // true\nconsole.log(data.length); // 200\n```\n\n\u003c/details\u003e\n\n## Relevant Links\n\n- [Zod Documentation](https://zod.dev/)\n- [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)\n- [Transform JSON to Zod Schema](https://transform.tools/json-to-zod)\n\n## License\n\n[MIT](LICENSE) © [Shahrad Elahi](https://github.com/shahradelahi)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Fzod-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahradelahi%2Fzod-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Fzod-request/lists"}