{"_id":"@api-zero/core","_rev":"6-5a184c2e91427ed8a24d7c4d847fadca","name":"@api-zero/core","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.0":{"name":"@api-zero/core","version":"0.1.0","keywords":["http","client","fetch","api","typescript","interceptors","retry"],"license":"MIT","_id":"@api-zero/core@0.1.0","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"501a4079c5eba0c26a32df3e028751bae7b44ea5","tarball":"https://registry.npmjs.org/@api-zero/core/-/core-0.1.0.tgz","fileCount":9,"integrity":"sha512-31IJNbvzg5fY0d5kdByCv59hZdsgvdzEFpAuTVSsrSQbhzSvQ5LLOCV8iNxUw92Cont3vJmLRtGWfkFcQnytgw==","signatures":[{"sig":"MEUCIQDtZ5l3flQ22x+rMNUYplobyNB17z2N5BNs204/6HkipwIgBGvkSXCdaNiAXPDpPtu0l4qygqmrLPLhnHcRL2v9Q3I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2fcore@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":200151},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-core-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/683646e7ebbff44217f2b133fb16d5f5/api-zero-core-0.1.0.tgz","_integrity":"sha512-31IJNbvzg5fY0d5kdByCv59hZdsgvdzEFpAuTVSsrSQbhzSvQ5LLOCV8iNxUw92Cont3vJmLRtGWfkFcQnytgw==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/core"},"_npmVersion":"11.17.0","description":"Lightweight, type-safe HTTP client built on the Fetch API with interceptors, retries, and structured errors.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.1.0_1787621524249_0.5263524113101545","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@api-zero/core","version":"0.1.1","keywords":["http","client","fetch","api","typescript","interceptors","retry"],"license":"MIT","_id":"@api-zero/core@0.1.1","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"dde4a34a46605bd5c7132d20c85b117cc88f54cf","tarball":"https://registry.npmjs.org/@api-zero/core/-/core-0.1.1.tgz","fileCount":9,"integrity":"sha512-C+7AuNMawD/7gs3306jArKcV7wYHkfWac1AlGdbE3BQXtqr5t7aj7PrzFCJmYdEfLPGm0mcehiCTutFBGASdfw==","signatures":[{"sig":"MEUCIHu697lCnQlbrUCulrygqrQXGzAzECHuw1DEdye1WiAAAiEA8UGH7QJKzexOpnuEuHqaS69TWIOFaMOZ+I9t2+Cbrng=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2fcore@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":200094},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-core-0.1.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/e4a01dec70db34ddcfce095ff56946b8/api-zero-core-0.1.1.tgz","_integrity":"sha512-C+7AuNMawD/7gs3306jArKcV7wYHkfWac1AlGdbE3BQXtqr5t7aj7PrzFCJmYdEfLPGm0mcehiCTutFBGASdfw==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/core"},"_npmVersion":"11.17.0","description":"Lightweight, type-safe HTTP client built on the Fetch API with interceptors, retries, and structured errors.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.1.1_1787771963856_0.4989387378726675","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@api-zero/core","version":"0.1.2","keywords":["http","client","fetch","api","typescript","interceptors","retry"],"license":"MIT","_id":"@api-zero/core@0.1.2","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"c49bf18de84db6758df467063e9afb9c962afdab","tarball":"https://registry.npmjs.org/@api-zero/core/-/core-0.1.2.tgz","fileCount":9,"integrity":"sha512-+Yyc1Okri7yefevsjRaOon5SG9lapv0ubbeVHEA9Shfh3UxZ3ZFI7TBGMJgqKfpG1sxb6J147avGxZlj2aIGyg==","signatures":[{"sig":"MEYCIQCA+bt2C7RBwdeSMj646eOIoFDGH6wD1rPhKjVlZLZ4WQIhANsJ9jy+Jxj1bTKHMUhDYz9ZetCF6LoHGIpEEbMvimC9","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2fcore@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":200094},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-core-0.1.2.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/b3bdea958ba21e48cf6cb59645775f66/api-zero-core-0.1.2.tgz","_integrity":"sha512-+Yyc1Okri7yefevsjRaOon5SG9lapv0ubbeVHEA9Shfh3UxZ3ZFI7TBGMJgqKfpG1sxb6J147avGxZlj2aIGyg==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/core"},"_npmVersion":"11.17.0","description":"Lightweight, type-safe HTTP client built on the Fetch API with interceptors, retries, and structured errors.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.1.2_1787772563804_0.019339361172383107","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@api-zero/core","version":"0.1.3","keywords":["http","client","fetch","api","typescript","interceptors","retry"],"license":"MIT","_id":"@api-zero/core@0.1.3","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"942a6379debc1e6983c9125209aa9ddc77812beb","tarball":"https://registry.npmjs.org/@api-zero/core/-/core-0.1.3.tgz","fileCount":9,"integrity":"sha512-crCrRVH/k5l8VfcYRcPqYrQ/unvI6uGStK+ZJSyTdXnZKC3JMoohmUxjjFjXxldQxIr5hlOij4x6yukAqBDNkg==","signatures":[{"sig":"MEYCIQCX+R+YeI1xoU0xU7OtSLfl3Cp3DhVeviAODEDIhMFBEAIhAO0Jxyaves27lwrT5v8QwLKbWetTbyj9tyovbMSTosjc","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2fcore@0.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":200346},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-core-0.1.3.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/1475fa72a7c7b78e00981752bd298e90/api-zero-core-0.1.3.tgz","_integrity":"sha512-crCrRVH/k5l8VfcYRcPqYrQ/unvI6uGStK+ZJSyTdXnZKC3JMoohmUxjjFjXxldQxIr5hlOij4x6yukAqBDNkg==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/core"},"_npmVersion":"11.17.0","description":"Lightweight, type-safe HTTP client built on the Fetch API with interceptors, retries, and structured errors.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.1.3_1787773901144_0.36229859447355595","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@api-zero/core","version":"0.1.4","keywords":["http","client","fetch","api","typescript","interceptors","retry"],"license":"MIT","_id":"@api-zero/core@0.1.4","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"340f57ac4bcc64f7c5114d8e7f45b4aed4db91d1","tarball":"https://registry.npmjs.org/@api-zero/core/-/core-0.1.4.tgz","fileCount":9,"integrity":"sha512-j/+uM84wWNI7lNGM8OmqmLwQ7u9MMz0vyzqzmK8zh+8JwWiOazcCKxQXeSw/gPRHKDho3roOM6XS1z0Z84kdHA==","signatures":[{"sig":"MEUCIQD3SQ9R0RgnuBmd4aqLeoOnSTPkzmBfmnvRL4XDXgiw7gIgNFDtME0bIeLOl/aGD07K7oG/7OtNkrgYqaUWkOkMsP4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2fcore@0.1.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":204860},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-core-0.1.4.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/5a3857fe44576bae5dabf28a6d7d8f32/api-zero-core-0.1.4.tgz","_integrity":"sha512-j/+uM84wWNI7lNGM8OmqmLwQ7u9MMz0vyzqzmK8zh+8JwWiOazcCKxQXeSw/gPRHKDho3roOM6XS1z0Z84kdHA==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/core"},"_npmVersion":"11.17.0","description":"Lightweight, type-safe HTTP client built on the Fetch API with interceptors, retries, and structured errors.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.1.4_1787792132112_0.008831437046372681","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@api-zero/core","version":"0.1.5","description":"Lightweight, type-safe HTTP client built on the Fetch API with interceptors, retries, and structured errors.","type":"module","license":"MIT","repository":{"type":"git","url":"git+https://github.com/api-zero/api-zero.git","directory":"packages/core"},"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"keywords":["http","client","fetch","api","typescript","interceptors","retry"],"sideEffects":false,"engines":{"node":">=22"},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest run","lint":"biome check .","format":"biome format --write ."},"_id":"@api-zero/core@0.1.5","_integrity":"sha512-ZpOTM4U4DdnQIP8Z/vqQ8zpfjF9JLnzkVKHeWuw5ttr2dCbf7k2Gqv7xnz/sqhwV1cLt4sfoRu7wyMZlldbJTA==","_resolved":"/tmp/85cfb1f778905d1df0a14fe3b0f204e9/api-zero-core-0.1.5.tgz","_from":"file:api-zero-core-0.1.5.tgz","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-ZpOTM4U4DdnQIP8Z/vqQ8zpfjF9JLnzkVKHeWuw5ttr2dCbf7k2Gqv7xnz/sqhwV1cLt4sfoRu7wyMZlldbJTA==","shasum":"3ccb60c9fe3511a4addad45604c53709c065f807","tarball":"https://registry.npmjs.org/@api-zero/core/-/core-0.1.5.tgz","fileCount":9,"unpackedSize":207596,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2fcore@0.1.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHnZbxACNWC4PhIuBnTiVdP4iLoI+lb2ds//j+sE2MeCAiEA6pSSsntKBY+66JzgzHYPk1qpoYGHcepJGAm7+wzzoQk="}]},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"directories":{},"maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/core_0.1.5_1787793180877_0.7002055429478113"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-25T01:32:04.073Z","modified":"2026-08-27T01:13:01.397Z","0.1.0":"2026-08-25T01:32:04.388Z","0.1.1":"2026-08-26T19:19:24.004Z","0.1.2":"2026-08-26T19:29:23.947Z","0.1.3":"2026-08-26T19:51:41.284Z","0.1.4":"2026-08-27T00:55:32.327Z","0.1.5":"2026-08-27T01:13:01.029Z"},"bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"license":"MIT","homepage":"https://api-zero.vercel.app","keywords":["http","client","fetch","api","typescript","interceptors","retry"],"repository":{"type":"git","url":"git+https://github.com/api-zero/api-zero.git","directory":"packages/core"},"description":"Lightweight, type-safe HTTP client built on the Fetch API with interceptors, retries, and structured errors.","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"readme":"# @api-zero/core\n\nA small, Fetch-based HTTP client whose value is reliable transport plus\nruntime-validated contracts. No framework, no dependencies.\n\n## What this package is for\n\nEvery project ends up with the same hand-written `api.ts`: a client wrapper, a\nplace to stash the auth token, an interceptor or two, and re-declared `.get` /\n`.post` helpers. That file is what api-zero replaces.\n\nIt is the transport and contract layer. Cache, deduplication and server-state\nlifecycle belong to [TanStack Query](https://tanstack.com/query) or\n[SWR](https://swr.vercel.app) — api-zero is designed to sit underneath them, not\nto compete with them.\n\n## Installation\n\n```bash\nnpm install @api-zero/core\n# or\npnpm add @api-zero/core\n```\n\nRuns on Node.js 22+, modern browsers and Edge runtimes.\n\n## Quick start\n\n```ts\nimport { createClient } from \"@api-zero/core\";\n\nconst api = createClient({\n  baseURL: \"https://api.example.com\",\n  timeout: 10_000,\n});\n\nconst user = await api.get<User>(\"/users/1\");\nconst created = await api.post<User>(\"/users\", { name: \"Alice\" });\n```\n\n## Structured errors\n\nEvery failure — HTTP status, network, timeout, abort, invalid JSON — arrives as\nan `ApiError` carrying the context needed to act on it, instead of a bare\n`TypeError: Failed to fetch`.\n\n```ts\nimport { ApiError } from \"@api-zero/core\";\n\ntry {\n  await api.get(\"/users/1\");\n} catch (error) {\n  if (error instanceof ApiError) {\n    error.status;      // 404\n    error.request;     // method, resolved URL, headers, params\n    error.attempt;     // which retry produced it\n    error.cause;       // the original error, preserved\n    error.isTimeout;   // timeout vs caller abort, kept distinct\n    error.isAborted;\n\n    if (error.is5xx()) { /* … */ }\n    if (error.isNotFound()) { /* … */ }\n  }\n}\n```\n\n## Retries you can defend\n\nRetries are conservative by default and never silently repeat an unsafe request.\n\n```ts\nconst api = createClient({\n  baseURL: \"https://api.example.com\",\n  retry: {\n    attempts: 3,\n    delay: 1000,\n    // exponential backoff with jitter, capped at maxDelay\n    backoff: \"exponential\",\n    jitter: true,\n    maxDelay: 30_000,\n    // Retry-After from 429/503 is honored\n    respectRetryAfter: true,\n    // idempotent methods only, unless you opt in explicitly\n    retryMethods: [\"GET\", \"PUT\", \"DELETE\"],\n    retryUnsafeMethods: false,\n    onRetry: (event) => console.warn(\"retrying\", event),\n  },\n});\n```\n\nCancelling a request stops it during the backoff sleep too — it does not wait\nout the delay before noticing.\n\n## Interceptors\n\n```ts\napi.interceptors.request.use((context) => {\n  context.headers[\"X-Request-Id\"] = crypto.randomUUID();\n  return context;\n});\n\napi.interceptors.response.use(\n  (response) => {\n    // Interceptors receive parsed data and timing, not a raw Response\n    metrics.record(response.request.url, response.status, response.timing);\n    return response;\n  },\n  (error) => {\n    if (error.isUnauthorized()) redirectToLogin();\n    throw error;\n  },\n);\n```\n\nSuccess handlers receive a `ResponseContext` — the request that produced it,\nthe parsed `data`, the status, the headers and timing. Rejection handlers see\nevery failure class, HTTP, network, timeout and validation alike, because errors\nare normalized before the chain runs.\n\n## Auth and headers\n\n```ts\napi.setAuthToken(token);        // Authorization: Bearer …\napi.setBasicAuth(user, pass);\napi.clearAuth();\napi.setHeader(\"X-Tenant\", \"acme\");\napi.removeHeader(\"X-Tenant\");\n```\n\nSet once on the client; every request carries it. That is the point.\n\n## Cancellation and timeouts\n\n```ts\nconst controller = new AbortController();\nconst promise = api.get(\"/slow\", { signal: controller.signal });\ncontroller.abort();\n```\n\nTimeout and caller cancellation compose into one signal, and the resulting error\ntells you which one fired.\n\n## Custom transports\n\n`Transport` is a public contract, so a mock transport in tests needs no network\nand no global patching.\n\n```ts\nimport type { Transport } from \"@api-zero/core\";\n\nconst mock: Transport = { async send(context) { /* … */ } };\nconst api = createClient({ transport: mock });\n```\n\n`FetchTransport` is used everywhere; `XhrTransport` is selected automatically in\nbrowsers when upload or download progress is requested.\n\n## Typed contracts\n\nFor runtime-validated payloads with inferred types, add\n[`@api-zero/zod`](https://www.npmjs.com/package/@api-zero/zod). For React\nbindings, add [`@api-zero/react`](https://www.npmjs.com/package/@api-zero/react).\n\n## License\n\nMIT\n","readmeFilename":"README.md"}