football-docs 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@ Searchable football data provider and tooling documentation for AI coding agents
4
4
 
5
5
  **Who it's for:** Developers and analysts who use AI coding tools (Claude Code, Cursor, VS Code Copilot) to work with football data. Works with any tool that supports MCP.
6
6
 
7
- **What it does:** Gives your AI agent a searchable index of documentation for 20 football data providers and tools — event types, qualifier IDs, coordinate systems, API endpoints, data models, identity surfaces, and cross-provider comparisons for the data providers (StatsBomb, Opta, Wyscout, Impect, SkillCorner, Sportradar, TheSportsDB, FMDB Pro, TransferRoom, and more), plus the open-source libraries people build with (kloppy, mplsoccer, socceraction, soccerdata, floodlight, and more). Your agent looks up the real docs instead of guessing from training data.
7
+ **What it does:** Gives your AI agent a searchable index of documentation for 21 football data providers and tools — event types, qualifier IDs, coordinate systems, API endpoints, data models, identity surfaces, and cross-provider comparisons for the data providers (StatsBomb, Opta, Wyscout, Impect, SkillCorner, Sportradar, TheSportsDB, FMDB Pro, TransferRoom, and more), plus the open-source libraries people build with (kloppy, mplsoccer, socceraction, soccerdata, floodlight, and more). Your agent looks up the real docs instead of guessing from training data.
8
8
 
9
9
  **Why not just let the AI figure it out?** LLMs get football data specifics wrong constantly — Opta qualifier IDs, StatsBomb coordinate ranges, API endpoint URLs, library method signatures. These are mutable facts that change across versions. football-docs gives the agent verified, sourced documentation with provenance tracking so you know where every answer came from.
10
10
 
@@ -19,11 +19,11 @@ public-safe provider facts, and how contributors should prove retrieval quality.
19
19
 
20
20
  football-docs is the public source for provider identity-surface facts: access
21
21
  shape, ID schemes, matching fields, provider quirks, and provenance rules.
22
- Curated provider identity notes belong here when they can be stated without
23
- private register state. They should say whether a fact comes from public docs,
22
+ Curated provider identity notes belong here when they can be stated as public
23
+ facts about the provider. They should say whether a fact comes from public docs,
24
24
  public page evidence, licensed feed shape, or a reviewed public-safe
25
- observation, and must not include private paths, credentials, scraper state,
26
- action ledgers, mint salts, or raw restricted payloads.
25
+ observation, and must not include credentials, local paths, internal tooling
26
+ details, or restricted payloads from any private project.
27
27
 
28
28
  MCP ([Model Context Protocol](https://modelcontextprotocol.io)) is a standard for connecting AI coding tools to external data sources.
29
29
 
@@ -108,7 +108,7 @@ Provider filters use the indexed provider keys shown by `list_providers`, but co
108
108
 
109
109
  | Provider | Chunks | Categories |
110
110
  |----------|--------|------------|
111
- | StatsBomb | 234 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-lineups, xg-model, iq-metrics, player/team stats, player-mapping, identity-surfaces |
111
+ | StatsBomb | 235 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-lineups, xg-model, iq-metrics, player/team stats, player-mapping, identity-surfaces |
112
112
  | Wyscout | 161 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-analysis-metrics, glossary, identity-surfaces |
113
113
  | kloppy | 126 | data-model, usage, provider-mapping, tracking-rendering, event-derived-metrics |
114
114
  | floodlight | 145 | core data objects, io parsers (Tracab, DFL, Kinexon, Opta, SkillCorner, StatsBomb, StatsPerform, Second Spectrum), transforms, metrics, models, visualisation, guides |
@@ -118,18 +118,19 @@ Provider filters use the indexed provider keys shown by `list_providers`, but co
118
118
  | Impect | 77 | overview, data-model, event-types, coordinate-system, concepts, kpi-definitions, identity-surfaces |
119
119
  | SkillCorner | 48 | api-access, api-endpoints, data-model, physical-data, coordinate-system, concepts, identity-surfaces |
120
120
  | Free sources | 62 | overview, fbref, understat, contextual-story-joins, xg-timelines |
121
- | soccerdata | 41 | overview, data-sources, usage |
121
+ | soccerdata | 40 | overview, data-sources, usage |
122
122
  | TransferRoom | 43 | api-access, api-endpoints, charting-availability, data-model, identity-surfaces |
123
123
  | Opta | 71 | event-types, qualifiers, coordinate-system, api-access, charting-game-state, charting-lineups, charting-passmaps, charting-set-pieces, charting-shot-placement, identity-surfaces |
124
124
  | FMDB Pro | 35 | api-access, api-endpoints, data-model, identity-surfaces |
125
125
  | Sportradar | 29 | api-access, api-endpoints, data-model, charting-and-stories, integration-notes |
126
- | socceraction | 27 | SPADL format, VAEP, Expected Threat |
126
+ | socceraction | 34 | SPADL format, VAEP, Expected Threat |
127
+ | BeSoccer | 14 | api-access, api-endpoints |
127
128
  | TheSportsDB | 18 | api-access, api-endpoints, livescore, identity-surfaces |
128
129
  | FotMob | 3 | identity-surfaces |
129
130
  | Soccerdonna | 3 | identity-surfaces |
130
131
  | Transfermarkt | 3 | identity-surfaces |
131
132
 
132
- **1,335 searchable chunks** across 20 providers and tools.
133
+ **1,356 searchable chunks** across 21 providers and tools.
133
134
 
134
135
  > **Impect** documentation is built solely from the public
135
136
  > [ImpectAPI/open-data](https://github.com/ImpectAPI/open-data) repository — a
@@ -140,6 +141,41 @@ Provider filters use the indexed provider keys shown by `list_providers`, but co
140
141
  > (`pnpm impect:truth`, `src/__tests__/impect-open-data-validation.test.ts`).
141
142
  > Data source: **Impect**; use is subject to the repository's own Terms of Use.
142
143
 
144
+ ## Documentation validation
145
+
146
+ Docs for AI agents are only useful if they are correct, and prose about an API is
147
+ exactly the kind of thing that drifts or gets invented. Where a machine-readable
148
+ source of truth exists, this repo checks the docs against it in CI rather than
149
+ trusting them.
150
+
151
+ | Providers | Ground truth | Checked by |
152
+ |---|---|---|
153
+ | kloppy, socceraction, soccerdata, mplsoccer, floodlight, databallpy, skillcorner | The installed package itself — enum members, importable symbols, class constants | `src/__tests__/provider-truth.test.ts` |
154
+ | Wyscout, SkillCorner, FMDB Pro, Sportradar | The vendor's own publicly published OpenAPI spec — endpoint paths and methods | `src/__tests__/provider-truth.test.ts` |
155
+ | BeSoccer | The vendor's published Postman collection — request vocabulary and parameters | `src/__tests__/provider-truth.test.ts` |
156
+ | Impect | The public [open-data](https://github.com/ImpectAPI/open-data) repository | `src/__tests__/impect-open-data-validation.test.ts` |
157
+
158
+ Truth files live in `data/provider-truth/` and are generated, not hand-written:
159
+
160
+ ```bash
161
+ pnpm provider:truth # rebuild every package truth file (needs python3.11)
162
+ pnpm openapi:truth # rebuild every spec-derived truth file
163
+ ```
164
+
165
+ The specs those derive from are snapshots of **publicly published, unauthenticated**
166
+ vendor documentation. Source URLs, fetch dates and refresh instructions are in
167
+ [`specs/README.md`](specs/README.md). Wyscout's three API versions merge into one
168
+ truth file, because its docs legitimately span v2, v3 and v4.
169
+
170
+ Each package gets its own pinned venv — co-installing them makes pip silently
171
+ downgrade conflicting versions, which would produce truth that disagrees with the
172
+ docs. Bump a pin in `scripts/gen_all_truth.sh` and the matching `version` in
173
+ `providers.json` together, then re-run and fix whatever the tests flag.
174
+
175
+ A doc that names an enum member or importable symbol which does not exist in the
176
+ real package fails the build. `scripts/gen_openapi_truth.py` derives the same kind
177
+ of facts from a vendor OpenAPI spec, for providers documented that way.
178
+
143
179
  ## Contributing
144
180
 
145
181
  Contributions are welcome from everyone. There are three ways to help:
package/data/docs.db CHANGED
Binary file
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Validate provider docs against ground truth introspected from the real package.
3
+ *
4
+ * Companion to scripts/gen_python_truth.py, which writes
5
+ * data/provider-truth/<provider>.json from an installed package. This module
6
+ * checks docs/<provider>/*.md against those facts and is run by the test suite,
7
+ * so a doc claiming a symbol or enum member that does not exist fails the build.
8
+ *
9
+ * Two checks, both chosen for precision over coverage:
10
+ *
11
+ * 1. Imports - every `from <package> import X` in a doc must resolve to a real
12
+ * symbol. This is what catches fabricated API surface.
13
+ * 2. Enum members - every SCREAMING_SNAKE token in a code span must belong to
14
+ * one of the package's enums, or be explicitly allowlisted below.
15
+ *
16
+ * Regenerate a truth file after a version bump:
17
+ * python3 scripts/gen_python_truth.py kloppy --provider kloppy
18
+ */
19
+ export interface PythonPackageTruth {
20
+ provider: string;
21
+ kind: string;
22
+ source: {
23
+ package: string;
24
+ version: string;
25
+ generated_at: string;
26
+ };
27
+ modules: Record<string, string[]>;
28
+ enums: Record<string, string[]>;
29
+ valueLists: Record<string, string[]>;
30
+ classes: string[];
31
+ symbols: string[];
32
+ signatures: Record<string, string>;
33
+ }
34
+ export interface DocFile {
35
+ file: string;
36
+ text: string;
37
+ }
38
+ export interface OpenApiTruth {
39
+ provider: string;
40
+ kind: string;
41
+ source: {
42
+ specs: Array<{
43
+ spec: string;
44
+ title: string;
45
+ version: string;
46
+ }>;
47
+ generated_at: string;
48
+ };
49
+ /** Server base paths (e.g. /soccer/trial/v4), which callable URLs include. */
50
+ basePaths?: string[];
51
+ /** Endpoint path -> the HTTP methods the spec defines on it. */
52
+ paths: Record<string, string[]>;
53
+ parameters: string[];
54
+ schemas: string[];
55
+ fields: string[];
56
+ enums: Record<string, string[]>;
57
+ }
58
+ /**
59
+ * Compare endpoints on shape, not on parameter naming. Docs and specs often use
60
+ * different placeholder names for the same path segment, and that is a style
61
+ * difference rather than a documentation error.
62
+ */
63
+ export declare function normalisePath(path: string, basePaths?: string[]): string;
64
+ /**
65
+ * Endpoint claims in a doc set, from both notations the corpus uses: inline code
66
+ * spans (`GET /matches/{wyId}/events`) and HTTP request lines inside fenced
67
+ * blocks (```http ... GET /api/players HTTP/1.1).
68
+ */
69
+ export declare function extractDocumentedEndpoints(text: string): Array<{
70
+ method: string;
71
+ path: string;
72
+ }>;
73
+ /**
74
+ * How many endpoint claims a doc set actually makes.
75
+ *
76
+ * validateOpenApiDocs returns no violations both when every endpoint is correct
77
+ * and when a doc set cites no endpoints at all. Those are very different states,
78
+ * and only one of them means anything, so callers can check coverage separately.
79
+ */
80
+ export declare function countDocumentedEndpoints(docs: DocFile[]): number;
81
+ export declare function loadOpenApiTruth(provider: string): OpenApiTruth;
82
+ export declare function listOpenApiProviders(): string[];
83
+ /** Check that every endpoint a doc set cites exists in the vendor's own spec. */
84
+ export declare function validateOpenApiDocs(docs: DocFile[], truth: OpenApiTruth): string[];
85
+ export declare function loadProviderTruth(provider: string): PythonPackageTruth;
86
+ export declare function listTruthProviders(): string[];
87
+ export declare function loadProviderDocs(provider: string): DocFile[];
88
+ /** Names imported from the package in `from x import a, b` statements. */
89
+ export declare function extractImportedSymbols(text: string, pkg: string): string[];
90
+ /** SCREAMING_SNAKE_CASE tokens inside backtick code spans. */
91
+ export declare function extractEnumTokens(text: string): string[];
92
+ export declare function validateProviderDocs(docs: DocFile[], truth: PythonPackageTruth): string[];
93
+ export interface PostmanTruth {
94
+ provider: string;
95
+ kind: string;
96
+ source: {
97
+ collection: string;
98
+ name: string;
99
+ dispatch_param: string | null;
100
+ generated_at: string;
101
+ };
102
+ baseUrls: string[];
103
+ parameters: string[];
104
+ operations: Record<string, {
105
+ group: string;
106
+ methods: string[];
107
+ names: string[];
108
+ params: string[];
109
+ }>;
110
+ }
111
+ export declare function loadPostmanTruth(provider: string): PostmanTruth;
112
+ export declare function listPostmanProviders(): string[];
113
+ /** Resource selectors a doc set cites, e.g. `req=match_lineups`. */
114
+ export declare function extractDispatchValues(text: string, param: string): string[];
115
+ /**
116
+ * Check a single-endpoint API's docs against the published request vocabulary.
117
+ *
118
+ * With no paths to get wrong, the failure mode moves to the dispatch parameter:
119
+ * an invented or misspelled `req` value is not a routing error and will not
120
+ * necessarily look like one at runtime.
121
+ */
122
+ export declare function validatePostmanDocs(docs: DocFile[], truth: PostmanTruth): string[];
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Validate provider docs against ground truth introspected from the real package.
3
+ *
4
+ * Companion to scripts/gen_python_truth.py, which writes
5
+ * data/provider-truth/<provider>.json from an installed package. This module
6
+ * checks docs/<provider>/*.md against those facts and is run by the test suite,
7
+ * so a doc claiming a symbol or enum member that does not exist fails the build.
8
+ *
9
+ * Two checks, both chosen for precision over coverage:
10
+ *
11
+ * 1. Imports - every `from <package> import X` in a doc must resolve to a real
12
+ * symbol. This is what catches fabricated API surface.
13
+ * 2. Enum members - every SCREAMING_SNAKE token in a code span must belong to
14
+ * one of the package's enums, or be explicitly allowlisted below.
15
+ *
16
+ * Regenerate a truth file after a version bump:
17
+ * python3 scripts/gen_python_truth.py kloppy --provider kloppy
18
+ */
19
+ import { readdirSync, readFileSync } from "node:fs";
20
+ import { dirname, resolve } from "node:path";
21
+ import { fileURLToPath } from "node:url";
22
+ const __dirname = dirname(fileURLToPath(import.meta.url));
23
+ const TRUTH_DIR = resolve(__dirname, "..", "data", "provider-truth");
24
+ const DOCS_DIR = resolve(__dirname, "..", "docs");
25
+ /**
26
+ * SCREAMING_SNAKE tokens that legitimately appear in a provider's docs without
27
+ * being members of that package's own enums - other providers' vocabularies,
28
+ * format markers, and column names. Anything not listed here and not in the
29
+ * package is treated as invented.
30
+ */
31
+ const TOKEN_ALLOWLIST = {
32
+ kloppy: ["SPADL", "VAEP"],
33
+ socceraction: ["SPADL", "VAEP"],
34
+ soccerdata: [
35
+ // Environment variables and a log level, read by the package but not symbols in it.
36
+ "SOCCERDATA_DIR",
37
+ "SOCCERDATA_LOGLEVEL",
38
+ "SOCCERDATA_MAXAGE",
39
+ "SOCCERDATA_NOCACHE",
40
+ "SOCCERDATA_NOSTORE",
41
+ "INFO",
42
+ // football-data.co.uk CSV headers, which MatchHistory passes through unrenamed.
43
+ "FTHG",
44
+ "FTAG",
45
+ "HTHG",
46
+ "HTAG",
47
+ "B365H",
48
+ "B365D",
49
+ "B365A",
50
+ ],
51
+ mplsoccer: [],
52
+ floodlight: ["PATH"],
53
+ databallpy: [],
54
+ // HTTP verbs in the endpoint tables.
55
+ skillcorner: ["GET", "POST"],
56
+ };
57
+ /**
58
+ * Endpoint paths a doc set may cite without the spec defining them - other
59
+ * vendors' endpoints named in comparison prose, and illustrative examples.
60
+ */
61
+ const ENDPOINT_ALLOWLIST = {
62
+ wyscout: [],
63
+ skillcorner: [],
64
+ "fmdb-pro": [],
65
+ };
66
+ /**
67
+ * Compare endpoints on shape, not on parameter naming. Docs and specs often use
68
+ * different placeholder names for the same path segment, and that is a style
69
+ * difference rather than a documentation error.
70
+ */
71
+ export function normalisePath(path, basePaths = []) {
72
+ let p = path.split("?")[0].trim();
73
+ // Docs cite the callable URL, which carries the server base path and often a
74
+ // response-format extension; the spec lists neither.
75
+ for (const base of [...basePaths].sort((a, b) => b.length - a.length)) {
76
+ if (p.startsWith(base)) {
77
+ p = p.slice(base.length);
78
+ break;
79
+ }
80
+ }
81
+ return p
82
+ .replace(/\.(json|xml)$/i, "")
83
+ .replace(/\{[^}]*\}/g, "{}")
84
+ .replace(/\/+$/, "")
85
+ .trim();
86
+ }
87
+ /**
88
+ * Endpoint claims in a doc set, from both notations the corpus uses: inline code
89
+ * spans (`GET /matches/{wyId}/events`) and HTTP request lines inside fenced
90
+ * blocks (```http ... GET /api/players HTTP/1.1).
91
+ */
92
+ export function extractDocumentedEndpoints(text) {
93
+ const out = [];
94
+ const seen = new Set();
95
+ const add = (method, rawPath) => {
96
+ // `GET /metrics/game_intelligence/...` is prose shorthand for a family of
97
+ // endpoints, not a claim that this exact path exists.
98
+ if (rawPath.includes("..."))
99
+ return;
100
+ const key = `${method} ${rawPath}`;
101
+ if (seen.has(key))
102
+ return;
103
+ seen.add(key);
104
+ out.push({ method, path: rawPath });
105
+ };
106
+ for (const match of text.matchAll(/`(GET|POST|PUT|PATCH|DELETE)\s+(\/[^`\s]*)`/g)) {
107
+ add(match[1], match[2]);
108
+ }
109
+ // Request lines are anchored to the start of a line and may carry an HTTP
110
+ // version suffix, which keeps ordinary prose from matching.
111
+ for (const block of text.matchAll(/```[a-z]*\n([\s\S]*?)```/g)) {
112
+ for (const line of block[1].split("\n")) {
113
+ const m = line.match(/^\s*(GET|POST|PUT|PATCH|DELETE)\s+(\/\S*)(?:\s+HTTP\/[\d.]+)?\s*$/);
114
+ if (m)
115
+ add(m[1], m[2]);
116
+ }
117
+ }
118
+ return out;
119
+ }
120
+ /**
121
+ * How many endpoint claims a doc set actually makes.
122
+ *
123
+ * validateOpenApiDocs returns no violations both when every endpoint is correct
124
+ * and when a doc set cites no endpoints at all. Those are very different states,
125
+ * and only one of them means anything, so callers can check coverage separately.
126
+ */
127
+ export function countDocumentedEndpoints(docs) {
128
+ return docs.reduce((n, d) => n + extractDocumentedEndpoints(d.text).length, 0);
129
+ }
130
+ export function loadOpenApiTruth(provider) {
131
+ return JSON.parse(readFileSync(resolve(TRUTH_DIR, `${provider}.openapi.json`), "utf-8"));
132
+ }
133
+ export function listOpenApiProviders() {
134
+ return readdirSync(TRUTH_DIR)
135
+ .filter((f) => f.endsWith(".openapi.json"))
136
+ .map((f) => f.replace(/\.openapi\.json$/, ""))
137
+ .sort();
138
+ }
139
+ /** Check that every endpoint a doc set cites exists in the vendor's own spec. */
140
+ export function validateOpenApiDocs(docs, truth) {
141
+ const violations = [];
142
+ const bases = truth.basePaths ?? [];
143
+ // Spec paths as segment arrays. A placeholder segment matches any concrete
144
+ // value, so a doc showing a worked example (/en/...) still matches a spec
145
+ // written with a variable (/{locale}/...).
146
+ const specPaths = [];
147
+ for (const [path, methods] of Object.entries(truth.paths)) {
148
+ const segments = normalisePath(path, bases).split("/").filter(Boolean);
149
+ const existing = specPaths.find((s) => s.segments.length === segments.length && s.segments.every((seg, i) => seg === segments[i]));
150
+ const target = existing ?? { segments, methods: new Set() };
151
+ for (const m of methods)
152
+ target.methods.add(m);
153
+ if (!existing)
154
+ specPaths.push(target);
155
+ }
156
+ const matchSpec = (docPath) => {
157
+ const segments = normalisePath(docPath, bases).split("/").filter(Boolean);
158
+ const hit = specPaths.find((s) => s.segments.length === segments.length &&
159
+ s.segments.every((seg, i) => seg === "{}" || seg === segments[i]));
160
+ return hit?.methods;
161
+ };
162
+ const allowed = new Set((ENDPOINT_ALLOWLIST[truth.provider] ?? []).map((p) => normalisePath(p, bases)));
163
+ for (const { file, text } of docs) {
164
+ for (const { method, path } of extractDocumentedEndpoints(text)) {
165
+ const shape = normalisePath(path, bases);
166
+ if (allowed.has(shape))
167
+ continue;
168
+ const methods = matchSpec(path);
169
+ if (!methods) {
170
+ violations.push(`${file}: \`${method} ${path}\` - no such path in the ${truth.provider} spec`);
171
+ }
172
+ else if (!methods.has(method)) {
173
+ violations.push(`${file}: \`${method} ${path}\` - spec defines ${[...methods].sort().join(", ")} on this path, not ${method}`);
174
+ }
175
+ }
176
+ }
177
+ return violations;
178
+ }
179
+ export function loadProviderTruth(provider) {
180
+ return JSON.parse(readFileSync(resolve(TRUTH_DIR, `${provider}.json`), "utf-8"));
181
+ }
182
+ export function listTruthProviders() {
183
+ // Package truth is <provider>.json. Other kinds carry a qualifier
184
+ // (<provider>.openapi.json, <provider>.postman.json), so require a bare name.
185
+ return readdirSync(TRUTH_DIR)
186
+ .filter((f) => /^[a-z0-9-]+\.json$/.test(f))
187
+ .map((f) => f.replace(/\.json$/, ""))
188
+ .sort();
189
+ }
190
+ export function loadProviderDocs(provider) {
191
+ const dir = resolve(DOCS_DIR, provider);
192
+ return readdirSync(dir)
193
+ .filter((f) => f.endsWith(".md"))
194
+ .map((file) => ({ file, text: readFileSync(resolve(dir, file), "utf-8") }));
195
+ }
196
+ /** Names imported from the package in `from x import a, b` statements. */
197
+ export function extractImportedSymbols(text, pkg) {
198
+ const out = new Set();
199
+ const re = new RegExp(`from\\s+(${pkg}(?:\\.[\\w.]+)?)\\s+import\\s+([^\\n#]+)`, "g");
200
+ for (const match of text.matchAll(re)) {
201
+ for (const raw of match[2].split(",")) {
202
+ const name = raw.trim().replace(/\s+as\s+\w+$/, "").trim();
203
+ // `import *` says nothing about individual names.
204
+ if (name && name !== "*" && /^[A-Za-z_]\w*$/.test(name))
205
+ out.add(name);
206
+ }
207
+ }
208
+ return [...out];
209
+ }
210
+ /** SCREAMING_SNAKE_CASE tokens inside backtick code spans. */
211
+ export function extractEnumTokens(text) {
212
+ const out = new Set();
213
+ for (const match of text.matchAll(/`([A-Z][A-Z0-9_]{2,})`/g))
214
+ out.add(match[1]);
215
+ return [...out];
216
+ }
217
+ export function validateProviderDocs(docs, truth) {
218
+ const violations = [];
219
+ const pkg = truth.source.package;
220
+ const knownSymbols = new Set([
221
+ ...truth.symbols,
222
+ ...truth.classes,
223
+ ...Object.keys(truth.modules).map((m) => m.split(".").pop()),
224
+ ]);
225
+ // A SCREAMING_SNAKE token is legitimate if it is an enum member, or any real
226
+ // name in the package - module constants and class constants both get
227
+ // documented (soccerdata's TEAMNAME_REPLACEMENTS, floodlight's ECW_ES_CUTOFFS).
228
+ const knownTokens = new Set([
229
+ ...Object.values(truth.enums).flat(),
230
+ ...truth.symbols,
231
+ ...(TOKEN_ALLOWLIST[truth.provider] ?? []),
232
+ ]);
233
+ for (const { file, text } of docs) {
234
+ for (const name of extractImportedSymbols(text, pkg)) {
235
+ if (!knownSymbols.has(name)) {
236
+ violations.push(`${file}: \`from ${pkg}... import ${name}\` - no such symbol in ${pkg} ${truth.source.version}`);
237
+ }
238
+ }
239
+ for (const token of extractEnumTokens(text)) {
240
+ if (!knownTokens.has(token)) {
241
+ violations.push(`${file}: \`${token}\` is not a member of any ${pkg} enum - invented, renamed, or needs an allowlist entry`);
242
+ }
243
+ }
244
+ }
245
+ return violations;
246
+ }
247
+ export function loadPostmanTruth(provider) {
248
+ return JSON.parse(readFileSync(resolve(TRUTH_DIR, `${provider}.postman.json`), "utf-8"));
249
+ }
250
+ export function listPostmanProviders() {
251
+ return readdirSync(TRUTH_DIR)
252
+ .filter((f) => f.endsWith(".postman.json"))
253
+ .map((f) => f.replace(/\.postman\.json$/, ""))
254
+ .sort();
255
+ }
256
+ /** Resource selectors a doc set cites, e.g. `req=match_lineups`. */
257
+ export function extractDispatchValues(text, param) {
258
+ const out = new Set();
259
+ const inline = new RegExp(`${param}=([A-Za-z0-9_]+)`, "g");
260
+ for (const m of text.matchAll(inline))
261
+ out.add(m[1]);
262
+ // Reference tables list the value on its own, in a code span.
263
+ for (const m of text.matchAll(/\|\s*`([a-z][a-z0-9_]{2,})`\s*\|/g))
264
+ out.add(m[1]);
265
+ return [...out];
266
+ }
267
+ /**
268
+ * Check a single-endpoint API's docs against the published request vocabulary.
269
+ *
270
+ * With no paths to get wrong, the failure mode moves to the dispatch parameter:
271
+ * an invented or misspelled `req` value is not a routing error and will not
272
+ * necessarily look like one at runtime.
273
+ */
274
+ export function validatePostmanDocs(docs, truth) {
275
+ const violations = [];
276
+ const param = truth.source.dispatch_param;
277
+ if (!param)
278
+ return violations;
279
+ const known = new Set(Object.keys(truth.operations));
280
+ const params = new Set(truth.parameters);
281
+ for (const { file, text } of docs) {
282
+ for (const value of extractDispatchValues(text, param)) {
283
+ // A table cell may hold a parameter name rather than a resource selector.
284
+ if (known.has(value) || params.has(value))
285
+ continue;
286
+ violations.push(`${file}: \`${value}\` is not a published ${truth.provider} ${param} value or parameter`);
287
+ }
288
+ }
289
+ return violations;
290
+ }
@@ -0,0 +1,84 @@
1
+ ---
2
+ source_url: https://documenter.getpostman.com/view/6414020/2s93JwM1t4
3
+ source_type: curated
4
+ upstream_version: Postman collection "Apiclient"
5
+ crawled_at: 2026-07-31
6
+ ---
7
+
8
+ # BeSoccer API Access
9
+
10
+ BeSoccer is a Spanish football data provider. Its client API is documented as a
11
+ public Postman collection rather than an OpenAPI specification.
12
+
13
+ - **Base URL**: `https://apiclient.besoccerapps.com/scripts/api/api.php`
14
+ - **Documentation**: [Postman collection](https://documenter.getpostman.com/view/6414020/2s93JwM1t4)
15
+ - **Style**: single endpoint, resource selected by the `req` query parameter
16
+
17
+ ## Authentication
18
+
19
+ A single API key, passed as the `key` query parameter on every request:
20
+
21
+ ```
22
+ GET https://apiclient.besoccerapps.com/scripts/api/api.php?key={key}&req=competitions&format=json
23
+ ```
24
+
25
+ There is no OAuth flow, no bearer token and no login call. The key is described
26
+ as the "unique key that allows users to connect to the API", and it is a query
27
+ parameter, so it will appear in server logs and browser history — keep it out of
28
+ anything shared or committed.
29
+
30
+ ## Request shape
31
+
32
+ Every call is a `GET` to the same URL. Four parameters are common to all requests:
33
+
34
+ | Parameter | Required | Notes |
35
+ |---|---|---|
36
+ | `key` | yes | API key |
37
+ | `req` | yes | Resource selector — see [api-endpoints.md](api-endpoints.md) |
38
+ | `format` | no | `json`, `xml`, `text` or `js` |
39
+ | `tz` | no | Time zone, e.g. `Europe/Madrid` |
40
+
41
+ Everything else varies per request: `id`, `year`, `league`, `team`, `competitions`,
42
+ `players`, `lang` and others. The full per-request parameter list is in
43
+ [api-endpoints.md](api-endpoints.md).
44
+
45
+ Because the resource is a query parameter, a typo in `req` is not a 404 on a path
46
+ — it is a request to an endpoint that does not exist, and the failure will not
47
+ necessarily look like a routing error. Validate `req` against the published
48
+ vocabulary rather than guessing.
49
+
50
+ ## Access levels
51
+
52
+ Requests are grouped into three levels, which map to access tiers:
53
+
54
+ | Level | Requests | Broad content |
55
+ |---|---|---|
56
+ | Level 1 | 15 | Competitions, seasons, tables, teams, matches by day, live matches |
57
+ | Level 2 | 24 | Match detail and lineups, team detail and squads, transfers, referees, TV listings |
58
+ | Level 3 | 18 | Player detail, player statistics and trajectory, advanced team statistics, historical data |
59
+
60
+ A key not entitled to a level cannot call the requests in it. Which levels a key
61
+ carries is a commercial matter between you and BeSoccer.
62
+
63
+ ## Coverage window
64
+
65
+ BeSoccer states that the API serves **the current season plus the two previous
66
+ years**. Anything older is outside its range — plan historical work around another
67
+ source rather than expecting deep archives here.
68
+
69
+ ## Identifiers
70
+
71
+ BeSoccer uses its own integer IDs for competitions, teams, players and matches.
72
+ They are provider-scoped, with no cross-provider mapping exposed in the API, so
73
+ bridging to another provider means matching on attributes rather than looking up
74
+ an ID.
75
+
76
+ Seasons are selected with `year`, given as the starting calendar year of the
77
+ season.
78
+
79
+ ## Licensing
80
+
81
+ The API is commercial and key-gated. The Postman collection is public
82
+ documentation of the request surface; the data returned is BeSoccer's and subject
83
+ to whatever terms accompany your key. This repository documents the request
84
+ surface only and holds none of BeSoccer's data.