{"_id":"@askchannelai/sdk","_rev":"3-5dcb9b8ad40888bbc8c9359dff35315e","name":"@askchannelai/sdk","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.0":{"name":"@askchannelai/sdk","version":"0.1.0","keywords":["askchannel","youtube","transcripts","rag","chatbot","telegram","discord"],"license":"MIT","_id":"@askchannelai/sdk@0.1.0","maintainers":[{"name":"askchannel","email":"beastse@gmail.com"}],"dist":{"shasum":"85ccbb13776a75efaf7cbe7c68bcd35657b85fe6","tarball":"https://registry.npmjs.org/@askchannelai/sdk/-/sdk-0.1.0.tgz","fileCount":6,"integrity":"sha512-W9YBnPCEKBsgbA407IMb1lA0kfJye0ikAXmrmUsfS1H0L1L29B+ih/6QZ4DMKAmyWZGETUZldk51tDu5HZ+hjQ==","signatures":[{"sig":"MEUCIQDmGuVxmeyT3/4uUwL56EefhJ4NxDmSeaNc2Ib40dXIswIgXJBzhH/nr4k5VTycgdcN4nXpYdWpi6MUAckyx4cZyv4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30106},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"dcd69c2d2f4f025fce6fefc974c022c1e92d4f6b","scripts":{"build":"tsup src/index.ts --format esm,cjs --dts --clean","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"askchannel","email":"beastse@gmail.com"},"_npmVersion":"11.12.1","description":"Tiny, dependency-free client for the AskChannel API — ask cited questions over a YouTube channel's transcripts.","directories":{},"_nodeVersion":"25.9.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1780770094265_0.5801823569957356","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@askchannelai/sdk","version":"0.2.0","keywords":["askchannel","youtube","transcripts","rag","chatbot","telegram","discord"],"license":"MIT","_id":"@askchannelai/sdk@0.2.0","maintainers":[{"name":"askchannel","email":"beastse@gmail.com"}],"dist":{"shasum":"850472d5c6b153f6a3ab05ebf3a7cb113e98ed80","tarball":"https://registry.npmjs.org/@askchannelai/sdk/-/sdk-0.2.0.tgz","fileCount":6,"integrity":"sha512-fG44Wue6B35hUFCZq8PDkXbe3g5aEFy9h+CTqaVmnQGhtNOQb6lX0rrCLW8Q01rzTB0Pan7TAVMnlHSo7zqdjQ==","signatures":[{"sig":"MEUCIQCfB6Fdhc4os32+WbOfhF5ipMasUFbw0tC7WDg2kR9ofgIgch02xw5KnUsa9uRxtO/dmBHPM6F/UxCZr8a/qpp2NH4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53248},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"261e7c44d7f2cdf914ea42c6d911d918fc81ad65","scripts":{"build":"tsup src/index.ts --format esm,cjs --dts --clean","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"askchannel","email":"beastse@gmail.com"},"_npmVersion":"11.12.1","description":"Tiny, dependency-free client for the AskChannel API — ask cited questions over a YouTube channel's transcripts.","directories":{},"_nodeVersion":"25.9.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.2.0_1780774756036_0.2003477490607828","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@askchannelai/sdk","version":"0.3.0","description":"Tiny, dependency-free client for the AskChannel API — ask cited questions over a YouTube channel's transcripts.","keywords":["askchannel","youtube","transcripts","rag","chatbot","telegram","discord"],"license":"MIT","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18"},"scripts":{"build":"tsup src/index.ts --format esm,cjs --dts --clean","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"devDependencies":{"tsup":"^8.0.0","typescript":"^5.4.0"},"publishConfig":{"access":"public"},"gitHead":"220ef19065a3301794da52cfa1dc3c87ef0ca5f0","_id":"@askchannelai/sdk@0.3.0","_nodeVersion":"25.9.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-f0zvnueqEP2VhpBDnW90iJMHp8x2BvYet3Fv8DP2HTHwnj5K44p7OITkaowKwcIJ7/1k/kKJuI87sVMvEmlJ/w==","shasum":"92303d13ddbe5d3a73339feb2425ec0aa267c28a","tarball":"https://registry.npmjs.org/@askchannelai/sdk/-/sdk-0.3.0.tgz","fileCount":6,"unpackedSize":55168,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDyIfO36LT84BvwqWnCl896EgA+wggERZVcWwPPSsm31QIgJMvSMLyw9JV+jAYRaPnx3EVxYeZc2nvjeU4MrHB6yA0="}]},"_npmUser":{"name":"askchannel","email":"beastse@gmail.com"},"directories":{},"maintainers":[{"name":"askchannel","email":"beastse@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.3.0_1780791392090_0.01915510602811832"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-06T18:21:34.067Z","modified":"2026-06-07T00:16:32.400Z","0.1.0":"2026-06-06T18:21:34.400Z","0.2.0":"2026-06-06T19:39:16.169Z","0.3.0":"2026-06-07T00:16:32.260Z"},"license":"MIT","keywords":["askchannel","youtube","transcripts","rag","chatbot","telegram","discord"],"description":"Tiny, dependency-free client for the AskChannel API — ask cited questions over a YouTube channel's transcripts.","maintainers":[{"name":"askchannel","email":"beastse@gmail.com"}],"readme":"# @askchannelai/sdk\n\nTiny, **dependency-free** TypeScript client for the [AskChannel](https://askchannel.ai)\nAPI. Ask cited questions over a YouTube channel's transcripts and search the\nchannels you can ask. Works anywhere `fetch` exists — bots, web apps, edge, CLIs.\n\n```bash\nnpm i @askchannelai/sdk\n```\n\n> Requires Node 18+ (or any runtime with a global `fetch`).\n\n## Quick start\n\n```ts\nimport { createAskChannelClient } from \"@askchannelai/sdk\";\n\nconst ac = createAskChannelClient({ token: process.env.ASKCHANNEL_TOKEN });\n\nconst res = await ac.ask({\n  channel: \"@hubermanlab\",          // @handle (with/without @) or a UC… id\n  question: \"What's the best time to drink coffee?\",\n});\n\nconsole.log(res.answer);            // clean prose, no inline markers\nfor (const c of res.citations) {\n  console.log(`${c.videoTitle} → ${c.url}`); // deep-linked to the timestamp\n}\n```\n\n## Get a token\n\n`ask()` needs a **premium** AskChannel API token (starts with `askchannelai_`),\ncreated in your AskChannel account (Account → API). One token = one account; all\ncalls share that account's daily question quota. `searchChannels()` is public\nand needs no token.\n\n## Ready-to-send chat rendering\n\nPass `platform` and the response gains a `rendered` field already formatted for\nthat app — so a bot can forward it verbatim with no citation-formatting code:\n\n```ts\nconst res = await ac.ask({\n  channel: \"@lexfridman\",\n  question: \"What does he think about AGI timelines?\",\n  platform: \"telegram\",            // telegram | discord | whatsapp | slack\n});\n\n// HTML for telegram, mrkdwn for slack/whatsapp:\nbot.sendMessage(chatId, res.rendered as string, { parse_mode: \"HTML\" });\n// discord returns { content, embeds } instead of a string.\n```\n\n## Search the channels you can ask\n\n```ts\nconst channels = await ac.searchChannels(\"rogan\");\n// → [{ id, title, handle: \"@joerogan\", thumbnail, videoCount, ... }]\n```\n\nThis hits the **indexed-channels** search (only channels already on AskChannel),\nwhich is what you want for a \"pick a channel\" dropdown. Returns `[]` for an empty\nquery and degrades to `[]` (rather than throwing) on a search-side error.\n\n## Errors\n\nEvery call throws `AskChannelError` on failure, with a stable `code` you can\nswitch on:\n\n```ts\nimport { isAskChannelError } from \"@askchannelai/sdk\";\n\ntry {\n  await ac.ask({ channel: \"@unknown\", question: \"hi\" });\n} catch (e) {\n  if (isAskChannelError(e)) {\n    switch (e.code) {\n      case \"not_found\":      /* channel not indexed */ break;\n      case \"quota_exceeded\": /* 403 daily limit */ break;\n      case \"unauthorized\":   /* 401 bad/non-premium token */ break;\n      case \"rate_limited\":   /* 429 burst */ break;\n      case \"server_error\":   /* 5xx outage */ break;\n      case \"network\":        /* timeout / DNS / abort */ break;\n    }\n  }\n}\n```\n\n## API\n\n### `new AskChannelClient(options)` / `createAskChannelClient(options)`\n\n| Option | Default | Notes |\n|--------|---------|-------|\n| `token` | — | Premium `askchannelai_…` token. Required for `ask()`. |\n| `baseUrl` | `https://askchannel.ai` | API origin. |\n| `defaultProvider` | `gemini` | `gemini` (faster) or `claude`. |\n| `timeoutMs` | `70000` | Default per-call timeout. |\n| `fetch` | global `fetch` | Inject a custom fetch. |\n\n### `ask(params) → Promise<AskResponse>`\n`{ channel, question, provider?, platform?, signal?, timeoutMs? }` →\n`{ answer, citations[], provider, rendered? }`.\n\n### `searchChannels(query, opts?) → Promise<Channel[]>`\nIndexed-channel search by title or handle.\n\n## Building a Telegram bot?\n\nSee [`examples/telegram-bot`](../../examples/telegram-bot) — a complete bot with\nan inline channel-picker dropdown built on this SDK.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}