
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
TypeScript library to interact with the Chaturbate Affiliate API.
Provides a secure and typed way to query clicks, signups, earnings, and tokens.
npm install chaturbapi
# or
yarn add chaturbapi
Requires Node.js ≥ 18.17.
import { ChaturbAPI } from "chaturbapi";
const api = new ChaturbAPI("your_username", "your_token", {
timeoutMs: 10_000,
retries: 2,
});
const stats = await api.getStats({
range: "last_7_days",
breakdown: "day",
});
console.log(stats.rows);
AffiliateStatsResponse){
"range": "last_7_days",
"breakdown": "day",
"program": "affiliate",
"columns": ["date", "clicks", "signups", "revenue"],
"rows": [
{ "date": "2025-10-01", "clicks": 123, "signups": 12, "revenue": 45.5 },
{ "date": "2025-10-02", "clicks": 110, "signups": 9, "revenue": 33.7 }
],
"totals": { "clicks": 233, "signups": 21, "revenue": 79.2 }
}
new ChaturbAPI(username, token, {
baseURL: "https://chaturbate.com", // optional
timeoutMs: 12000, // request timeout
retries: 2, // automatic retries
headers: { "User-Agent": "chaturbapi/1.0" }, // custom headers
beforeRequest: (url) => console.log("➡️", url),
afterResponse: (url, status) => console.log("⬅️", status)
});
getStats(query?: AffiliateStatsQuery)Retrieves affiliate statistics.
| Name | Type | Description |
|---|---|---|
range | "today" | "yesterday" | "last_7_days" | "last_30_days" | "this_month" | "last_month" | "this_year" | Date range. |
breakdown | "none" | "day" | "month" | "program" | Level of breakdown. |
program | "affiliate" | "revshare" | "ppv" | "tokens" | Program type. |
Promise<AffiliateStatsResponse>
The EventsClient class provides a persistent connection to the Chaturbate Events API, allowing you to receive live notifications such as user entries, tips, chat messages, and more.
import { EventsClient } from "chaturbapi";
const events = new EventsClient("your_username", "your_events_token");
// Listen for specific events
events.on("broadcastStart", ({ broadcaster, user }) => {
console.log(`📡 ${broadcaster} started streaming`);
});
events.on("tip", ({ user, tip }) => {
console.log(`💰 ${user.username} sent ${tip.tokens} tokens`);
});
events.on("chatMessage", ({ user, message }) => {
console.log(`💬 ${user.username}: ${message.message}`);
});
// Generic listener
events.on("event", (e) => console.log(`[Raw Event]`, e));
// Handle errors
events.on("error", (err) => console.error("Stream error:", err));
// Start listening
events.start();
| Event | Description | Payload Type |
|---|---|---|
broadcastStart | Broadcaster started streaming | BroadcastEvent |
broadcastStop | Broadcast ended | BroadcastEvent |
userEnter | A user entered the room | BroadcastEvent |
userLeave | A user left the room | BroadcastEvent |
follow | User followed the broadcaster | BroadcastEvent |
unfollow | User unfollowed the broadcaster | BroadcastEvent |
fanclubJoin | User joined the fanclub | BroadcastEvent |
chatMessage | Public chat message | ChatMessageEvent |
privateMessage | Private message | PrivateMessageEvent |
tip | User sent a tip | TipEvent |
roomSubjectChange | Broadcaster updated room subject | RoomSubjectChangeEvent |
mediaPurchase | Media (photo/video) purchased | MediaPurchaseEvent |
Each event type has its own structure. Examples:
events.on("tip", ({ broadcaster, user, tip }) => {
// user.username, tip.tokens, tip.isAnon, tip.message
});
events.on("chatMessage", ({ broadcaster, user, message }) => {
// user.username, message.message, message.color
});
events.on("mediaPurchase", ({ broadcaster, user, media }) => {
// media.name, media.tokens, media.type
});
These types are automatically inferred in TypeScript, so you get full IntelliSense support per event type.
AffiliateStatsResponseinterface AffiliateStatsResponse {
range: string;
breakdown: string;
program?: string;
columns: string[];
rows: Record<string, any>[];
totals?: Record<string, any>;
}
AffiliateStatsQueryinterface AffiliateStatsQuery {
range?: string;
breakdown?: string;
program?: string;
}
ChaturbAPI implements a simple typed EventEmitter.
api.on("statsUpdated", (data) => {
console.log("Updated stats:", data);
});
api.on("error", (err) => {
console.error("API error:", err);
});
| Event | Description |
|---|---|
statsUpdated | Triggered when a successful response is received. |
error | Triggered when a network or HTTP error occurs. |
Network or API errors throw an HTTPError exception:
import { HTTPError } from "chaturbapi";
try {
await api.getStats({ range: "today" });
} catch (err) {
if (err instanceof HTTPError) {
console.error("HTTP failure:", err.status, err.body);
} else {
console.error("Unexpected error:", err);
}
}
const stats = await api.getStats({ range: "last_7_days", breakdown: "day" });
console.table(stats.rows);
api.on("error", (e) => {
// Send to your monitoring system
console.error("[ALERT] Chaturbate API failure:", e);
});
const { totals } = await api.getStats({ range: "this_month" });
console.log("Clicks:", totals?.clicks, "Revenue:", totals?.revenue);
const [today, month] = await Promise.all([
api.getStats({ range: "today" }),
api.getStats({ range: "this_month" }),
]);
| Event | Main Properties | Notes |
|---|---|---|
| broadcastStart | broadcaster, user | Triggered when stream starts |
| broadcastStop | broadcaster, user | Triggered when stream stops |
| userEnter | broadcaster, user | User enters room |
| userLeave | broadcaster, user | User leaves room |
| follow | broadcaster, user | User followed broadcaster |
| unfollow | broadcaster, user | User unfollowed broadcaster |
| fanclubJoin | broadcaster, user | User joined fanclub |
| chatMessage | broadcaster, user, message | Public chat message |
| privateMessage | broadcaster, user, message | Private message (to broadcaster) |
| tip | broadcaster, user, tip | User sent tokens |
| roomSubjectChange | broadcaster, user, subject | Room subject updated |
| mediaPurchase | broadcaster, user, media | Media (photo/video) purchased |
All events contain at least broadcaster and user fields.
import { ChaturbAPI, EventsClient } from "chaturbapi";
const api = new ChaturbAPI("user", "token");
const events = new EventsClient("user", "event_token");
const stats = await api.getStats({ range: "today" });
console.log("Current clicks:", stats.totals?.clicks);
events.on("tip", ({ user, tip }) => {
console.log(`${user.username} tipped ${tip.tokens} tokens`);
});
events.start();
MIT © Nikita Contreras
FAQs
Library to interact with the Chaturbate API's
We found that chaturbapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.