xcaDocs
Guides

Export smart money

Page through the smart-money holders of a token and save them to CSV.

Smart money are wallets with a profitable 30-day track record. Filter holders by class SMART_MONEY, follow the pages and write the rows to a file.

  • total counts only the holders your plan can see.
  • pageSize 100 means fewer requests.
  • Import the CSV into a copy-trading bot or a spreadsheet.

Code#

import csv
import os
import requests

BASE = "https://app.xca.fun/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['XCA_API_KEY']}"}
MINT = "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"

rows, page = [], 1
while True:
    res = requests.get(
        f"{BASE}/tokens/solana/{MINT}/holders",
        params={"class": "SMART_MONEY", "page": page, "pageSize": 100},
        headers=HEADERS,
        timeout=30,
    )
    res.raise_for_status()
    data = res.json()
    rows += data["rows"]
    if page * data["pageSize"] >= data["total"]:
        break
    page += 1

with open("smart-money.csv", "w", newline="") as fh:
    writer = csv.writer(fh)
    writer.writerow(["rank", "address", "sharePct", "pnl30dUsd", "winRate"])
    for r in rows:
        writer.writerow([r["rank"], r["address"], r["sharePct"], r["pnl30dUsd"], r["winRate"]])

print(f"saved {len(rows)} wallets")