Using the Solscan API to Retrieve Pump.fun Swap Activity
Overview
Pump.fun is a meme‑coin launch platform that supports decentralized trading of new tokens on Solana. It uses two programs: one implementing an automated market maker (AMM) for swaps and another implementing the bonding‑curve that sets prices.
To monitor swap activity for a specific user, Solscan provides a v2.0/account/defi/activities
API. This endpoint returns detailed DeFi activities such as token swaps, liquidity events, staking, etc. The documentation shows that it accepts parameters such as the wallet address, the program ID to filter by, a page number and page size for pagination and sort order pro-api.solscan.io.
This article explains how to use this API to pull Pump.fun swap transactions, filter them by USD value and export them into a CSV file.
Understanding the API
Endpoint and Parameters
Solscan’s Account DeFi Activities endpoint (GET /v2.0/account/defi/activities
) returns DeFi activities for a wallet. Key parameters include pro-api.solscan.io:
Parameter | Description |
---|---|
address | Required. The wallet address on Solana whose activities are queried. |
activity_type | Array of activity types to include. For swaps use ACTIVITY_TOKEN_SWAP . |
platform | Array of platform program IDs to filter by. Up to 5 IDs. |
source | Array of source program IDs to filter by. Up to 3 IDs (use Pump.fun program here). |
page | Page number for pagination (integer). |
page_size | Number of items per page (allowed values: 10, 20, 30, 40, 60, 100). |
sort_by | Field used for sorting; block_time is the default. |
sort_order | asc or desc for ascending or descending order. |
The API response contains a data
array. Each element includes fields such as:
block_id
,block_time
andtrans_id
to identify the block and transaction.activity_type
,from_address
andto_address
.token1
,token1_decimals
,amount1
andtoken2
,token2_decimals
,amount2
specifying the swap tokens and their amounts.price1
,price2
andusd_value
giving the USD value of each side if available.
Authentication
Solscan’s Pro API requires an API key. According to the Pro API documentation, you must supply the key in a custom HTTP header named token
docs.solscan.io. When using curl
or any HTTP client, set -H 'token: <YOUR_API_KEY>'
.
🚨 Warning: Never share your API key publicly.
Determining Pump.fun Program IDs
Pump.fun uses two Solana programs:
- Swap program (AMM):
pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA
- Bonding‑curve program:
6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P
To monitor swap activity you only need the AMM program. Pass it in the source
parameter when calling the API.
Solutions for Pulling Swap Activity
Solution 1 – Use curl
/Python to call the API directly
You can build a script to call the API, paginate through results and export them to CSV. The steps are:
- Prepare query parameters: set
address
to the wallet you want (e.g.GFF...T7y
),source
to the swap program ID,activity_type
toACTIVITY_TOKEN_SWAP
,page_size
to100
andsort_order
todesc
. - Paginate: loop
page=1,2,…
until you retrieve the desired number of records (e.g. 1000 swaps = 10 pages × 100 records). Stop when the returneddata
array is empty. - Filter by USD value: Each record includes
amount1
,token1
,amount2
,token2
and, if available,price1
andprice2
. If price fields are missing you can call Solscan’s Token Price endpoint (/v2.0/market/token/price
) to fetch historical USD pricespro-api.solscan.io. Multiply amount by price to compute the USD value and discard records below $1. - Write CSV: Save records with fields like date/time (
block_time
converted to ISO date), transaction ID, token symbols, amounts and USD values.
Example in Python:
python
CopyEdit
import csv, requests, time
API_KEY = "<your_api_key>"
BASE_URL = "https://pro-api.solscan.io/v2.0/account/defi/activities"
ADDRESS = "GFF4...YT7y"
SOURCE = "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"
headers = {"token": API_KEY}
page = 1
page_size = 100
results = []
while len(results) < 1000:
params = {
"address": ADDRESS,
"activity_type": "ACTIVITY_TOKEN_SWAP",
"source": SOURCE,
"page": page,
"page_size": page_size,
"sort_by": "block_time",
"sort_order": "desc",
}
resp = requests.get(BASE_URL, headers=headers, params=params)
resp.raise_for_status()
data = resp.json().get("data", [])
if not data:
break # no more records
results.extend(data)
page += 1
time.sleep(0.1) # avoid rate‑limits
# optionally truncate to 1000 records
data1000 = results[:1000]
# filter by USD value > $1 – compute if price fields available
filtered = []
for row in data1000:
usd = row.get("usd_value") # if Solscan already provides USD value
if usd is None:
usd = 0 # compute using token price endpoint if necessary
if usd > 1:
filtered.append(row)
# write to CSV
with open("/home/oai/share/pump.fun_swap.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["block_time","trans_id","token1","amount1","token2","amount2","usd_value"])
for row in filtered:
writer.writerow([
row["block_time"], row["trans_id"],
row.get("token1"), row.get("amount1"),
row.get("token2"), row.get("amount2"),
row.get("usd_value"),
])
print("Export completed!")
Pros:
- Completely automated; you can fetch 1000+ records and filter them programmatically.
- Scripts allow further analytics (e.g. time‑series analysis, distribution of swap sizes).
Cons:
- You must handle API rate‑limits by adding delays between requests.
Solution 2 – Use Solscan’s interactive API docs (manual)
The Pro API docs include a “Try It!” button that sends requests with your API key automatically. You can supply the address, activity type and program ID in the form and view the JSON response. This is helpful for testing parameters and inspecting a few records. However, it only returns one page at a time and does not support exporting to CSV. You would need to copy results manually and combine them yourself.

Pros:
- Convenient for exploring the API without writing code.
- Good for verifying query parameters and previewing response structure.
Cons:
- Manual; cannot fetch large datasets efficiently.
- Your API key appears in the request snippet, so be careful not to expose it when sharing screenshots.
Conclusion and Recommendation
Solscan’s Pro API offers a rich endpoint (/account/defi/activities
) for retrieving on‑chain swap data. By filtering on the Pump.fun AMM program ID and the ACTIVITY_TOKEN_SWAP
activity type, you can obtain detailed swap activity for any wallet. The key steps are:
- Supply your API key via the
token
header. - Paginate through results (page 1 through page n) because the API caps
page_size
at 100. - Compute USD values using the
value
fields or the token price endpoint and filter transactions above your threshold (e.g. > $1). - Export the filtered data to a CSV file for analysis.