All guides

Getting Started

Getting Started with Fomo API: Installation and First Request

A beginner-friendly setup guide for creating a Fomo API key, configuring environment variables and making your first leaderboard request in JavaScript and Python.

By Fomo API 3 min read

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

RequirementPurpose
Fomo API Pro keyAuthenticates protected requests
Node.js 20+ or Python 3.10+Runs the examples
A terminalInstalls packages and starts scripts
GitOptional, 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

SymptomLikely causeFix
401Missing or invalid keyCheck the header and key prefix.
403Inactive Pro planVerify account status.
422Invalid window or limitUse documented values and ranges.
429Too many requestsRespect Retry-After.
TimeoutTemporary network issueRetry 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.