Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/pumpfun_cli/protocol/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
from solders.pubkey import Pubkey

# pump.fun's HTTP endpoints sit behind Cloudflare, which rejects the default
# python-httpx User-Agent; an identifying one is accepted.
HTTP_HEADERS = {"User-Agent": "pumpfun-cli (+https://github.com/chainstacklabs/pumpfun-cli)"}
# python-httpx User-Agent and any request without an Origin and Accept-Language.
HTTP_HEADERS = {
"User-Agent": "pumpfun-cli (+https://github.com/chainstacklabs/pumpfun-cli)",
"Origin": "https://pump.fun",
"Accept-Language": "en-US,en;q=0.9",
}

# Solana constants
LAMPORTS_PER_SOL = 1_000_000_000
Expand Down
6 changes: 5 additions & 1 deletion tests/test_core/test_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ async def test_boards_keep_only_pump_coins(respx_mock, fn, board):
tokens = await fn(limit=5)
assert [t["symbol"] for t in tokens] == ["ONE", "TWO"]
assert route.call_count == 1 # a short page is the end of the board
assert route.calls.last.request.headers["user-agent"].startswith("pumpfun-cli")
headers = route.calls.last.request.headers
assert headers["user-agent"].startswith("pumpfun-cli")
# pump.fun answers 403 without these two.
assert headers["origin"] == "https://pump.fun"
assert headers["accept-language"]


async def test_board_pages_until_the_limit(respx_mock):
Expand Down
Loading