Backtest your rules
A
POST
/v1/backtest
Your rules, P&L at exchange prices net of commission
Post a rule and get the P&L back, staked level at the kickoff price and net of commission, with the equity curve and the maximum drawdown. The same engine that produces the Lab.
Plan
This endpoint needs Archive.
Calling it on a lower plan returns a 403 naming the plan it needs and
a link to pricing, never a bare refusal.
Parameters
league_id
string
query
Restrict to one competition. Ids come from
/v1/leagues: 39 is the English Premier League, 62 is Ligue 2. e.g. lg_24T9Z0G
season
integer
query
Season by its starting year. A 2024/25 season is
2024. e.g. 2024
date_from
string
query
Earliest kickoff date, inclusive. ISO
YYYY-MM-DD, evaluated in UTC. e.g. 2024-08-01
date_to
string
query
Latest kickoff date, inclusive. e.g.
2024-08-31
min_price
number
query
Lower bound on the kickoff price for the selection. e.g.
1.5
max_price
number
query
Upper bound on the kickoff price for the selection. e.g.
2.0
Returns
data.rule
object
Rule.
data.rule.back
string
Back.
data.rule.max_price
number
Max price.
data.rule.league_id
string
Our id for the competition.
data.bets
integer
Bets.
data.won
integer
Won.
data.strike_rate
number
Strike rate.
data.roi_net
number
Roi net.
data.max_drawdown
number
Max drawdown.
data.commission
number
Commission.
data.staking
string
Staking.
meta.data_as_of
string
When the data behind this answer was last brought up to date.
meta.request_id
string
This request's id, to quote to support.
meta.note
string
Note.
Request
curl "https://api.footballsoccerapi.com/v1/backtest?league_id=lg_24T9Z0G&season=2024&date_from=2024-08-01" \ -H "X-API-Key: $FSAPI_KEY"
const res = await fetch("https://api.footballsoccerapi.com/v1/backtest?league_id=lg_24T9Z0G&season=2024&date_from=2024-08-01", { headers: { "X-API-Key": process.env.FSAPI_KEY } }); const { data, meta } = await res.json();
import os, requests r = requests.get( "https://api.footballsoccerapi.com/v1/backtest?league_id=lg_24T9Z0G&season=2024&date_from=2024-08-01", headers={"X-API-Key": os.environ["FSAPI_KEY"]}, ) data = r.json()["data"]
$ch = curl_init("https://api.footballsoccerapi.com/v1/backtest?league_id=lg_24T9Z0G&season=2024&date_from=2024-08-01"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["X-API-Key: {$key}"], ]); $data = json_decode(curl_exec($ch), true)["data"];
Example response
A real row from the archive, fetched when this page rendered. Run it against your own key below.
200 OK
application/json
{
"data": {
"rule": {
"back": "home",
"max_price": 1.8,
"league_id": "lg_24T9Z0G"
},
"bets": 1284,
"won": 704,
"strike_rate": 54.8,
"roi_net": -3.1,
"max_drawdown": -18.4,
"commission": 0.02,
"staking": "level"
},
"meta": {
"data_as_of": "2026-10-29T04:32:57Z",
"request_id": "01J9QW3C7M4KX2VB",
"note": "P&L at kickoff prices, net of commission."
}
}
Run it live
Paste your key and fire the real request. The key is kept in this browser only and never sent anywhere but the API.