fighterapi
v0.2.0
Published
JavaScript and TypeScript client for the FighterAPI MMA data API: stats, play-by-play, odds and player props. No dependencies.
Maintainers
Readme
fighterapi
UFC and MMA data and odds API. JavaScript and TypeScript client for the FighterAPI MMA data API. No dependencies; Node 18+, Deno, Bun, and edge runtimes with fetch.
First call in plain Python
No package needed: standard library only. Set FIGHTERAPI_API_KEY to your key (free at https://fighterapi.com/signup) and run this. search_fighters costs 1 credit.
import json, os, urllib.request
req = urllib.request.Request(
"https://mcp.fighterapi.com/v1/search_fighters",
data=json.dumps({"query": "topuria"}).encode(),
headers={"x-api-key": os.environ["FIGHTERAPI_API_KEY"], "content-type": "application/json"},
)
with urllib.request.urlopen(req) as resp:
data = json.load(resp)["data"]
print("credits left:", resp.headers["x-credits-remaining"])
rows = next(v for v in data.values() if isinstance(v, list))
for row in rows[:5]:
print(row)Every tool works the same way: POST https://mcp.fighterapi.com/v1/, JSON in, {"data": ...} out, with X-Credits-Used and X-Credits-Remaining headers.
FighterAPI at a glance
- UFC and MMA data and odds API: UFC fights since 2000, plus PFL and Bellator: results, round stats, fighters and odds. REST and MCP.
- 12 tools, every one on the free plan. Each call costs 1 to 10 credits; the table below has every price.
- Free: 500 credits every month, no card. Plans: Starter $19/month (10,000 credits), Pro $49/month (30,000 credits), Scale $149/month (125,000 credits), Business $299/month (300,000 credits). Top-ups: 400 credits per $1, from $5.
- MCP server: https://mcp.fighterapi.com/mcp?key=YOUR_API_KEY (or the key in an
x-api-keyheader; Claude and ChatGPT connect with a sign-in instead) - REST: POST https://mcp.fighterapi.com/v1/ with your key in an
x-api-keyheader and the arguments as a JSON body. - Python:
pip install fighterapi. JavaScript:npm install fighterapi - Fights: Every UFC fight. Every UFC card since 2000, with results, method, round and time.
- Rounds: Round by round. Strikes, takedowns, control time and submission attempts for every round, checked against fight totals.
- Ratings: Every fighter. Our Elo for every UFC fighter, before and after every fight since 2000.
| Credits | Tools | | --- | --- | | 1 | get_data_status, list_events, search_fighters | | 2 | get_event, get_schedule, get_ratings | | 5 | get_fight, get_fighter, get_fighter_fights, get_leaders, get_odds | | 10 | get_line_movement |
- get_odds: 5 credits a call, 10 for its bulk form (a whole day, card or league).
Install
npm install fighterapiGet a free key (500 credits every month, no card) at https://fighterapi.com/signup?utm_source=npm&utm_medium=readme&utm_campaign=fighterapi-js and set FIGHTERAPI_API_KEY.
import { Client } from "fighterapi"
const client = new Client() // reads FIGHTERAPI_API_KEY, or new Client({ apiKey: "..." })
const data = await client.listEvents({"status":"final","limit":3})
console.log(data)
console.log("credits left:", client.lastCreditsRemaining)Every method takes one object with the API's parameter names and returns the unwrapped data. client.call("tool_name", {...}) reaches any tool newer than this package. Errors are typed: AuthError (401), InsufficientCreditsError (402), NotFoundError (404), RateLimitError (429, with retryAfter), APIError otherwise. 429 and 5xx responses are retried with backoff.
Load a whole season
client.loadSeason(dataset, season) pulls every page of one dataset for a season and returns an array of row objects. Nested fields become dotted keys (home.abbrev).
const rows = await client.loadSeason("events", 2025) // first call: pages through the API
const again = await client.loadSeason("events", 2025) // second call: read from ~/.cache/fighterapi/, no requests
await client.loadSeason("events", 2025, { refresh: true }) // pull againSeasons are calendar years.
| Dataset | Tool | What a row is | Requests for a typical season | Credits for a typical season |
| --- | --- | --- | --- | --- |
| events | listEvents | a year's fight cards | 1 | 1 |
Price a big pull first
Every request costs the tool's normal credits. Per-game datasets (plays, odds and props by game) make one request per played game, so a full season is thousands of credits. Ask first:
console.log(await client.loadSeason("events", 2025, { estimate: true }))
// { dataset: "events", season: ..., calls: ..., credits: ..., basis: ..., data_calls: 0 }estimate: true makes no data requests and spends nothing. Where the tool accepts estimate_only (season-wide odds, props) it asks the server for the price; it uses the games already in your cache when there are some, and typical season sizes otherwise. The numbers in the table are the same typical sizes: they are approximate, an order of magnitude and not a quote.
maxCalls(default 100) stops a pull that turns out larger than expected. It throwsLoadLimitError, which holds the rows fetched so far (err.rows), and caches nothing. Raise it deliberately for a big pull.- Extra tool arguments go in
params({ team: "BOS" },{ league: "mls" }). Do not pass the season, paging or date arguments:loadSeasonsets them. - In Node the result is cached as JSON lines under
~/.cache/fighterapi/(cacheDirorFIGHTERAPI_CACHE_DIRmoves it,cache: falseskips it). Browsers and other runtimes withoutnode:fshave no cache. client.lastLoadreports the last load:rows,calls,creditsUsedandcached.- Per-game datasets skip games that start today or later.
Tools
| Method | What it returns | Credits |
| --- | --- | --- |
| listEvents | List events | 1 |
| getEvent | Event | 2 |
| getSchedule | Schedule | 2 |
| getFight | Fight | 5 |
| searchFighters | Search fighters | 1 |
| getFighter | Fighter | 5 |
| getFighterFights | Fighter fights | 5 |
| getLeaders | Leaders | 5 |
| getRatings | Ratings | 2 |
| getOdds | Odds | 5 |
| getLineMovement | Line movement | 10 |
| getDataStatus | Data status | 1 |
Full reference with response shapes: https://fighterapi.com/docs?utm_source=npm&utm_medium=readme&utm_campaign=fighterapi-js. The same data is available as a hosted MCP server for Claude, ChatGPT and Cursor: https://fighterapi.com/mcp. A Python client is on PyPI: pip install fighterapi.
MIT licensed.
