From e332b75cde6cd0ff1067d6f0275b9a0a69791744 Mon Sep 17 00:00:00 2001 From: Anton Sauchyk Date: Tue, 17 Nov 2026 15:15:13 +0100 Subject: [PATCH] fix(tokens): send Origin and Accept-Language to pump.fun's API pump.fun's API now answers 403 to requests without them, which broke every tokens command. --- src/pumpfun_cli/protocol/contracts.py | 8 ++++++-- tests/test_core/test_tokens.py | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pumpfun_cli/protocol/contracts.py b/src/pumpfun_cli/protocol/contracts.py index 22e18cd..4b8afa3 100644 --- a/src/pumpfun_cli/protocol/contracts.py +++ b/src/pumpfun_cli/protocol/contracts.py @@ -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 diff --git a/tests/test_core/test_tokens.py b/tests/test_core/test_tokens.py index cd048c9..7a1cbfe 100644 --- a/tests/test_core/test_tokens.py +++ b/tests/test_core/test_tokens.py @@ -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):