This repo shows how to quickly connect to the Pumpfun & Pumpswap on-chain Solana data streams that are delivered over NATS.
.
βββ main.py # Minimal async consumer / JetStream durable example
βββ requirements.txt # Python packages pinned to known-good versions
βββ .env.example # Optional env vars so you donβt put secrets in git
-
Clone / copy the template:
git clone https://github.com/your-org/nats-python-starter.git cd nats-python-starter -
Create a virtual env & install dependencies:
python -m venv .venv source .venv/bin/activate pip install -r requirements.txt -
Copy
.env.exampleβ.envand fill in eitherNATS_CREDSor theNATS_JWT+NATS_NKEYpair plus your stream subject:NATS_SERVER=nats://edge.pump.fun:4223 NATS_CREDS=/absolute/path/to/user.creds # NATS_JWT=/path/user.jwt # NATS_NKEY=/path/user.nk NATS_SUBJECT=basic.>
- Credentials are issued by the Pumpfun User Management API (
/api/users). - Never commit creds / seeds to git!
- Credentials are issued by the Pumpfun User Management API (
-
Run the consumer (no CLI flags needed β everything is read from
.env/ env vars):python main.py
Messages will stream in real-time and be printed to stdout. Press Ctrl-C to disconnect cleanly.
| Variable | Purpose | Example |
|---|---|---|
NATS_SERVER |
NATS server URL | nats://edge.pump.fun:4223 |
NATS_CREDS |
Path to creds file (preferred auth) | /home/user/basic.creds |
NATS_JWT / NATS_NKEY |
Paths to JWT + NKey seed (advanced auth) | /jwt/u.jwt, /jwt/u.nk |
NATS_SUBJECT |
Subject or wildcard to stream | basic.> |
- The credential file bundles the user JWT and the NKey seed. Itβs the easiest way to authenticate.
- If you prefer to keep secrets split, pass
--jwtand--nkeyinstead of--creds. - All examples use the official
nats-pyclient. - This template always uses JetStream with an ephemeral push consumer β no cleanup required.
- If you wish to replay historical data you can add a durable consumer in your own code, but for live pricing a push consumer is the lightest weight option.
- Remember: Basic tier can only read
basic.*subjects, Plus/Pro can read bothbasic.*andpremium.*.
- Official client docs: https://pynats.docs.io / https://github.com/nats-io/nats.py
- Pumpfun API docs: (internal) https://pump.fun/docs
- NATS by Example: https://natsbyexample.com/
MIT Β© 2025 Pumpfun