# MFL API

> The MFL API (https://api.playmfl.com) gives read access to the data of MFL (Metaverse Football League), a football management game on the Flow blockchain: players, clubs, competitions, matches and marketplace listings. Responses are JSON. This file points to the API reference and to the reference data (countries, positions, formations, overall formula, enums, images, smart contracts) needed to interpret responses.

Rules for any code calling the API:

- Recommended: send an MFL API token in the `X-MFL-Api-Token` header. Public data works without one, but tokened tools are identified and can be contacted. To get one, the developer requests it from MFL support through the live chat: https://guide.playmfl.com/developers/api-token.
- Keep the token server-side: never put it in browser or mobile code, or in a public repository.
- For bulk player data, download the daily players CSV export (manifest: https://d13e14gtps4iwl.cloudfront.net/u/exports/players/active.json, details: https://guide.playmfl.com/developers/resources/players-export) instead of paging through `GET /players`.
- Rate limits apply per IP address, with or without a token. On HTTP 429, stop, then retry with increasing delays (for example 5 s, 10 s, 30 s, 1 min).
- At most 5 requests in parallel, and about 1 request per second on average for long jobs.
- Cache responses and avoid polling faster than the data changes: player stats change once a day, finished matches never change. For recent results, poll `GET /matches/feed` instead of fetching each match.
- Send a descriptive `User-Agent` that names the tool and how to reach its author.

## API

- [OpenAPI spec](https://api.playmfl.com/openapi.json): machine-readable description of every endpoint, parameter, response and error key
- [API reference](https://guide.playmfl.com/developers/api): the same, as documentation
- [API token](https://guide.playmfl.com/developers/api-token): how to get and send a token

## Resources

- [Players Export](https://guide.playmfl.com/developers/resources/players-export): The whole player base as a daily CSV file on the CDN, instead of paging through GET /players.
- [Enums](https://guide.playmfl.com/developers/resources/enums): What the coded values in API responses mean: statuses, types, divisions, rarity…
- [Player Images](https://guide.playmfl.com/developers/resources/player-images): Player photo and club logo URLs, and React components to display a player card and photo.
- [Overall Rating](https://guide.playmfl.com/developers/resources/overall): How a player's overall is computed from his stats, for each position.
- [Positions](https://guide.playmfl.com/developers/resources/positions): The 15 position codes, their line, and their full name and short code in every language of the app.
- [Formations](https://guide.playmfl.com/developers/resources/formations): The position and pitch coordinates of every lineup index, for all 25 formations.
- [Out-of-Position Penalty](https://guide.playmfl.com/developers/resources/out-of-position): How much overall a starter loses when he plays away from his positions.
- [Smart Contracts](https://guide.playmfl.com/developers/resources/smart-contracts): Flow mainnet addresses of the MFL contracts and the standard contracts they use.
- [Countries](https://guide.playmfl.com/developers/resources/countries): Country keys used for nationalities and clubs, with their name in every language of the app.

## Downloads

- [enums.json](https://guide.playmfl.com/developers/resources/enums.json): Enums, JSON
- [PlayerCard.tsx](https://guide.playmfl.com/developers/resources/PlayerCard.tsx): Player Images, React (TSX)
- [PlayerImage.tsx](https://guide.playmfl.com/developers/resources/PlayerImage.tsx): Player Images, React (TSX)
- [overall.ts](https://guide.playmfl.com/developers/resources/overall.ts): Overall Rating, TypeScript
- [overall.json](https://guide.playmfl.com/developers/resources/overall.json): Overall Rating, JSON
- [positions.json](https://guide.playmfl.com/developers/resources/positions.json): Positions, JSON
- [positions.csv](https://guide.playmfl.com/developers/resources/positions.csv): Positions, CSV
- [formations.json](https://guide.playmfl.com/developers/resources/formations.json): Formations, JSON
- [formations.ts](https://guide.playmfl.com/developers/resources/formations.ts): Formations, TypeScript
- [out-of-position.json](https://guide.playmfl.com/developers/resources/out-of-position.json): Out-of-Position Penalty, JSON
- [out-of-position.ts](https://guide.playmfl.com/developers/resources/out-of-position.ts): Out-of-Position Penalty, TypeScript
- [contracts.json](https://guide.playmfl.com/developers/resources/contracts.json): Smart Contracts, JSON
- [countries.json](https://guide.playmfl.com/developers/resources/countries.json): Countries, JSON
- [countries.csv](https://guide.playmfl.com/developers/resources/countries.csv): Countries, CSV

## Optional

- [llms-full.txt](https://guide.playmfl.com/llms-full.txt): this file with every resource page and file inlined
