On this page
Advanced Query Engine
POST /v1/query runs a structured statistical query through the API-owned engine. Never send raw Mongo pipelines or field paths. See also Statistical concepts and Filtering & query parameters.
Interactive limit max: 200. Complexity score max: 80.
Example request
cURL
curl -s https://api.crunchclash.com/v1/query \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"entity": "player",
"season": "2026-27",
"filters": [{"field": "minutes", "operator": "gte", "value": 900}],
"metrics": ["appearances", "minutes", "goals", "expectedGoals"],
"sort": {"field": "expectedGoals", "direction": "desc"},
"limit": 50
}'
JavaScript
const API_KEY = "YOUR_API_KEY";
const res = await fetch("https://api.crunchclash.com/v1/query", {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
"content-type": "application/json",
},
body: JSON.stringify({
entity: "player",
season: "2026-27",
filters: [{ field: "minutes", operator: "gte", value: 900 }],
metrics: ["appearances", "minutes", "goals", "expectedGoals"],
sort: { field: "expectedGoals", direction: "desc" },
limit: 50,
}),
});
console.log(await res.json());
Python
import requests
API_KEY = "YOUR_API_KEY"
payload = {
"entity": "player",
"season": "2026-27",
"filters": [{"field": "minutes", "operator": "gte", "value": 900}],
"metrics": ["appearances", "minutes", "goals", "expectedGoals"],
"sort": {"field": "expectedGoals", "direction": "desc"},
"limit": 50,
}
r = requests.post(
"https://api.crunchclash.com/v1/query",
json=payload,
headers={"Authorization": f"Bearer {API_KEY}"},
)
print(r.json())
Capabilities
- Entities:
player|club|match - Grains:
player-season|club-season|team-match|player-match|match - Metrics: catalogue ids only (1–20); multi-metric supported
- Filters: top-level
filters= single AND group; optionalfilter_groups: [{ op: "and"|"or", filters: [...] }] - Sort:
{ field, direction }or an array of up to 3 sort keys group_byaggregations:sum(default) |count|avg(numeric only; never raw-avg per-90 — engines recompute from totals)home_away: "home"|"away"onteam-match/player-matchonly (matches$lookup)- Derived / per-90 metrics projected via catalogue formulas (missing ≠ 0)
- Nested SDP statistics via catalogue paths (e.g.
minutes→statistics.timePlayed)
Common errors
INVALID_DSL, UNKNOWN_METRIC, INCOMPATIBLE_GRAIN, ENTITY_NOT_FOUND, QUERY_TOO_COMPLEX, QUERY_TIMEOUT
See QUERY_ENGINE_SPEC internals in the repo and Errors and limits.
Related: API Reference · Playground