{"id":14007034,"url":"https://github.com/AHGGG/poe-node-api","last_synced_at":"2025-07-24T00:32:49.332Z","repository":{"id":154461766,"uuid":"632282220","full_name":"AHGGG/poe-node-api","owner":"AHGGG","description":"A reverse engineered Node.js client for Quora's Poe.","archived":true,"fork":false,"pushed_at":"2023-07-09T04:26:09.000Z","size":79,"stargazers_count":36,"open_issues_count":6,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T14:57:59.850Z","etag":null,"topics":["api","chatgpt","claude","gpt-4","node","poe","sage"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AHGGG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-04-25T05:03:44.000Z","updated_at":"2024-03-09T13:19:19.000Z","dependencies_parsed_at":"2023-07-19T00:00:19.052Z","dependency_job_id":null,"html_url":"https://github.com/AHGGG/poe-node-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AHGGG%2Fpoe-node-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AHGGG%2Fpoe-node-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AHGGG%2Fpoe-node-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AHGGG%2Fpoe-node-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AHGGG","download_url":"https://codeload.github.com/AHGGG/poe-node-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227384092,"owners_count":17772311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","chatgpt","claude","gpt-4","node","poe","sage"],"created_at":"2024-08-10T10:01:46.844Z","updated_at":"2024-11-30T17:31:45.002Z","avatar_url":"https://github.com/AHGGG.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# poe-api-node\r\nA reverse engineered Node.js client for Quora's Poe. \r\n\r\nSupport: Fetch needed info and write to .env file | send messages to different bot | set up proxies | clear/delete/purge messages | get history messages | get bot info | get next data\r\n\r\n\u003e I'm still working on this, so it's might not stable. If your meet any problems, please create an issue.\r\n- [poe-api-node](#poe-api-node)\r\n  - [Install](#install)\r\n  - [Usage](#usage)\r\n    - [SendMessage](#sendmessage)\r\n    - [AddChatBreak](#addchatbreak)\r\n    - [DeleteMessage](#deletemessage)\r\n    - [PurgeAllMessage](#purgeallmessage)\r\n    - [GetHistory](#gethistory)\r\n    - [GetBotInfo](#getbotinfo)\r\n    - [GetNextData](#getnextdata)\r\n    - [UpdateAllBotInfo](#updateallbotinfo)\r\n  - [Example](#example)\r\n    - [SendMessage](#sendmessage-1)\r\n    - [Multi-account support](#multi-account-support)\r\n    - [SetProxy](#setproxy)\r\n    - [History](#history)\r\n    - [FetchAllNeededInfo](#fetchallneededinfo)\r\n  - [TODO](#todo)\r\n  - [Notes](#notes)\r\n  - [Thanks](#thanks)\r\n  - [License](#license)\r\n\r\n## Install\r\n```bash\r\nnpm install poe-node-api\r\n```\r\n\u003e requirement: \r\n\u003e - node \u003e= 18\r\n\u003e - .env: To store needed params like `poe-formkey` / `cookie` / `buildId` / botId.....\r\n\r\n## Usage\r\n1. Get cookie from poe.com: F12 / inspect, Application \u003e Cookies \u003e https://poe.com \u003e p-b\r\n\r\n2. Create .env file in your project root path, and add cookie to .env file\r\n```env\r\ncookie=p-b=xxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n```\r\n\r\n3. Fetch all needed info\r\n```ts\r\nconst client = new PoeClient({logLevel: 'debug'});\r\nawait client.init()\r\n// If no poe-formkey and buildId in .env file, client will download needed params, next time will not need to fetch these params again until cookie is changed/logout(For now).\r\n```\r\n- [UpdateAllBotInfo](#updateallbotinfo)\r\n\r\nHow to create a client:\r\n```ts\r\nimport {PoeClient} from \"poe-node-api\";\r\n\r\nconst client = new PoeClient({logLevel: 'debug'});\r\n```\r\n- cookie?: string\r\n- env?: [ProcessEnv](https://github.com/AHGGG/poe-node-api/blob/dev/src/types/index.d.ts#L66)(Default: process.env). for multi-account use, user can pass envMap to constructor, client will read needed info from that envMap\r\n- logLevel?: string(Default: 'info'). enable debug console output\r\n- fetch?: FetchFunction\r\n  - type FetchFunction = typeof fetch\r\n- retry?: number(Default: 5).\r\n- retryMsInterval?: number(Default: 2000).\r\n- proxy?: [ProxyInfo](https://github.com/AHGGG/poe-node-api/blob/dev/src/types/index.d.ts#L12)\r\n\r\nHow to init client\r\n```ts\r\nawait client.init()\r\n```\r\n- rewriteToLocalEnvFile: boolean = true. This means that the client will retrieve necessary parameters like `buildId` / `poe-formkey` and overwrite them in the local '.env' file.\r\n\u003e To prevent conflicts, when using multi-account, you should set `rewriteToLocalEnvFile` to false\r\n\r\nBot nicknames\r\n\r\nbotNickName \u003c==\u003e botDisplayName\r\n\u003e - a2 \u003c==\u003e Claude-instant\r\n\u003e - a2_2 \u003c==\u003e Claude+\r\n\u003e - beaver \u003c==\u003e GPT-4\r\n\u003e - capybara \u003c==\u003e Sage\r\n\u003e - nutria \u003c==\u003e Dragonfly\r\n\u003e - chinchilla \u003c==\u003e ChatGPT\r\n\u003e - hutia \u003c==\u003e NeevaAI\r\n\u003e - Your own bot\r\n\r\n\r\n### SendMessage\r\n```ts\r\n/**\r\n  * send message to bot\r\n  * @param text user input\r\n  * @param botNickName bot nick name, like capybara(Sage) / a2(Claude-instant) / a2_2(Claude+) etc.\r\n  * @param withChatBreak Add a chat break or not. (Empty context)\r\n  * @param callback When ws on message, will invoke this callback function.\r\n */\r\nawait client.sendMessage(text, botNickName, withChatBreak, (result: string) =\u003e {console.log(`${result}`)})\r\n```\r\n\u003e text: string\r\n\u003e \r\n\u003e botNickName: string\r\n\u003e \r\n\u003e withChatBreak: boolean\r\n\u003e \r\n\u003e callback: (result: string) =\u003e void\r\n\r\n\u003e **Warning**: Too many requests within one minute will result in (free)account being blocked !!!!!\r\n\u003e \r\n\u003e I had sent about 20 messages in one minute, and now it's blocked. Login failed with error message: `Something went wrong. Please wait a moment and try again.`\r\n\u003e \r\n\u003e So make sure you know what you're doing~\r\n\r\n### AddChatBreak\r\n```ts\r\nconst res = await client.addChatBreak(botNickName);\r\n```\r\n- botNickName: string\r\n\r\n### DeleteMessage\r\n```ts\r\nconst res = await client.deleteMessage(messageIds);\r\n```\r\n- messageIds: number[], messageIds to delete\r\n\r\n\r\n### PurgeAllMessage\r\n```ts\r\nconst res = await client.purgeAllMessage();\r\n```\r\n\u003e Delete all bot messages, equals to click poe.com \u003e Settings \u003e Delete all messages\r\n\r\n### GetHistory\r\n```ts\r\nconst history = await client.getHistory(botNickName, count);\r\n```\r\n- botNickName: string\r\n- count?: number,  Messages's count to get. (default: 25)\r\n\r\n### GetBotInfo\r\n```ts\r\nconst history = await client.getBotByNickName(botNickName, retryCount, retryIntervalMs);\r\n```\r\n- botNickName: string\r\n- retryCount?: number, If fetch bot info failed, will retry.\r\n- retryIntervalMs?: number, ms time to wait before next fetch. (default: 2000)\r\n\r\n### GetNextData\r\n```ts\r\nconst history = await client.getNextData();\r\n```\r\n\u003e Can get `poe-formkey` / `buildId` / `latest messages`(like latest 5 messages) and `startCursor`(use startCursor to fetch history messages) / `availableBots` / `x-forwarded-for` / ......\r\n\r\n### UpdateAllBotInfo\r\n```ts\r\nawait client.updateAllBotInfo()\r\n```\r\n\u003e This function will fetch poe-formkey, buildId, latest messages, startCursor and all bots info(chatId / id, this two params will be used to ). \r\n\u003e \r\n\u003e This function will set `poe-formkey` / `cookie` / `buildId` / `${botDisplayName}_chatId` and `${botDisplayName}_id` to **.env** file(These parameters are the same as cookies and do not need to be requested every time). \r\n\u003e \r\n\u003e Next time you send a msg to any bot, will not need to fetch bot info again, client will get needed params like `buildId` from local .env file.\r\n\r\n## Example\r\n### SendMessage\r\n[example - sendMessage.ts](example/sendMsg.ts)\r\n\r\n### Multi-account support\r\n[example - sendMessage.ts](example/sendMsg.ts)\r\n\r\n### SetProxy\r\n[example - proxy.ts](example/proxy.ts)\r\n\r\n### History\r\n[example - history.ts](example/history.ts)\r\n\r\n### FetchAllNeededInfo\r\n[example - fetchAllNeededInfo.ts](example/fetchAllNeededInfo.ts)\r\n\r\n\r\n## TODO\r\n- [ ] Add type definition to bots/viewer/nextData\r\n- [ ] Use free SMS/email services to log in?\r\n\r\n## Notes\r\n- I'm working on one of my project which can integrate any bot like chatgpt by plugin. But I can't find any poe node api, so I try to write this client. Huge thanks to [poe-api](https://github.com/ading2210/poe-api)(ISC License) and [poe](https://github.com/muharamdani/poe)(MIT License).\r\n- .graphql files is merge from two repos above and find a new graphql to purge all message.\r\n- If you meet any problems, please create an issue.\r\n- I'm not familiar with ts, feel free give suggestions | create pull request.\r\n\r\n## Thanks\r\n- [poe-api](https://github.com/ading2210/poe-api)\r\n- [poe](https://github.com/muharamdani/poe)\r\n- [chatgpt-api](https://github.com/transitive-bullshit/chatgpt-api)\r\n\r\n## License\r\nMIT\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAHGGG%2Fpoe-node-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAHGGG%2Fpoe-node-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAHGGG%2Fpoe-node-api/lists"}