Unofficial Node.js library for JanitorAI
^ 24hr cooldown i will publish it soon😭
This is an unofficial library and is not affiliated with or endorsed by JanitorAI. Use at your own risk. This library is for educational and personal use only.
npm install janitorai.jsRequires Node.js 18+
- Open janitorai.com in your browser
- Open DevTools → Network tab → Filter by Fetch/XHR
- Click any character or do any action
- Find any
/hampter/request → Headers tab → copy theAuthorization: Bearer xxxxxvalue (without "Bearer ")
⚠️ alert: Tokens expire every ~30 minutes. You'll need to refresh it periodically.
const { JanitorClient } = require('janitorai.js');
const client = new JanitorClient({ token: 'YOUR_BEARER_TOKEN' });
async function main() {
// initialize (launches a stealth browser to bypass Cloudflare)
await client.login();
// browse trending characters
const trending = await client.getTrending({ mode: 'weekly' });
console.log(trending[0].name); // "Some Character"
// start a chat
const chat = await client.createChat(trending[0].id);
// set your profile (required for generating replies)
chat.setProfile({
id: 'YOUR_USER_ID',
name: 'YOUR_NAME',
user_name: 'YOUR_USERNAME'
});
// wait for the bot's greeting
const greeting = await chat.waitForGreeting();
console.log('Bot:', greeting);
// send a message and get a reply
const reply = await chat.sendMessage('Hello!');
console.log('Bot:', reply);
await client.destroy();
}
main();| Option | Type | Required | Description |
|---|---|---|---|
token |
string |
yes | Your JanitorAI Bearer token |
Initializes the stealth browser. Must be called before anything else.
Closes the browser. Call when done.
Returns an array of Character objects.
| Option | Type | Default | Description |
|---|---|---|---|
page |
number |
1 |
Page number |
mode |
string |
'weekly' |
'weekly' or '24hr' |
Returns a single Character object by ID.
Search for characters by name.
Creates a new chat session. Returns a Chat object.
| Property | Type | Description |
|---|---|---|
id |
string |
Character UUID |
name |
string |
Character name |
description |
string |
Character description |
tags |
string[] |
Character tags |
Set your user profile for generating replies. Required before sendMessage().
chat.setProfile({
id: 'your-user-id',
name: 'Your Name',
user_name: 'your_username'
});Optionally set your persona.
Send a message and returns the bot's reply as a string.
Waits for the bot's opening message after chat creation. Returns the greeting string.
| Option | Type | Default | Description |
|---|---|---|---|
timeout |
number |
15000 |
Max wait time in ms |
Returns all messages in the chat as an array.
See examples/discord-bot.js for a full Discord bot implementation.
const { JanitorClient } = require('janitorai.js');
const readline = require('readline');
const client = new JanitorClient({ token: 'YOUR_TOKEN' });
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
async function main() {
await client.login();
const trending = await client.getTrending();
const char = trending[0];
console.log(`Starting chat with: ${char.name}`);
const chat = await client.createChat(char.id);
chat.setProfile({ id: 'user-id', name: 'User', user_name: 'user' });
const greeting = await chat.waitForGreeting();
console.log(`\n${char.name}: ${greeting}\n`);
const ask = () => {
rl.question('You: ', async (input) => {
const reply = await chat.sendMessage(input);
console.log(`\n${char.name}: ${reply}\n`);
ask();
});
};
ask();
}
main();- Bearer tokens expire every 30 minutes
- You need to manually grab a fresh one from devtools each time
- Auto-refresh is on the roadmap
JanitorAI uses Supabase for auth. Some technical details for contributors:
- Project URL:
https://mcmzxtzommpnxkynddbo.supabase.co - Refresh token flow: POST to
/auth/v1/token?grant_type=refresh_token - Tokens expire at: roughly August 2026 based on the JWT
expfield
Discord: sidecharactered feel free to DM for questions or contributions or custom orders.
MIT