{"_id":"@anseta/typescript-sdk","_rev":"4-be83dbc405d9c840020d3827eae1c52e","name":"@anseta/typescript-sdk","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@anseta/typescript-sdk","version":"0.1.0","keywords":["anseta","staking","restaking","ethereum","solana","cosmos","openapi","sdk"],"license":"MIT","_id":"@anseta/typescript-sdk@0.1.0","maintainers":[{"name":"dvisacker","email":"davidvanisacker@gmail.com"}],"homepage":"https://docs.stakefi.network/docs/sdks/typescript","bugs":{"url":"https://github.com/anseta-labs/typescript-sdk/issues"},"dist":{"shasum":"f7586bde46432fd1f090c1a9e5167cadbeb7862f","tarball":"https://registry.npmjs.org/@anseta/typescript-sdk/-/typescript-sdk-0.1.0.tgz","fileCount":752,"integrity":"sha512-RZBuyuhoor1CcLgCD3IOzEAM+myWqMqEcoO/tq6I5OP+BkEIFSHi8y19yW6Bxx+ILAsWeP12FJS3SN60dqmKqQ==","signatures":[{"sig":"MEUCIGoglcC0JhrRI4b7aYUbo2qnGsbT31cZ/AptzF1neoL9AiEAowd02MCaZ+t85AqN9TZCdsOiMB2fNh2MM6lqEdR+TBY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2154871},"main":"./dist/index.js","_from":"file:anseta-typescript-sdk-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./package.json":"./package.json"},"scripts":{"build":"pnpm run build:cjs && pnpm run build:esm","clean":"rm -rf dist","format":"prettier --write \"scripts/**/*.mjs\" \"examples/**/*.ts\"","generate":"pnpm run prepare-spec && pnpm run generate:code","build:cjs":"tsc -p tsconfig.json","build:esm":"tsc -p tsconfig.esm.json && node scripts/fix-esm.mjs","typecheck":"tsc -p tsconfig.json --noEmit","prepare-spec":"node scripts/prepare-spec.mjs","generate:code":"rm -rf src && openapi-generator-cli generate","typecheck:examples":"tsc -p tsconfig.examples.json"},"_npmUser":{"name":"dvisacker","email":"davidvanisacker@gmail.com"},"_resolved":"/private/var/folders/sj/nx0wldb56vq7m0nwcqrfpw280000gn/T/559e23474ae0b172c5cc88390d51742f/anseta-typescript-sdk-0.1.0.tgz","_integrity":"sha512-RZBuyuhoor1CcLgCD3IOzEAM+myWqMqEcoO/tq6I5OP+BkEIFSHi8y19yW6Bxx+ILAsWeP12FJS3SN60dqmKqQ==","repository":{"url":"git+https://github.com/anseta-labs/typescript-sdk.git","type":"git"},"_npmVersion":"10.9.4","description":"TypeScript client for the Anseta Developer API, generated from the OpenAPI specification","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.23.9","prettier":"^3.4.2","typescript":"^5.7.2","@types/node":"^22.10.2","@openapitools/openapi-generator-cli":"^2.15.3"},"_npmOperationalInternal":{"tmp":"tmp/typescript-sdk_0.1.0_1787817753242_0.8028368886208643","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@anseta/typescript-sdk","version":"0.2.0","description":"TypeScript client for the Anseta Developer API, generated from the OpenAPI specification","license":"MIT","repository":{"type":"git","url":"git+https://github.com/anseta-labs/typescript-sdk.git"},"homepage":"https://docs.stakefi.network/docs/sdks/typescript","keywords":["anseta","staking","restaking","ethereum","solana","cosmos","openapi","sdk"],"main":"./dist/index.js","module":"./dist/esm/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./package.json":"./package.json"},"engines":{"node":">=18"},"sideEffects":false,"scripts":{"prepare-spec":"node scripts/prepare-spec.mjs","generate":"pnpm run prepare-spec && pnpm run generate:code","generate:code":"rm -rf src && openapi-generator-cli generate","build":"pnpm run build:cjs && pnpm run build:esm","build:cjs":"tsc -p tsconfig.json","build:esm":"tsc -p tsconfig.esm.json && node scripts/fix-esm.mjs","typecheck":"tsc -p tsconfig.json --noEmit","typecheck:examples":"tsc -p tsconfig.examples.json","clean":"rm -rf dist","format":"prettier --write \"scripts/**/*.mjs\" \"examples/**/*.ts\"","prepublishOnly":"pnpm run clean && pnpm run build","changelog":"node scripts/changelog.mjs"},"devDependencies":{"@openapitools/openapi-generator-cli":"^2.15.3","@types/node":"^22.10.2","prettier":"^3.4.2","tsx":"^4.23.9","typescript":"^5.7.2"},"packageManager":"pnpm@10.33.0","publishConfig":{"access":"public"},"gitHead":"b4cce938e83021e4bd748de059a9be03439d6946","_id":"@anseta/typescript-sdk@0.2.0","bugs":{"url":"https://github.com/anseta-labs/typescript-sdk/issues"},"_nodeVersion":"22.23.2","_npmVersion":"12.0.2","dist":{"integrity":"sha512-4MI1vkG7uG2SddrlJg0q5KaSxz0Ok6GysJFLnWw05NbmUYfcWtnLSA/ooaGEAMPyUyKyn6zRJsXuW/DfkHuLuQ==","shasum":"a592ec7598d5be4b36facd4e470d90256a74e143","tarball":"https://registry.npmjs.org/@anseta/typescript-sdk/-/typescript-sdk-0.2.0.tgz","fileCount":887,"unpackedSize":2432167,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC41wlzbfV6lMTs2khEJC43q/EGwnOKBA7gka5VUPiJywIgQSg0R1Z0PrPx1RJGpVP0nDxKSCtpswNK/TOTTT5IDEU="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:a1c5f1dd-1c4c-404a-b23c-37a069112c81"}},"directories":{},"maintainers":[{"name":"dvisacker","email":"davidvanisacker@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-sdk_0.2.0_1788144635104_0.47488665465921387"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-27T07:58:26.239Z","modified":"2026-08-31T02:50:35.456Z","2.0.0":"2026-08-27T07:58:26.679Z","0.1.0":"2026-08-27T08:02:33.423Z","0.2.0":"2026-08-31T02:50:35.277Z"},"bugs":{"url":"https://github.com/anseta-labs/typescript-sdk/issues"},"license":"MIT","homepage":"https://docs.stakefi.network/docs/sdks/typescript","keywords":["anseta","staking","restaking","ethereum","solana","cosmos","openapi","sdk"],"repository":{"type":"git","url":"git+https://github.com/anseta-labs/typescript-sdk.git"},"description":"TypeScript client for the Anseta Developer API, generated from the OpenAPI specification","maintainers":[{"name":"dvisacker","email":"davidvanisacker@gmail.com"}],"readme":"# Anseta TypeScript SDK\n\n[![CI](https://github.com/anseta-labs/typescript-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/anseta-labs/typescript-sdk/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/@anseta/typescript-sdk.svg)](https://www.npmjs.com/package/@anseta/typescript-sdk)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\nType-safe TypeScript/JavaScript client for the [Anseta Developer API](https://docs.stakefi.network).\n\nThe code in `src/` is generated from the API's OpenAPI 3.1 specification with [OpenAPI Generator](https://openapi-generator.tech) (`typescript-fetch`). Do not edit it by hand: change the API spec and re-run `pnpm run generate`.\n\n## Install\n\n```bash\nnpm install @anseta/typescript-sdk\n# or\npnpm add @anseta/typescript-sdk\n```\n\nRequires Node.js 18 or newer (uses the global `fetch`). In older Node versions pass your own fetch implementation through `Configuration.fetchApi`.\n\n## Authenticate\n\nThe API takes an API key in the `x-api-key` header. Set `apiKey` on the `Configuration` and every request gets the header:\n\n```typescript\nimport { Configuration } from '@anseta/typescript-sdk';\n\nconst config = new Configuration({\n  basePath: 'https://preview.api.stakefi.network',\n  apiKey: process.env.ANSETA_API_KEY!,\n});\n```\n\nPassing it as a default header instead works the same way and is useful when you also want other headers:\n\n```typescript\nconst config = new Configuration({\n  headers: { 'x-api-key': process.env.ANSETA_API_KEY! },\n});\n```\n\n`basePath` defaults to `https://preview.api.stakefi.network`, so you only need to set it when pointing at another environment (for example `http://localhost:8081` in local development).\n\n## Usage\n\n```typescript\nimport {\n  Configuration,\n  APIInfoApi,\n  SimpleStakingApi,\n  SimplifiedStakeRequest,\n  StakingNetwork,\n  StakingToken,\n} from '@anseta/typescript-sdk';\n\nconst config = new Configuration({\n  apiKey: process.env.ANSETA_API_KEY!,\n});\n\nconst infoApi = new APIInfoApi(config);\nconst stakingApi = new SimpleStakingApi(config);\n\n// Every supported network\nconst networks = await infoApi.getNetworks({});\nconsole.log(networks.data);\n\n// Validators on one network\nconst validators = await stakingApi.getValidators({ network: StakingNetwork.Mantra });\nconsole.log(validators.data);\n\n// Staking positions for an address\nconst positions = await stakingApi.getStakingPositions({\n  staker: 'mantra1fz9hdjrupmtu6l490vurlj6d8dkp4t0p6gg57f',\n  validator: 'mantravaloper1r3s4pefpz69fk4rq8sn0zt2wxnv09uffz06nxu',\n  token: StakingToken.Mantra,\n  network: StakingNetwork.Mantra,\n});\nconsole.log(positions.data);\n\n// Build an unsigned stake transaction\nconst simplifiedStakeRequest: SimplifiedStakeRequest = {\n  network: StakingNetwork.Mantra,\n  token: StakingToken.Mantra,\n  // Base units, not whole tokens. MANTRA has 18 decimals, so this is 1 MANTRA.\n  amount: '1000000000000000000',\n  staker: 'mantra1fz9hdjrupmtu6l490vurlj6d8dkp4t0p6gg57f',\n  validator: 'mantravaloper1r3s4pefpz69fk4rq8sn0zt2wxnv09uffz06nxu',\n};\n\nconst stake = await stakingApi.createStake({ simplifiedStakeRequest });\nconsole.log(stake.data);\n\n// Daily reward history for a validator\nconst rewards = await stakingApi.getStakingDailyRewards({\n  validatorId: '53370563-e823-4d5d-8dd5-1c6b27a61a2a',\n  startDate: '2024-10-19',\n  endDate: '2024-10-31',\n});\nconsole.log(rewards.data);\n```\n\nMethods return the parsed response body directly. Use the `...Raw` variant of any method (for example `getNetworksRaw`) when you need the underlying `Response` object, its status code, or headers.\n\n## Networks and tokens\n\nNetwork and token values are shared enums, not per-endpoint ones. The lists genuinely differ by scope, so there are several:\n\n| Type | Values | Used by |\n|------|--------|---------|\n| `Network` | Every network the API knows about | `getNetworks` |\n| `StakingNetwork` | Networks that support staking | Staking endpoints, `getTokens`, `getStakingOptions` |\n| `RestakingNetwork` | `ethereum`, `ethereum-hoodi-testnet` | EigenLayer restaking endpoints |\n| `EthereumNetwork` | `ethereum`, `ethereum-hoodi-testnet` | Ethereum native staking endpoints |\n| `StakingToken` | Token symbols that can be staked | Staking endpoints |\n| `RestakingToken` | Token symbols that can be restaked | EigenLayer restaking endpoints |\n\nThese are `as const` objects plus string-literal union types, not TypeScript `enum`s, so a plain string literal works anywhere one is accepted.\n\n## API classes\n\n| Class | Covers |\n|-------|--------|\n| `APIInfoApi` | Networks, tokens, staking options, entities |\n| `SimpleStakingApi` | Validators, positions, delegation and reward history, stake/unstake/withdraw transactions |\n| `EigenlayerRestakingApi` | Operators, restaking positions and history, deposit/delegate/undelegate/unstake/withdraw transactions |\n| `EthereumStakingApi` | Provision, confirm, cancel, exit, force exit, and withdraw from your own Ethereum validators, plus validator listing and staking/reward history |\n| `SystemApi` | Health check and the OpenAPI spec endpoint |\n\n## Errors\n\nA non-2xx response throws a `ResponseError` carrying the raw `Response`:\n\n```typescript\nimport { ResponseError, StakingNetwork } from '@anseta/typescript-sdk';\n\ntry {\n  await stakingApi.getValidators({ network: StakingNetwork.Mantra });\n} catch (error) {\n  if (error instanceof ResponseError) {\n    console.error(error.response.status, await error.response.json());\n  } else {\n    throw error;\n  }\n}\n```\n\n`RequiredError` is thrown before any request is sent when a required parameter is missing.\n\n## Examples\n\nRunnable scripts live in `examples/`. Each one makes a single API call, with the addresses, validator IDs, amounts, and dates as plain constants at the top for you to edit. `ANSETA_API_KEY` is required; `ANSETA_BASE_URL` is optional and defaults to the preview host.\n\n```bash\nANSETA_API_KEY=... npx tsx examples/list-networks.ts\n\n# against a local API instead of the default preview host\nANSETA_API_KEY=... ANSETA_BASE_URL=http://localhost:8081 \\\n  npx tsx examples/list-networks.ts\n```\n\nThe addresses and IDs are real values from the Anseta validator set, so the scripts run as-is.\n\n| File | Calls |\n|------|-------|\n| `list-networks.ts` | `getNetworks` |\n| `list-tokens.ts` | `getTokens` |\n| `list-staking-options.ts` | `getStakingOptions` |\n| `list-entities.ts` | `getEntities` |\n| `list-validators.ts` | `getValidators` |\n| `get-staking-position.ts` | `getStakingPositions` |\n| `create-stake.ts` | `createStake` |\n| `create-unstake.ts` | `createUnstake` |\n| `daily-rewards.ts` | `getStakingDailyRewards` |\n| `delegation-history.ts` | `getStakingDelegationHistory` |\n| `list-ethereum-validators.ts` | `ethereumGetValidators` |\n| `provision-ethereum-validator.ts` | `ethereumStake` |\n| `list-restaking-operators.ts` | `getRestakingOperators` |\n| `restaking-deposit.ts` | `createRestakingDeposit` |\n| `restaking-delegate.ts` | `createRestakingDelegation` |\n\n`client.ts` holds the shared `Configuration` and is the only file that reads an environment variable.\n\n## Regenerating\n\n```bash\npnpm install\n\n# From the API repo's spec, which is what you normally want\nANSETA_SPEC=../stakefi-developer-api/openapi.json pnpm run generate\n\n# Or from a deployment\nANSETA_SPEC=https://preview.api.stakefi.network/v1/openapi.json pnpm run generate\n\npnpm run build\n```\n\nThere is no default spec source and `pnpm run generate` fails without one. That is deliberate: the deployed spec lags the API repo, and `generate` deletes `src/` before regenerating, so a silent fallback would quietly rebuild the client against an older API.\n\n`scripts/prepare-spec.mjs` writes `openapi.json` and pins `servers[0]` to `https://preview.api.stakefi.network`, which is what the generator turns into the default base path. The base URL is pinned here rather than read from the upstream spec, whose own server list has advertised hosts that do not resolve. Override it with `ANSETA_BASE_URL`.\n\n`pnpm run generate:code` regenerates from whatever `openapi.json` is already on disk, without fetching.\n\nGenerator settings live in `openapitools.json`. `.openapi-generator-ignore` keeps the generator from overwriting this repo's `package.json`, `tsconfig*.json`, `README.md`, `.gitignore`, and `.npmignore`.\n\nRequires a JDK on `PATH` (the generator runs as a jar).\n\n## Releasing\n\nSee [RELEASING.md](./RELEASING.md).\n\n## Scripts\n\n| Script | Does |\n|--------|------|\n| `pnpm run generate` | Fetch the spec (`ANSETA_SPEC`) and regenerate `src/` |\n| `pnpm run generate:code` | Regenerate `src/` from the existing `openapi.json` |\n| `pnpm run build` | Compile CommonJS to `dist/` and ESM to `dist/esm/` |\n| `pnpm run typecheck` | Type-check `src/` without emitting |\n| `pnpm run typecheck:examples` | Type-check `examples/` against `src/` |\n| `pnpm run format` | Prettier over `scripts/` and `examples/`, never the generated `src/` |\n","readmeFilename":"README.md"}