Skip to main content

Python SDK for the Cookin API — Pump.fun and Solana memecoin data (REST + WebSocket).

Project description

cookin-fun

Python 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.

Install

pip install cookin-fun

Python 3.9+.

Quickstart

Mint an API key at cookin.fun/account/api-keys and set it as COOKIN_API_KEY.

from cookin_fun import Cookin
import os

cookin = Cookin(api_key=os.environ["COOKIN_API_KEY"])

# Full snapshot for one token
snap = cookin.tokens.get("BgNrWZKAaZAa...")
print(snap["data"]["score"]["value"], snap["data"]["holders"]["count"])

That's it. Every REST method returns the raw envelope dict {"data": ..., "meta": ...}. TypedDict definitions ship with the package so IDEs get autocomplete for every field.

REST

Every REST method returns the envelope as a plain dict. Field types are documented via TypedDicts in cookin_fun.types.

# Token feeds. All four return a list of token cards.
cookin.tokens.new()          # recently deployed
cookin.tokens.pumps()        # currently pumping
cookin.tokens.graduated()    # recently on Raydium / PumpSwap
cookin.tokens.survivors()    # 3-24h post deploy, still alive

# One token, one call. Filter to the field groups you actually need.
cookin.tokens.get(mint, fields=["meta", "market", "score"])

# Most recent trades for a token, enriched with per-trade trader context.
cookin.tokens.trades(mint)

# Full behavioral profile for a wallet.
cookin.traders.get(wallet_address)

WebSocket

Two channels, both multiplexed on one socket connection. Use .on_tokens / .on_frames to register handlers, then .run_forever() to pump events.

socket = cookin.connect()

# Token lifecycle events: created, graduated, DEX-paid, metadata,
# duplication flags flipped.
def on_token_event(event):
    if event["type"] == "token_created":
        card = event["data"]
        print("new token:", card["symbol"], card["score"])

# Every enriched trade, ~1s off Solana block time. One message per
# {signature, mint} unit, so multi-hop swaps arrive grouped.
def on_frame(frame):
    for trade in frame["trades"]:
        print(trade["signature"], trade["user_address"], trade["sol_amount"])

with socket:
    socket.on_tokens(on_token_event)
    socket.on_frames(on_frame)
    socket.run_forever()

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 for long-lived processes.

Examples

Two runnable scripts in examples/:

  • lifecycle_events.py — subscribes to tokens:live and prints one line per event type (token_created, token_metadata_retrieved, token_graduated, token_dex_paid, token_duplication_status_updated).
  • wallet_watcher.py — streams frames:live filtered to a list of wallets.
COOKIN_API_KEY=sk_live_... python examples/lifecycle_events.py

Errors

Non-2xx responses raise a typed CookinError:

from cookin_fun import CookinError

try:
    cookin.tokens.get(mint)
except CookinError as exc:
    print(exc.status, exc.code, exc.request_id)

Every response carries a request_id in meta (and on errors, on the exception). 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cookin_fun-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cookin_fun-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file cookin_fun-0.1.0.tar.gz.

File metadata

  • Download URL: cookin_fun-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for cookin_fun-0.1.0.tar.gz
Algorithm Hash digest
SHA256 96c63681a68d8ddc0a0a05eefe46de4b69f89e8b6601b99d425c840bb5bb9521
MD5 93e0413af1ed2e646a07e4b7fce0c645
BLAKE2b-256 fc306fab6d00342204942050ba33505d41c75b8bd7c3994a62bfc2187f4b16f6

See more details on using hashes here.

File details

Details for the file cookin_fun-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cookin_fun-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for cookin_fun-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ae1bfa2c19a9d1021a00f49b7d485f0dbd07bf423b970d84c9b3a17eb66f00a
MD5 3dd55ab5401e7700e1d01a3d8edc5bde
BLAKE2b-256 7d500f162195f0b7b210ac81851340efb64ab2ff90dcb9bacf56f789117d659c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page