Fomo API gives developers one REST interface for Fomo Family trader profiles, verified wallet mappings, balances, swaps, holdings, PnL and leaderboards. This tutorial takes you from an empty folder to a working request.
What you need
| Requirement | Purpose |
|---|---|
| Fomo API Pro key | Authenticates protected requests |
| Node.js 20+ or Python 3.10+ | Runs the examples |
| A terminal | Installs packages and starts scripts |
| Git | Optional, but recommended for source control |
You do not need a wallet or private key to read data. Fomo API does not execute trades.
Create the project
For Node.js:
mkdir fomo-api-starter
cd fomo-api-starter
npm init -y
npm install dotenv
For Python:
mkdir fomo-api-starter
cd fomo-api-starter
python -m venv .venv
Activate the virtual environment, then install:
pip install requests python-dotenv
Configure the API key
Create .env in the project root:
FOMO_API_KEY=fomo_live_YOUR_API_KEY
Add it to .gitignore before your first commit:
.env
.venv/
node_modules/
Warning: A key in a
NEXT_PUBLIC_,VITE_or similar browser-exposed variable is public. Call Fomo API from server code only.
Make a request with JavaScript
Create index.mjs:
import "dotenv/config"
const apiKey = process.env.FOMO_API_KEY
if (!apiKey) throw new Error("FOMO_API_KEY is missing")
const response = await fetch(
"https://getfomoapi.fun/api/leaderboard/24h?limit=5",
{
headers: {
Accept: "application/json",
"X-API-Key": apiKey,
},
}
)
if (!response.ok) {
throw new Error(
`Fomo API returned ${response.status}: ${await response.text()}`
)
}
const payload = await response.json()
const traders = payload.responseObject?.leaderboard ?? []
for (const trader of traders) {
console.log(trader.userHandle, trader.pnl24h, trader.solana)
}
Run it with node index.mjs.
Make a request with Python
Create main.py:
import os
import requests
from dotenv import load_dotenv
load_dotenv()
api_key = os.environ["FOMO_API_KEY"]
response = requests.get(
"https://getfomoapi.fun/api/leaderboard/24h",
params={"limit": 5},
headers={"Accept": "application/json", "X-API-Key": api_key},
timeout=30,
)
response.raise_for_status()
for trader in response.json()["responseObject"]["leaderboard"]:
print(trader["userHandle"], trader.get("pnl24h"))
Run it with python main.py.
Understand the response
A successful endpoint generally returns success, message, responseObject and statusCode. Endpoint data is inside responseObject; do not assume it exists on failures.
Use optional access in JavaScript or .get() in Python for fields that may be absent. Wallets and social profile fields can legitimately be null.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
401 | Missing or invalid key | Check the header and key prefix. |
403 | Inactive Pro plan | Verify account status. |
422 | Invalid window or limit | Use documented values and ranges. |
429 | Too many requests | Respect Retry-After. |
| Timeout | Temporary network issue | Retry with bounded backoff. |
Next steps
Resolve a selected handle through /api/users/{handle}, store its returned user ID, then request balances and swaps. Keep your first integration read-only until logging, retry handling and data validation are working correctly.