Why this works
https://api.thestatsapi.com/llms.txtis the whole API reference in one Markdown file: every endpoint, parameter and response field. It’s generated from our OpenAPI spec, so it matches the live API.- With it, your AI uses real endpoint and parameter names instead of guessing.
- If the AI still sends a wrong parameter, the API answers with
400 UNKNOWN_PARAMETERand suggests the right name, so the AI can fix its own mistake.
Three steps
1
Get your API key
Create an account, then make a key on the API keys page. The key is shown only once, so save it straight into a Make sure
.env file in your project:.env
.env is listed in your .gitignore.2
Give your AI the API reference
This is the link your AI needs:If your tool works on files in your project (Claude Code, Codex, Cursor), save a copy into the project too:The file is about 300 KB. Web-fetch tools often summarise or cut off long pages, but a local copy can be searched in full. Re-run the
curl command now and then to pick up API changes. Don’t add this file to .gitignore: Cursor hides git-ignored files from its AI.3
Paste a starter prompt
Replace
[describe your app] and paste this into your AI tool. It points the AI at the reference, keeps your key on the server and heads off the most common mistakes.Starter prompt
Set up your tool
For Claude Code, Codex and Cursor, also save these project notes in your project. The AI reads them every session, so it keeps following the rules. Keep the reference file path in backticks and don’t paste the wholellms.txt into this file: it’s too big to load every time.
Project notes
- Claude Code
- Codex
- Cursor
- Lovable
- In your project folder, download the reference (step 2) and create
.env(step 1). - Save the project notes above as
CLAUDE.mdin the project root. - Run
claudeand paste the starter prompt.
.claude/settings.json:.claude/settings.json
NEXT_PUBLIC_ or VITE_ variable for it: those are bundled into browser code.
Get live data in your AI chat (MCP)
Our MCP server lets your AI assistant look up live football data while you work: find an ID, check today’s fixtures, or see what a response looks like. It doesn’t replacellms.txt for writing code.
It uses your own API key, so its calls count against your plan. Its tools are read-only and cover competitions, standings, teams, squads, players, injuries, matches, lineups, match and player stats, shot maps, heatmaps, referees and coverage. It doesn’t include odds; use the REST API for those.
- Claude Code
- Cursor
- Codex
- VS Code
- Gemini CLI
Export the key first, then add the server. If you don’t export it, the shell expands Run
$THESTATSAPI_API_KEY to nothing and the saved header is empty.claude mcp list to check it shows as connected.MCP tool arguments are not REST parameters. For example, the
find_matches tool accepts date, but the REST endpoint /football/matches only accepts date_from and date_to. When your AI writes code, it should take names from llms.txt, not from the MCP tools.Prompt ideas
Add one of these after the starter prompt:- Live scores widget: “Show today’s Premier League matches with live scores. Use
/football/matcheswithdate_fromanddate_toset to today, and poll every 60 seconds only while a match is live.” - League table page: “Build a page with the current Premier League table. Get
current_season_idfrom/football/competitions/comp_3039, then call the season’s standings endpoint.” - Fantasy points: “For a finished match, get
/football/matches/{match_id}/player-statsand score each player with my rules: 4 points a goal, 3 an assist, 1 for playing 60 minutes or more.” - xG shot map: “Draw a pitch with every shot from
/football/matches/{match_id}/shotmap, sized byexpected_goals. Only offer it for matches whereshotmap_availableis true.” - Odds comparison: “For this weekend’s Premier League matches, show the best home, draw and away price across bookmakers from
/football/matches/{match_id}/odds. Skip matches whereodds_availableis false.”
Tips for good results
- Paste errors back in. A
400 UNKNOWN_PARAMETERmessage names the right parameter, for example:Unknown query parameter 'date' (did you mean 'date_from' or 'date_to'?). AI tools can usually fix the call from that. - Give it real IDs. Look them up in the ID finder in your dashboard, or let the AI use the
search=endpoints. Don’t let it make IDs up. - Watch your quota. An agent stuck in a retry loop can use up your requests quickly, and trials get 10% of the plan’s limits. Ask for caching. See Rate limits.
- Check coverage before you build a feature. Not every competition has xG, player stats or odds. See Coverage.
More AI resources
Next steps
Quickstart
Make your first requests by hand and see what comes back.
Finding IDs
Look up the competition, season, team and player IDs your app needs.
Errors
What each error code means and how to fix it.
API reference
Every endpoint, with a playground to try requests.