{"_id":"@anagramagames/sdk","_rev":"3-78c61e673b9a764e33cad9948b328ae6","name":"@anagramagames/sdk","dist-tags":{"latest":"0.6.0"},"versions":{"0.3.0":{"name":"@anagramagames/sdk","version":"0.3.0","author":{"name":"Anagrama"},"license":"Apache-2.0","_id":"@anagramagames/sdk@0.3.0","maintainers":[{"name":"rickyanagrama","email":"rickyplummer2004@gmail.com"}],"homepage":"https://github.com/AnagramaGames/anagrama-typescript#readme","bugs":{"url":"https://github.com/AnagramaGames/anagrama-typescript/issues"},"dist":{"shasum":"dd1cf0d3927821f3b0827f0716c008d378dd77eb","tarball":"https://registry.npmjs.org/@anagramagames/sdk/-/sdk-0.3.0.tgz","fileCount":361,"integrity":"sha512-mLf/wawVCTs3XB1PR5IiNveHf2HIbr1YFo7Q2nb6HRMEYwEQSsyGdEu9FWVl65leMja5VP1y9Rux+k+6lzaygQ==","signatures":[{"sig":"MEYCIQDz8+mC1h4L3sdOFdLNo+1PaO8DY86DxbvQE4PHh0PvNAIhAJI0Cg5zGC4gpUagwffh5RI8no3AZSCv48dGUBhDzRfL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":578468},"main":"./index.js","type":"commonjs","types":"./index.d.ts","exports":{".":{"types":"./index.d.mts","default":"./index.mjs","require":{"types":"./index.d.ts","default":"./index.js"}},"./error":{"import":"./error.mjs","require":"./error.js"},"./index":{"import":"./index.mjs","require":"./index.js"},"./client":{"import":"./client.mjs","require":"./client.js"},"./core/*":{"import":"./core/*.mjs","require":"./core/*.js"},"./uploads":{"import":"./uploads.mjs","require":"./uploads.js"},"./version":{"import":"./version.mjs","require":"./version.js"},"./error.js":{"default":"./error.js"},"./index.js":{"default":"./index.js"},"./resource":{"import":"./resource.mjs","require":"./resource.js"},"./client.js":{"default":"./client.js"},"./core/*.js":{"default":"./core/*.js"},"./error.mjs":{"default":"./error.mjs"},"./index.mjs":{"default":"./index.mjs"},"./resources":{"import":"./resources.mjs","require":"./resources.js"},"./client.mjs":{"default":"./client.mjs"},"./core/*.mjs":{"default":"./core/*.mjs"},"./uploads.js":{"default":"./uploads.js"},"./version.js":{"default":"./version.js"},"./api-promise":{"import":"./api-promise.mjs","require":"./api-promise.js"},"./resource.js":{"default":"./resource.js"},"./resources/*":{"import":"./resources/*.mjs","require":"./resources/*.js"},"./uploads.mjs":{"default":"./uploads.mjs"},"./version.mjs":{"default":"./version.mjs"},"./resource.mjs":{"default":"./resource.mjs"},"./resources.js":{"default":"./resources.js"},"./resources.mjs":{"default":"./resources.mjs"},"./api-promise.js":{"default":"./api-promise.js"},"./resources/*.js":{"default":"./resources/*.js"},"./api-promise.mjs":{"default":"./api-promise.mjs"},"./resources/*.mjs":{"default":"./resources/*.mjs"}},"gitHead":"4b6fb5a88bb35afc43d40ce61cc4bcac5e081d1c","private":false,"scripts":{"fix":"./scripts/format","tsn":"ts-node -r tsconfig-paths/register","lint":"./scripts/lint","test":"./scripts/test","build":"./scripts/build","format":"./scripts/format"},"_npmUser":{"name":"rickyanagrama","email":"rickyplummer2004@gmail.com"},"repository":{"url":"git+https://github.com/AnagramaGames/anagrama-typescript.git","type":"git"},"_npmVersion":"10.9.4","description":"The official TypeScript library for the Anagrama API","directories":{},"_nodeVersion":"22.21.1","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.27.0","_npmOperationalInternal":{"tmp":"tmp/sdk_0.3.0_1770669942525_0.2779720346583694","host":"s3://npm-registry-packages-npm-production"}},"0.3.1":{"name":"@anagramagames/sdk","version":"0.3.1","author":{"name":"Anagrama"},"license":"Apache-2.0","_id":"@anagramagames/sdk@0.3.1","maintainers":[{"name":"rickyanagrama","email":"rickyplummer2004@gmail.com"}],"homepage":"https://github.com/AnagramaGames/anagrama-typescript#readme","bugs":{"url":"https://github.com/AnagramaGames/anagrama-typescript/issues"},"dist":{"shasum":"71c8029705c8495693f0f3ec383acf77b32e4135","tarball":"https://registry.npmjs.org/@anagramagames/sdk/-/sdk-0.3.1.tgz","fileCount":361,"integrity":"sha512-1j56B3d/X5RuLSL//eZ/xr3OpTj7CrPZ+D8MuTtNAcsQ37pJ+J1BteN+djiauIA9gj7uNQh0VHCj6q/dO77xbg==","signatures":[{"sig":"MEQCIDxC6LuKciNrCrJmdob3980lq0rFsXKiOB/GrOSI1c00AiBLC2WRLVsWzO+WrHP79mh7FAOTaQ38wftRgdDGIpQxiA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":574290},"main":"./index.js","type":"commonjs","types":"./index.d.ts","exports":{".":{"types":"./index.d.mts","default":"./index.mjs","require":{"types":"./index.d.ts","default":"./index.js"}},"./error":{"import":"./error.mjs","require":"./error.js"},"./index":{"import":"./index.mjs","require":"./index.js"},"./client":{"import":"./client.mjs","require":"./client.js"},"./core/*":{"import":"./core/*.mjs","require":"./core/*.js"},"./uploads":{"import":"./uploads.mjs","require":"./uploads.js"},"./version":{"import":"./version.mjs","require":"./version.js"},"./error.js":{"default":"./error.js"},"./index.js":{"default":"./index.js"},"./resource":{"import":"./resource.mjs","require":"./resource.js"},"./client.js":{"default":"./client.js"},"./core/*.js":{"default":"./core/*.js"},"./error.mjs":{"default":"./error.mjs"},"./index.mjs":{"default":"./index.mjs"},"./resources":{"import":"./resources.mjs","require":"./resources.js"},"./client.mjs":{"default":"./client.mjs"},"./core/*.mjs":{"default":"./core/*.mjs"},"./uploads.js":{"default":"./uploads.js"},"./version.js":{"default":"./version.js"},"./api-promise":{"import":"./api-promise.mjs","require":"./api-promise.js"},"./resource.js":{"default":"./resource.js"},"./resources/*":{"import":"./resources/*.mjs","require":"./resources/*.js"},"./uploads.mjs":{"default":"./uploads.mjs"},"./version.mjs":{"default":"./version.mjs"},"./resource.mjs":{"default":"./resource.mjs"},"./resources.js":{"default":"./resources.js"},"./resources.mjs":{"default":"./resources.mjs"},"./api-promise.js":{"default":"./api-promise.js"},"./resources/*.js":{"default":"./resources/*.js"},"./api-promise.mjs":{"default":"./api-promise.mjs"},"./resources/*.mjs":{"default":"./resources/*.mjs"}},"gitHead":"2f0eaf1ac2c9db06c99f10acad75c276cb942801","private":false,"scripts":{"fix":"./scripts/format","tsn":"ts-node -r tsconfig-paths/register","lint":"./scripts/lint","test":"./scripts/test","build":"./scripts/build","format":"./scripts/format"},"_npmUser":{"name":"rickyanagrama","email":"rickyplummer2004@gmail.com"},"repository":{"url":"git+https://github.com/AnagramaGames/anagrama-typescript.git","type":"git"},"_npmVersion":"10.9.4","description":"The official TypeScript library for the Anagrama API","directories":{},"_nodeVersion":"22.21.1","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.27.0","_npmOperationalInternal":{"tmp":"tmp/sdk_0.3.1_1770693780335_0.11246928163526415","host":"s3://npm-registry-packages-npm-production"}},"0.6.0":{"name":"@anagramagames/sdk","version":"0.6.0","description":"The official TypeScript library for the Anagrama API","author":{"name":"Anagrama"},"types":"./index.d.ts","main":"./index.js","type":"commonjs","repository":{"type":"git","url":"git+https://github.com/AnagramaGames/anagrama-typescript.git"},"license":"Apache-2.0","packageManager":"pnpm@10.27.0","private":false,"publishConfig":{"access":"public"},"scripts":{"test":"./scripts/test","build":"./scripts/build","format":"./scripts/format","tsn":"ts-node -r tsconfig-paths/register","lint":"./scripts/lint","fix":"./scripts/format"},"dependencies":{},"exports":{".":{"require":{"types":"./index.d.ts","default":"./index.js"},"types":"./index.d.mts","default":"./index.mjs"},"./api-promise":{"import":"./api-promise.mjs","require":"./api-promise.js"},"./api-promise.js":{"default":"./api-promise.js"},"./api-promise.mjs":{"default":"./api-promise.mjs"},"./client":{"import":"./client.mjs","require":"./client.js"},"./client.js":{"default":"./client.js"},"./client.mjs":{"default":"./client.mjs"},"./core/*.mjs":{"default":"./core/*.mjs"},"./core/*.js":{"default":"./core/*.js"},"./core/*":{"import":"./core/*.mjs","require":"./core/*.js"},"./error":{"import":"./error.mjs","require":"./error.js"},"./error.js":{"default":"./error.js"},"./error.mjs":{"default":"./error.mjs"},"./index":{"import":"./index.mjs","require":"./index.js"},"./index.js":{"default":"./index.js"},"./index.mjs":{"default":"./index.mjs"},"./resource":{"import":"./resource.mjs","require":"./resource.js"},"./resource.js":{"default":"./resource.js"},"./resource.mjs":{"default":"./resource.mjs"},"./resources/*.mjs":{"default":"./resources/*.mjs"},"./resources/*.js":{"default":"./resources/*.js"},"./resources/*":{"import":"./resources/*.mjs","require":"./resources/*.js"},"./resources":{"import":"./resources.mjs","require":"./resources.js"},"./resources.js":{"default":"./resources.js"},"./resources.mjs":{"default":"./resources.mjs"},"./uploads":{"import":"./uploads.mjs","require":"./uploads.js"},"./uploads.js":{"default":"./uploads.js"},"./uploads.mjs":{"default":"./uploads.mjs"},"./version":{"import":"./version.mjs","require":"./version.js"},"./version.js":{"default":"./version.js"},"./version.mjs":{"default":"./version.mjs"}},"_id":"@anagramagames/sdk@0.6.0","gitHead":"dc25efc595a1031c166b145f6d4593f0ffea2fb9","bugs":{"url":"https://github.com/AnagramaGames/anagrama-typescript/issues"},"homepage":"https://github.com/AnagramaGames/anagrama-typescript#readme","_nodeVersion":"22.14.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-eBQy7GYq8FnxXfQASFZLy5NsRpa46c/VmheRgzmFT3M3EYethNeN+iYhtaTl9iOM3bPTn99A3ZbJlzxG7MNp4g==","shasum":"6a4b7fd3a420ea00441278376db12a10f458a9bc","tarball":"https://registry.npmjs.org/@anagramagames/sdk/-/sdk-0.6.0.tgz","fileCount":361,"unpackedSize":574290,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICw6JQO0jn0a3LdaK33HepecEIvvjvR8D5hZTMNg3Qt/AiBQnzjyoUdw8WoAnxwjz1xedZGTl3xaIplikqeIftssPw=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8da65651-1d02-48a9-934a-a7aae326a730"}},"directories":{},"maintainers":[{"name":"rickyanagrama","email":"rickyplummer2004@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.6.0_1771267935829_0.04682482348817407"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-09T20:45:42.293Z","modified":"2026-02-16T18:52:16.117Z","0.3.0":"2026-02-09T20:45:42.690Z","0.3.1":"2026-02-10T03:23:00.527Z","0.6.0":"2026-02-16T18:52:15.993Z"},"bugs":{"url":"https://github.com/AnagramaGames/anagrama-typescript/issues"},"author":{"name":"Anagrama"},"license":"Apache-2.0","homepage":"https://github.com/AnagramaGames/anagrama-typescript#readme","repository":{"type":"git","url":"git+https://github.com/AnagramaGames/anagrama-typescript.git"},"description":"The official TypeScript library for the Anagrama API","maintainers":[{"name":"rickyanagrama","email":"rickyplummer2004@gmail.com"}],"readme":"# Anagrama TypeScript SDK\n\n[![NPM version](https://img.shields.io/npm/v/@anagramagames/sdk.svg)](https://npmjs.org/package/@anagramagames/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@anagramagames/sdk)\n\nThe official TypeScript/JavaScript SDK for the [Anagrama API](https://playanagrama.com/docs).\n\n## Installation\n\n```sh\nnpm install @anagramagames/sdk\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n<!-- prettier-ignore -->\n```js\nimport Anagrama from '@anagramagames/sdk';\n\nconst client = new Anagrama({\n  apiKey: process.env['ANAGRAMA_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.words.getRandom({\n  count: 3,\n  maxLength: 8,\n  minLength: 5,\n});\n\nconsole.log(response.count);\n```\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n<!-- prettier-ignore -->\n```ts\nimport Anagrama from '@anagramagames/sdk';\n\nconst client = new Anagrama({\n  apiKey: process.env['ANAGRAMA_API_KEY'], // This is the default and can be omitted\n});\n\nconst params: Anagrama.WordGetRandomParams = {\n  count: 3,\n  maxLength: 8,\n  minLength: 5,\n};\nconst response: Anagrama.WordGetRandomResponse = await client.words.getRandom(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n<!-- prettier-ignore -->\n```ts\nconst response = await client.words\n  .getRandom({\n    count: 3,\n    maxLength: 8,\n    minLength: 5,\n  })\n  .catch(async (err) => {\n    if (err instanceof Anagrama.APIError) {\n      console.log(err.status); // 400\n      console.log(err.name); // BadRequestError\n      console.log(err.headers); // {server: 'nginx', ...}\n    } else {\n      throw err;\n    }\n  });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type                 |\n| ----------- | -------------------------- |\n| 400         | `BadRequestError`          |\n| 401         | `AuthenticationError`      |\n| 403         | `PermissionDeniedError`    |\n| 404         | `NotFoundError`            |\n| 422         | `UnprocessableEntityError` |\n| 429         | `RateLimitError`           |\n| >=500       | `InternalServerError`      |\n| N/A         | `APIConnectionError`       |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n<!-- prettier-ignore -->\n```js\n// Configure the default for all requests:\nconst client = new Anagrama({\n  maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.words.getRandom({\n  count: 3,\n  maxLength: 8,\n  minLength: 5,\n}, {\n  maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n<!-- prettier-ignore -->\n```ts\n// Configure the default for all requests:\nconst client = new Anagrama({\n  timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.words.getRandom({\n  count: 3,\n  maxLength: 8,\n  minLength: 5,\n}, {\n  timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n<!-- prettier-ignore -->\n```ts\nconst client = new Anagrama();\n\nconst response = await client.words\n  .getRandom({\n    count: 3,\n    maxLength: 8,\n    minLength: 5,\n  })\n  .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.words\n  .getRandom({\n    count: 3,\n    maxLength: 8,\n    minLength: 5,\n  })\n  .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.count);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `ANAGRAMA_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport Anagrama from '@anagramagames/sdk';\n\nconst client = new Anagrama({\n  logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport Anagrama from '@anagramagames/sdk';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new Anagrama({\n  logger: logger.child({ name: 'Anagrama' }),\n  logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/AnagramaGames/anagrama-typescript/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n","readmeFilename":"README.md"}