A reverse engineered Node.js client for Quora's Poe.
Support: 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
I'm still working on this, so it's might not stable. If your meet any problems, please create an issue.
npm install poe-node-apirequirement:
- node >= 18
- .env: To store needed params like
poe-formkey/cookie/buildId/ botId.....
Get cookie from poe.com: F12 / inspect, Application > Cookies > https://poe.com > p-b
Create .env file in your project root path, and add cookie to .env file
cookie=p-b=xxxxxxxxxxxxxxxxxxxxxxxxxxxconst client = new PoeClient({logLevel: 'debug'});
await client.init()
// 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).How to create a client:
import {PoeClient} from "poe-node-api";
const client = new PoeClient({logLevel: 'debug'});How to init client
await client.init()buildId / poe-formkey and overwrite them in the local '.env' file.To prevent conflicts, when using multi-account, you should set
rewriteToLocalEnvFileto false
Bot nicknames
botNickName <==> botDisplayName
- a2 <==> Claude-instant
- a2_2 <==> Claude+
- beaver <==> GPT-4
- capybara <==> Sage
- nutria <==> Dragonfly
- chinchilla <==> ChatGPT
- hutia <==> NeevaAI
- Your own bot
/**
* send message to bot
* @param text user input
* @param botNickName bot nick name, like capybara(Sage) / a2(Claude-instant) / a2_2(Claude+) etc.
* @param withChatBreak Add a chat break or not. (Empty context)
* @param callback When ws on message, will invoke this callback function.
*/
await client.sendMessage(text, botNickName, withChatBreak, (result: string) => {console.log(`${result}`)})text: string
botNickName: string
withChatBreak: boolean
callback: (result: string) => void
Warning: Too many requests within one minute will result in (free)account being blocked !!!!!
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.So make sure you know what you're doing~
const res = await client.addChatBreak(botNickName);const res = await client.deleteMessage(messageIds);const res = await client.purgeAllMessage();Delete all bot messages, equals to click poe.com > Settings > Delete all messages
const history = await client.getHistory(botNickName, count);const history = await client.getBotByNickName(botNickName, retryCount, retryIntervalMs);const history = await client.getNextData();Can get
poe-formkey/buildId/latest messages(like latest 5 messages) andstartCursor(use startCursor to fetch history messages) /availableBots/x-forwarded-for/ ......
await client.updateAllBotInfo()This function will fetch poe-formkey, buildId, latest messages, startCursor and all bots info(chatId / id, this two params will be used to ).
This function will set
poe-formkey/cookie/buildId/${botDisplayName}_chatIdand${botDisplayName}_idto .env file(These parameters are the same as cookies and do not need to be requested every time).Next time you send a msg to any bot, will not need to fetch bot info again, client will get needed params like
buildIdfrom local .env file.
example - sendMessage.ts
example - sendMessage.ts
example - proxy.ts
example - history.ts
example - fetchAllNeededInfo.ts
MIT