SDKs & client libraries
Official Node.js and Python SDKs are on npm and PyPI. Both wrap the REST endpoints and both WebSocket channels behind the same shape. MIT licensed, source on GitHub. If you'd rather roll your own, the raw-HTTP snippets further down show what a working wrapper looks like in about 50 lines.
Node.js
cookin-fun on
npm
· source on
GitHub.
npm install cookin-fun
import { Cookin } from 'cookin-fun';
const cookin = new Cookin({ apiKey: process.env.COOKIN_API_KEY! });
// REST
const { data } = await cookin.tokens.get(mint);
console.log(data.score?.value, data.holders?.count);
// WebSocket
const socket = cookin.connect();
socket.onFrames((frame) => {
for (const trade of frame.trades) {
console.log(trade.signature, trade.sol_amount);
}
});
Python
cookin-fun on
PyPI
· source on
GitHub.
pip install cookin-fun
import os
from cookin_fun import Cookin
cookin = Cookin(api_key=os.environ["COOKIN_API_KEY"])
# REST
snap = cookin.tokens.get(mint)
print(snap["data"]["score"]["value"], snap["data"]["holders"]["count"])
# WebSocket
def on_frame(frame):
for trade in frame["trades"]:
print(trade["signature"], trade["sol_amount"])
with cookin.connect() as socket:
socket.on_frames(on_frame)
socket.run_forever()
curl
{"# Every REST call\ncurl -sS -H \"Authorization: Bearer $API_KEY\" \\\n https://api.cookin.fun/v1/tokens/new"}
Raw HTTP
If you don't want the SDK, both languages can drive the API in about 30 lines with only the standard library.
Node.js (fetch)
{"const API_KEY = process.env.API_KEY;\n\nasync function fetchApi(path) {\n const res = await fetch(`https://api.cookin.fun${path}`, {\n headers: { \"Authorization\": `Bearer ${API_KEY}` },\n });\n if (!res.ok) throw new Error(`API ${res.status}: ${await res.text()}`);\n return res.json();\n}\n\nconst { data } = await fetchApi(\"/v1/tokens/new\");\nconsole.log(data);"}
Python (requests)
{"import os, requests\n\nAPI_KEY = os.environ[\"API_KEY\"]\nSESSION = requests.Session()\nSESSION.headers.update({\"Authorization\": f\"Bearer {API_KEY}\"})\n\ndef fetch_api(path):\n r = SESSION.get(f\"https://api.cookin.fun{path}\")\n r.raise_for_status()\n return r.json()\n\nresponse = fetch_api(\"/v1/tokens/new\")\nprint(response[\"data\"])"}
WebSocket without the SDK
Terminal, Node.js, and Python examples that drive the Phoenix Channels v2 wire protocol directly live on the tokens:live and frames:live pages.
Community wrappers
Building a wrapper for Go, Rust, or something we're missing? Come tell us in Discord and we'll link it here.