{"_id":"@5minbot/sdk","name":"@5minbot/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@5minbot/sdk","version":"0.1.0","description":"Official JavaScript SDK for the 5minbot API","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"node build.mjs","typecheck":"tsc --project tsconfig.json --noEmit","test":"node --import tsx --test src/index.test.ts","verify":"npm run typecheck && npm run test && npm run build"},"keywords":["5minbot","chatbot","sdk","api"],"author":{"name":"founder@5minbot.com"},"license":"MIT","engines":{"node":">=18"},"_id":"@5minbot/sdk@0.1.0","gitHead":"87992af1fa43c1a8112fa57a1e721748de08ddf8","_nodeVersion":"24.13.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-SP2mi3+Mqd+dXYvgfw4dG0a3dkKXD3I/ROIvRYbi/Qeq4C1b8werDpFLiLyZ6P1swfhXaerob+X8A50ikufZxA==","shasum":"5f9e14b3173835309507de86ac3555a5dfa51ee5","tarball":"https://registry.npmjs.org/@5minbot/sdk/-/sdk-0.1.0.tgz","fileCount":6,"unpackedSize":19866,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHrFGem/E/AhV3faUjHAEM+2rFL5EfISbAkw2wS/IpWfAiEAue97PZXrs40+APHnXNhyBD6ysx3Tkm4I/iBWFXIaPZk="}]},"_npmUser":{"name":"aikinley","email":"aikinley123@gmail.com"},"directories":{},"maintainers":[{"name":"aikinley","email":"aikinley123@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.0_1779174127220_0.4475755934068302"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-19T07:02:07.114Z","0.1.0":"2026-05-19T07:02:07.366Z","modified":"2026-05-19T07:02:07.629Z"},"maintainers":[{"name":"aikinley","email":"aikinley123@gmail.com"}],"description":"Official JavaScript SDK for the 5minbot API","keywords":["5minbot","chatbot","sdk","api"],"author":{"name":"founder@5minbot.com"},"license":"MIT","readme":"# @5minbot/sdk\n\nOfficial JavaScript SDK for the [5minbot API](https://5minbot.com/docs/api). Zero dependencies. Works in Node 18+, browsers, Cloudflare Workers, and Deno.\n\n## Installation\n\n```bash\nnpm install @5minbot/sdk\n```\n\n## Quickstart\n\n```js\nimport { FiveMinBotClient } from '@5minbot/sdk';\n\nconst client = new FiveMinBotClient({ apiKey: process.env.FIVEMINBOT_KEY });\n\n// List all bots in your account\nconst bots = await client.bots.list();\nconsole.log(bots);\n\n// Chat with a bot\nconst reply = await client.bots.chat('my-bot-slug', { message: 'Hello!' });\nconsole.log(reply.reply);\n```\n\nGenerate an API key in [Dashboard → Settings → API keys](https://5minbot.com/dashboard/settings/api-keys).\n\n## API Reference\n\n### `new FiveMinBotClient(options)`\n\n| Option    | Type     | Required | Default               | Description                         |\n| --------- | -------- | -------- | --------------------- | ----------------------------------- |\n| `apiKey`  | `string` | Yes      | —                     | Your API key (`Bearer` token)       |\n| `baseUrl` | `string` | No       | `https://5minbot.com` | Override for self-hosted or testing |\n| `timeout` | `number` | No       | `30000`               | Request timeout in milliseconds     |\n\n### `client.bots.list()`\n\nReturns the list of bots owned by your API key.\n\n```ts\nconst bots: Bot[] = await client.bots.list();\n// [{ id, name, slug, status, createdAt }]\n```\n\n**Bot shape:**\n\n```ts\ninterface Bot {\n  id: string;\n  name: string;\n  slug: string;\n  status: string; // \"active\" | \"draft\" | ...\n  createdAt: string; // ISO 8601\n}\n```\n\n**Errors:** `AuthError` (401), `RateLimitError` (429).\n\n---\n\n### `client.bots.chat(slug, options)`\n\nSend a message to a bot and receive a complete (non-streaming) JSON reply.\n\n```ts\nconst response: ChatResponse = await client.bots.chat('my-bot-slug', {\n  message: 'What is your return policy?',\n});\nconsole.log(response.reply);\n```\n\n**ChatOptions:**\n\n| Field     | Type     | Required | Description       |\n| --------- | -------- | -------- | ----------------- |\n| `message` | `string` | Yes      | 1–4000 characters |\n\n**ChatResponse shape:**\n\n```ts\ninterface ChatResponse {\n  reply: string;\n  conversationId: string; // persists across calls (same key + slug)\n  tokensIn: number;\n  tokensOut: number;\n}\n```\n\n**Errors:** `AuthError` (401), `NotFoundError` (404), `RateLimitError` (429), `FiveMinBotError` (400, 502).\n\n---\n\n## Error handling\n\nAll errors extend `FiveMinBotError`.\n\n```ts\nimport {\n  FiveMinBotError,\n  AuthError,\n  NotFoundError,\n  RateLimitError,\n} from '@5minbot/sdk';\n\ntry {\n  await client.bots.chat('my-bot', { message: 'Hello' });\n} catch (err) {\n  if (err instanceof RateLimitError) {\n    console.log(`Retry after ${err.retryAfter}s`);\n  } else if (err instanceof AuthError) {\n    console.error('Check your API key');\n  } else if (err instanceof NotFoundError) {\n    console.error('Bot not found — check the slug');\n  } else if (err instanceof FiveMinBotError) {\n    console.error(`API error ${err.status}: ${err.code} — ${err.message}`);\n  } else {\n    throw err; // network error, etc.\n  }\n}\n```\n\n### Error class hierarchy\n\n```\nError\n└── FiveMinBotError          (.status, .code, .message)\n    ├── AuthError            401 — invalid or missing API key\n    ├── NotFoundError        404 — bot not found or not active\n    └── RateLimitError       429 — rate limit or plan cap (.retryAfter in seconds, nullable)\n```\n\n`timeout` aborts with `FiveMinBotError { status: 0, code: \"timeout\" }`.\n\n---\n\n## CommonJS usage\n\n```js\nconst { FiveMinBotClient } = require('@5minbot/sdk');\n```\n\n## TypeScript\n\nThe SDK is written in TypeScript. All types are bundled in `dist/index.d.ts` — no `@types/` package needed.\n\n## Links\n\n- [API Reference](https://5minbot.com/docs/api)\n- [Dashboard](https://5minbot.com/dashboard)\n- [Changelog](https://5minbot.com/changelog)\n","readmeFilename":"README.md","_rev":"1-8c42cfeac7210e2d5d110ba3333b4f76"}