cookin-fun
v0.1.0
Published
Node.js SDK for the Cookin API — Pump.fun and Solana memecoin data (REST + WebSocket).
Downloads
127
Maintainers
Readme
cookin-fun
Node.js SDK for the Cookin API — real-time Pump.fun and Solana memecoin data. REST + WebSocket over the same pipeline that powers the cookin.fun UI. Quality scores, bundle detection, trader behavioral stats, live trade frames.
- Free during beta. No credit card.
- Docs: https://cookin.fun/api
- Discord: https://cookin.fun/discord
Install
npm install cookin-funOn Node 22+ this is the only dependency you need. On Node 18-21, also install ws:
npm install cookin-fun wsQuickstart
Mint an API key at cookin.fun/account/api-keys and set it as COOKIN_API_KEY.
import { Cookin } from 'cookin-fun';
const cookin = new Cookin({ apiKey: process.env.COOKIN_API_KEY! });
// Full snapshot for one token
const { data } = await cookin.tokens.get('BgNrWZKAaZAa...');
console.log(data.score?.value, data.holders?.count);That's it. Every endpoint returns a typed Envelope<T> with the same shape as the wire format: { data, meta }.
REST
Every REST method returns Promise<Envelope<T>>.
// Token feeds. All four return TokenCard[].
await cookin.tokens.new(); // recently deployed
await cookin.tokens.pumps(); // currently pumping
await cookin.tokens.graduated(); // recently on Raydium / PumpSwap
await cookin.tokens.survivors(); // 3-24h post deploy, still alive
// One token, one call. Filter to the field groups you actually need.
await cookin.tokens.get(mint, { fields: ['meta', 'market', 'score'] });
// Most recent trades for a token, enriched with per-trade trader context.
await cookin.tokens.trades(mint);
// Full behavioral profile for a wallet.
await cookin.traders.get(walletAddress);WebSocket
Two channels, both multiplexed on one socket connection. Subscribe with .onTokens / .onFrames.
const socket = cookin.connect();
// Token lifecycle events: created, graduated, DEX-paid, metadata,
// duplication flags flipped.
socket.onTokens((event) => {
if (event.type === 'token_created') {
console.log('new token:', event.data.symbol, event.data.score);
}
});
// Every enriched trade, ~1s off Solana block time. One message per
// {signature, mint} unit, so multi-hop swaps arrive grouped.
socket.onFrames((frame) => {
for (const trade of frame.trades) {
console.log(trade.signature, trade.user_address, trade.sol_amount);
}
});
// When you're done
socket.close();The SDK handles the Phoenix Channels v2 wire protocol (join, heartbeat, event dispatch) internally. Reconnect and back-pressure are left to callers on purpose so the SDK stays predictable. Wrap .connect() in your own reconnect loop when running long-lived processes.
Examples
Two runnable scripts in examples/:
lifecycle_events.ts— subscribes totokens:liveand prints one line per event type (token_created,token_metadata_retrieved,token_graduated,token_dex_paid,token_duplication_status_updated).wallet_watcher.ts— streamsframes:livefiltered to a list of wallets.
COOKIN_API_KEY=sk_live_... npx tsx examples/lifecycle_events.tsErrors
Non-2xx responses throw a typed CookinError:
import { CookinError } from 'cookin-fun';
try {
await cookin.tokens.get(mint);
} catch (err) {
if (err instanceof CookinError) {
console.error(err.status, err.code, err.requestId);
}
}Every response carries a request_id in meta (and on errors, on the CookinError). Quote it when reporting issues.
Rate limits
60 requests per minute per key. X-RateLimit-* headers on every response. See Rate limits for details.
Full reference
Every endpoint, every field, every WebSocket event: cookin.fun/api.
Contributing
Bug reports and feature requests: Discord.
License
MIT
