{"_id":"@allowancejs/api-client","_rev":"3-28779d7825c74b9ff9f99e0a65b4c19a","name":"@allowancejs/api-client","dist-tags":{"latest":"0.4.0"},"versions":{"0.2.0":{"name":"@allowancejs/api-client","version":"0.2.0","_id":"@allowancejs/api-client@0.2.0","maintainers":[{"name":"ptiger10","email":"dhfort@gmail.com"}],"homepage":"https://github.com/withallowance/platform#readme","bugs":{"url":"https://github.com/withallowance/platform/issues"},"dist":{"shasum":"52fd3d5b1bc7ffddf50a678c74e04a32a54a0539","tarball":"https://registry.npmjs.org/@allowancejs/api-client/-/api-client-0.2.0.tgz","fileCount":14,"integrity":"sha512-86TA4a2SVbqmKlZxk4NnKOn0qM1f/XkvuFIgxuQVLTtjv6FPgGM7STVVeh5zhXDFqRQfxvDCnIYk6YUuQTlSvw==","signatures":[{"sig":"MEUCIBpCLdYZUKuWTl7GDitfNmwU6k+kc6Ptn4JqD+IvG44YAiEAxqzmsrzWl1+IaQNtkA53T1Y1SJ+WGLUvquwmWFTSWAc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":137719},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","development":"./src/index.ts"}},"gitHead":"3c6a789d2473f4a5a207dd55c94539828d17bc0f","scripts":{"test":"vitest run","build":"tsc --project tsconfig.build.json","clean":"rm -rf dist","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"ptiger10","email":"dhfort@gmail.com"},"repository":{"url":"git+https://github.com/withallowance/platform.git","type":"git","directory":"frontend/packages/api-client"},"_npmVersion":"11.11.1","description":"Typed Connect-style client for the AllowanceJS API. Types are the single source of truth shared across the SDK, embed, and admin (kept aligned with /proto).","directories":{},"sideEffects":false,"_nodeVersion":"25.8.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/api-client_0.2.0_1781641569407_0.49397385718256426","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@allowancejs/api-client","version":"0.3.0","_id":"@allowancejs/api-client@0.3.0","maintainers":[{"name":"ptiger10","email":"dhfort@gmail.com"}],"homepage":"https://github.com/withallowance/platform#readme","bugs":{"url":"https://github.com/withallowance/platform/issues"},"dist":{"shasum":"c30a7b103829bd9a37c7b7866172b6073c906ff8","tarball":"https://registry.npmjs.org/@allowancejs/api-client/-/api-client-0.3.0.tgz","fileCount":14,"integrity":"sha512-23yzsfPyuLNFrZ/0/B1kfgroD1xMKgGSIGasgAMGjbWMSRDq8r4qNcIq1mNorrHnlWQjccpcsrj0pr8pA/AAHA==","signatures":[{"sig":"MEUCIHDNmcvWFJvHRqbeDexthb+C62OU33jFHkSybmx7edhHAiEA5qemETVZCvNccgi/7hGpL1E5zx9xZZ+EXMd9UVENIb4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":228556},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","development":"./src/index.ts"}},"gitHead":"71f647aebd7ec1b486449d7e9f8553c883666575","scripts":{"test":"vitest run","build":"tsc --project tsconfig.build.json","clean":"rm -rf dist","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:89272d22-a961-4908-9d11-7c648b7cf7bc"}},"repository":{"url":"git+https://github.com/withallowance/platform.git","type":"git","directory":"frontend/packages/api-client"},"_npmVersion":"11.17.0","description":"Typed Connect-style client for the AllowanceJS API. Types are the single source of truth shared across the SDK, embed, and admin (kept aligned with /proto).","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/api-client_0.3.0_1782321687372_0.5175584336743171","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@allowancejs/api-client","version":"0.4.0","description":"Typed Connect-style client for the AllowanceJS API. Types are the single source of truth shared across the SDK, embed, and admin (kept aligned with /proto).","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"development":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js"}},"sideEffects":false,"scripts":{"build":"tsc --project tsconfig.build.json","clean":"rm -rf dist","prepublishOnly":"npm run build","typecheck":"tsc --noEmit","test":"vitest run"},"devDependencies":{"typescript":"^6.0.3"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/withallowance/platform.git","directory":"frontend/packages/api-client"},"gitHead":"7a079baf304623ce861732363259125c695beaee","_id":"@allowancejs/api-client@0.4.0","bugs":{"url":"https://github.com/withallowance/platform/issues"},"homepage":"https://github.com/withallowance/platform#readme","_nodeVersion":"22.23.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-+tPNl+QNqaAwDGR2hcE0ZE0kbpbUHqru7FfL12ieFYQNoTw4r7Hmd64UUiAe0bgcqx2SuDrFYu0pr3I++GQ05Q==","shasum":"c23d8c66a73e9e9071408e71ae6fb9add193cd79","tarball":"https://registry.npmjs.org/@allowancejs/api-client/-/api-client-0.4.0.tgz","fileCount":14,"unpackedSize":223907,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIH/ZclHbTizaAzgIwpuahUV5HLTRXFPaTPs2juewyfUuAiEAy2oCEJTZ+LrB8/iD7mlNhsLgXQZhHW9pDN/63n608SY="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:89272d22-a961-4908-9d11-7c648b7cf7bc"}},"directories":{},"maintainers":[{"name":"ptiger10","email":"dhfort@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/api-client_0.4.0_1782351614495_0.15625807592460195"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-16T20:26:09.191Z","modified":"2026-06-25T01:40:14.846Z","0.2.0":"2026-06-16T20:26:09.564Z","0.3.0":"2026-06-24T17:21:27.556Z","0.4.0":"2026-06-25T01:40:14.735Z"},"bugs":{"url":"https://github.com/withallowance/platform/issues"},"homepage":"https://github.com/withallowance/platform#readme","repository":{"type":"git","url":"git+https://github.com/withallowance/platform.git","directory":"frontend/packages/api-client"},"description":"Typed Connect-style client for the AllowanceJS API. Types are the single source of truth shared across the SDK, embed, and admin (kept aligned with /proto).","maintainers":[{"name":"ptiger10","email":"dhfort@gmail.com"}],"readme":"# @allowancejs/api-client\n\nTyped HTTP client for the AllowanceJS API.\n\nTypes are the single source of truth shared across the SDK, dashboards, and admin surfaces — kept aligned with the proto definitions in `/proto/allowancejs/v1`.\n\n## Install\n\n```bash\nnpm install @allowancejs/api-client\n```\n\n## Usage\n\n```ts\nimport { AllowanceClient } from \"@allowancejs/api-client\";\n\nconst client = new AllowanceClient({\n  baseUrl: \"https://api.example.com\",\n  getToken: async () => getSessionToken(),\n});\n\n// Fetch the current balance (read tier)\nconst balance = await client.getBalance({ userId: \"user_xyz\" });\nconsole.log(balance.remainingUnits, balance.allowanceUnits, balance.outOfAllowance);\n\n// Preflight a governed action (kill switch / per-feature cap / total budget)\nconst decision = await client.checkAllowance({\n  userId: \"user_xyz\",\n  featureKey: \"summarize\",\n  estimateUnits: 1500,\n});\n```\n\n> This client is the **read + governance** surface. Usage events are **not**\n> submitted here — metering metadata is pushed to the `ingest` service (or its\n> gateway/OTel adapters), never through `@allowancejs/api-client`. To report usage\n> from your backend, use the per-language ingest SDKs under\n> [`clients/`](../../../clients/README.md) — see the\n> [server-side reference](https://allowancejs.com/server.html).\n\n## Error handling\n\n```ts\nimport { RpcError } from \"@allowancejs/api-client\";\n\ntry {\n  await client.getBalance({ userId: \"user_xyz\" });\n} catch (err) {\n  if (err instanceof RpcError) {\n    console.error(err.code, err.httpStatus, err.message);\n  }\n}\n```\n\n## Format utilities\n\n```ts\nimport { toDisplay, formatUsage } from \"@allowancejs/api-client\";\n\n// Convert raw units to a display string (positional args: units, metric, locale?)\nconst label = formatUsage(1_500_000, \"usd\"); // \"$1.50\"\n```\n\n## Key exports\n\n`AllowanceClient`, `RpcError`, `toDisplay`, `unitsFromDisplay`, `formatUsage`, `compactUsage` — plus the complete domain type inventory (`Period`, `UsageMetric`, `BudgetScope`, request/response interfaces, etc.). See `src/types.ts` for the full list.\n","readmeFilename":"README.md"}