football-docs 0.15.0 → 0.15.1
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 +15 -4
- package/data/docs.db +0 -0
- package/dist/data-format.d.ts +5 -0
- package/dist/data-format.js +7 -0
- package/dist/index.js +1 -1
- package/dist/tools.js +47 -3
- package/docs/firstbeat/api-access.md +127 -0
- package/docs/firstbeat/api-endpoints.md +434 -0
- package/docs/firstbeat/data-model.md +325 -0
- package/docs/firstbeat/data-provenance.md +36 -0
- package/docs/firstbeat/identity-surfaces.md +57 -0
- package/docs/firstbeat/variables.md +208 -0
- package/docs/hawkin-dynamics/api-access.md +112 -0
- package/docs/hawkin-dynamics/api-endpoints.md +258 -0
- package/docs/hawkin-dynamics/data-model.md +207 -0
- package/docs/hawkin-dynamics/data-provenance.md +36 -0
- package/docs/hawkin-dynamics/identity-surfaces.md +49 -0
- package/docs/hawkin-dynamics/test-metrics.md +670 -0
- package/docs/opta/api-access.md +0 -1
- package/docs/opta/coordinate-system.md +0 -1
- package/docs/opta/event-types.md +48 -50
- package/docs/opta/qualifiers.md +3 -3
- package/docs/statsports/api-access.md +96 -0
- package/docs/statsports/api-endpoints.md +97 -0
- package/docs/statsports/data-model.md +399 -0
- package/docs/statsports/data-provenance.md +35 -0
- package/docs/statsports/drill-kpi-metrics.md +549 -0
- package/docs/statsports/identity-surfaces.md +67 -0
- package/docs/vald/api-access.md +131 -0
- package/docs/vald/api-endpoints.md +106 -0
- package/docs/vald/data-provenance.md +40 -0
- package/docs/vald/dynamo.md +566 -0
- package/docs/vald/forcedecks.md +839 -0
- package/docs/vald/forceframe.md +668 -0
- package/docs/vald/humantrak.md +286 -0
- package/docs/vald/identity-surfaces.md +67 -0
- package/docs/vald/nordbord.md +694 -0
- package/docs/vald/profiles.md +302 -0
- package/docs/vald/smartspeed.md +490 -0
- package/docs/vald/tenants.md +413 -0
- package/package.json +1 -1
- package/providers.json +116 -2
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
|
|
7
|
+
**What it does:** Gives your AI agent a searchable index of documentation for 30 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), the open-source libraries people build with (kloppy, mplsoccer, socceraction, soccerdata, floodlight, fast-forward, unravelsports, and more), and the APIs of wearable and sports-science vendors (STATSports, Firstbeat, Hawkin Dynamics, VALD). 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
|
|
|
@@ -87,7 +87,7 @@ Add to `claude_desktop_config.json`:
|
|
|
87
87
|
|
|
88
88
|
| Tool | Description |
|
|
89
89
|
|------|-------------|
|
|
90
|
-
| `search_docs` | Full-text search across all provider docs. Filter by provider. Results include provenance (source URL, version), mark partial matches,
|
|
90
|
+
| `search_docs` | Full-text search across all provider docs. Filter by provider. Results include provenance (source URL, version), mark partial matches, name query terms that no indexed doc mentions, and say when a query names a provider that is not indexed (the `not_indexed` list in `providers.json` gives the reason). |
|
|
91
91
|
| `resolve_provider_id` | Resolve provider names and aliases to canonical indexed provider keys before searching. |
|
|
92
92
|
| `get_provider_docs` | Retrieve docs for a resolved provider, optionally filtered by topic or category. |
|
|
93
93
|
| `list_providers` | List all indexed providers and their doc coverage. |
|
|
@@ -95,7 +95,7 @@ Add to `claude_desktop_config.json`:
|
|
|
95
95
|
| `request_update` | Request a new provider, flag outdated docs, or suggest a better doc source. Queues locally and points to the matching public GitHub issue template. |
|
|
96
96
|
| `resolve_entity` | Map a player, coach, referee, team, competition, season, stage or match to its IDs at every provider through the [Reep register](https://reep.football). Uses a local copy of the free register (`REEP_DUCKDB_PATH`), else the Reep API (`REEP_API_KEY`; keys are issued by hand on request to getintouch+nutmeg@withqwerty.com, with no self-service sign-up), else returns setup steps and a DuckDB query. See [Reep through football-docs](docs/reep/overview.md#using-reep-through-football-docs). |
|
|
97
97
|
|
|
98
|
-
Provider filters use the indexed provider keys shown by `list_providers`, but common aliases are accepted. Examples: `fbref`, `understat`, `ClubElo`, `football-data.co.uk`, and `engsoccerdata` search `free-sources`; `Sofascore` searches `soccerdata`; `ESPN`, `ESPN FC`, and `espn-soccer` search `espn`; `FMDB` searches `fmdb-pro`; `Transfer Room` searches `transferroom`; `Hudl Wyscout` searches `wyscout`; `Stats Perform` / `Opta F24` / `WhoScored` search `opta`; `Metrica`, `Sportec` / `DFL`, and `TRACAB` search `databallpy`; `Second Spectrum` searches `kloppy`; `Hawk-Eye`, `SciSports`, `Signality`, `Respovision`, `GradientSports` and `OptaVision` search `fast-forward`; `unravel` searches `unravelsports`; `SportRadar API` / `Soccer Extended` search `sportradar`; `The Sports DB` / `TSDB` search `thesportsdb`; `StatsBomb Open Data` searches `statsbomb`.
|
|
98
|
+
Provider filters use the indexed provider keys shown by `list_providers`, but common aliases are accepted. Examples: `fbref`, `understat`, `ClubElo`, `football-data.co.uk`, and `engsoccerdata` search `free-sources`; `Sofascore` searches `soccerdata`; `ESPN`, `ESPN FC`, and `espn-soccer` search `espn`; `FMDB` searches `fmdb-pro`; `Transfer Room` searches `transferroom`; `Hudl Wyscout` searches `wyscout`; `Stats Perform` / `Opta F24` / `WhoScored` search `opta`; `Metrica`, `Sportec` / `DFL`, and `TRACAB` search `databallpy`; `Second Spectrum` searches `kloppy`; `Hawk-Eye`, `SciSports`, `Signality`, `Respovision`, `GradientSports` and `OptaVision` search `fast-forward`; `unravel` searches `unravelsports`; `SportRadar API` / `Soccer Extended` search `sportradar`; `Sonra` / `Apex` search `statsports`; `Hawkin` searches `hawkin-dynamics`; `ForceDecks` / `NordBord` / `ForceFrame` search `vald`; `The Sports DB` / `TSDB` search `thesportsdb`; `StatsBomb Open Data` searches `statsbomb`.
|
|
99
99
|
|
|
100
100
|
## How the index stays current
|
|
101
101
|
|
|
@@ -176,8 +176,18 @@ development and tests always use the working tree's docs.
|
|
|
176
176
|
| FotMob | 5 | identity-surfaces, data-provenance |
|
|
177
177
|
| Soccerdonna | 5 | identity-surfaces, data-provenance |
|
|
178
178
|
| Transfermarkt | 5 | identity-surfaces, data-provenance |
|
|
179
|
+
| STATSports | 70 | api-access, api-endpoints, data-model, drill-kpi-metrics (all 319 DrillKpiV7 fields), identity-surfaces, data-provenance |
|
|
180
|
+
| Firstbeat | 79 | api-access, api-endpoints, data-model, variables (100 scalars, 17 time series), identity-surfaces, data-provenance |
|
|
181
|
+
| Hawkin Dynamics | 67 | api-access, api-endpoints, data-model, test-metrics (535 metrics across 13 test types), identity-surfaces, data-provenance |
|
|
182
|
+
| VALD | 318 | api-access, api-endpoints, per-product endpoints and schemas (tenants, profiles, forcedecks, nordbord, forceframe, smartspeed, dynamo, humantrak), identity-surfaces, data-provenance |
|
|
179
183
|
|
|
180
|
-
**
|
|
184
|
+
**3,394 searchable chunks** across 30 providers and tools.
|
|
185
|
+
|
|
186
|
+
STATSports, Firstbeat, Hawkin Dynamics and VALD sell wearables and testing devices.
|
|
187
|
+
Their APIs return a customer's own athlete data, which includes personal and health
|
|
188
|
+
data. The docs describe the API surface only: endpoints, field names, types and
|
|
189
|
+
units as each vendor's public spec or reference page states them. They contain no
|
|
190
|
+
athlete data, and none of these vendors' IDs join to a football data provider's IDs.
|
|
181
191
|
|
|
182
192
|
ESPN coverage consists of curated, dated observations of ESPN-hosted soccer
|
|
183
193
|
endpoints, checked for eng.1 and esp.1. These observations are not an official API
|
|
@@ -212,6 +222,7 @@ trusting them.
|
|
|
212
222
|
| Opta | Stats Perform's F24 appendices, which have no machine-readable form. `data/opta-truth.json` holds each ID the docs use, with its label, checked by hand. The test also rejects the wrong meanings earlier docs gave some IDs (`WRONG_MEANINGS` in `src/opta-truth.ts`) | `src/__tests__/opta-truth.test.ts` |
|
|
213
223
|
| SportMonks | Type and state IDs as SportMonks publishes them on its definitions pages and in the types spreadsheet linked from its Types page (`data/sportmonks-types-truth.json`, fetched 2026-09-30). Not the full list: the complete one needs an API key | `src/__tests__/sportmonks-truth.test.ts` |
|
|
214
224
|
| Reep | The public OpenAPI spec (endpoint paths and methods), and one release's manifest and column schema (CSV table list, columns used in the SQL examples, licence and exclusions) | `src/__tests__/provider-truth.test.ts`, `src/__tests__/reep.test.ts` |
|
|
225
|
+
| STATSports, Firstbeat, Hawkin Dynamics, VALD | Each vendor's public OpenAPI spec (STATSports v5 to v7, Firstbeat's `openapi.json`, the document inline on Hawkin's API reference page, VALD's eight product specs) — endpoint paths and methods, and every field name in the docs' schema tables. The STATSports `DrillKpiV7` table and the Hawkin metric tables must list the spec's and `metrics.json`'s entries in full. Firstbeat's variable list has no machine-readable source and is copied by hand from its public variables page | `src/__tests__/provider-truth.test.ts`, `src/__tests__/wearable-vendors.test.ts` |
|
|
215
226
|
|
|
216
227
|
ESPN has a separate observation check in `src/__tests__/espn.test.ts`. It validates
|
|
217
228
|
documented endpoint paths, field-table names and types, and source URLs against
|
package/data/docs.db
CHANGED
|
Binary file
|
package/dist/data-format.d.ts
CHANGED
|
@@ -48,6 +48,11 @@ export declare const providersFileSchema: z.ZodObject<{
|
|
|
48
48
|
}, z.core.$loose>>;
|
|
49
49
|
last_crawled: z.ZodNullable<z.ZodString>;
|
|
50
50
|
}, z.core.$loose>>;
|
|
51
|
+
not_indexed: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
52
|
+
display_name: z.ZodString;
|
|
53
|
+
aliases: z.ZodArray<z.ZodString>;
|
|
54
|
+
reason: z.ZodString;
|
|
55
|
+
}, z.core.$loose>>>;
|
|
51
56
|
}, z.core.$loose>;
|
|
52
57
|
export type ProvidersFile = z.infer<typeof providersFileSchema>;
|
|
53
58
|
export type ProviderRegistryEntry = z.infer<typeof providerEntrySchema>;
|
package/dist/data-format.js
CHANGED
|
@@ -65,8 +65,15 @@ const providerEntrySchema = z.looseObject({
|
|
|
65
65
|
sources: z.array(providerSourceSchema),
|
|
66
66
|
last_crawled: z.string().nullable(),
|
|
67
67
|
});
|
|
68
|
+
/** A provider that was assessed and is not indexed, with the reason. */
|
|
69
|
+
const notIndexedEntrySchema = z.looseObject({
|
|
70
|
+
display_name: z.string(),
|
|
71
|
+
aliases: z.array(z.string()),
|
|
72
|
+
reason: z.string(),
|
|
73
|
+
});
|
|
68
74
|
export const providersFileSchema = z.looseObject({
|
|
69
75
|
providers: z.record(z.string(), providerEntrySchema),
|
|
76
|
+
not_indexed: z.record(z.string(), notIndexedEntrySchema).optional(),
|
|
70
77
|
});
|
|
71
78
|
/** Compare two x.y.z versions; a pre-release suffix is ignored. */
|
|
72
79
|
export function compareVersions(a, b) {
|
package/dist/index.js
CHANGED
|
@@ -101,7 +101,7 @@ export function createFootballDocsServer() {
|
|
|
101
101
|
name: "nutmeg-football-docs",
|
|
102
102
|
version: PKG_VERSION,
|
|
103
103
|
});
|
|
104
|
-
server.tool("search_docs", "Search football data provider documentation. Use for finding event types, qualifier IDs, API endpoints, coordinate systems, data models, and cross-provider mappings. Returns the most relevant documentation chunks. Results that do not contain every query term are marked \"partial\", and the reply names any query term that no indexed doc mentions: if the question is about that term, it is not indexed.", {
|
|
104
|
+
server.tool("search_docs", "Search football data provider documentation. Use for finding event types, qualifier IDs, API endpoints, coordinate systems, data models, and cross-provider mappings. Returns the most relevant documentation chunks. Results that do not contain every query term are marked \"partial\", and the reply names any query term that no indexed doc mentions: if the question is about that term, it is not indexed. It also says when the query names a provider that is not indexed, and why.", {
|
|
105
105
|
query: z.string().describe("Search query. Examples: 'Opta goal qualifier', 'StatsBomb shot event type', 'coordinate system differences', 'xG qualifier ID', 'SportMonks fixture endpoint', 'FMDB Pro players endpoint'"),
|
|
106
106
|
provider: z
|
|
107
107
|
.string()
|
package/dist/tools.js
CHANGED
|
@@ -50,7 +50,14 @@ function buildRegistry(file) {
|
|
|
50
50
|
list.push(alias);
|
|
51
51
|
displayAliases[provider] = list;
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
const notIndexed = {};
|
|
54
|
+
for (const [key, entry] of Object.entries(file.not_indexed ?? {})) {
|
|
55
|
+
const value = { displayName: entry.display_name, reason: entry.reason };
|
|
56
|
+
for (const name of [key, entry.display_name, ...entry.aliases]) {
|
|
57
|
+
notIndexed[slugProvider(name)] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { providers: file.providers, aliases, displayAliases, notIndexed };
|
|
54
61
|
}
|
|
55
62
|
let packagedRegistry;
|
|
56
63
|
const registryCache = new Map();
|
|
@@ -175,10 +182,44 @@ function providerSuggestions(registry, provider, providerSet) {
|
|
|
175
182
|
.slice(0, 3);
|
|
176
183
|
}
|
|
177
184
|
function unknownProviderMessage(registry, original, provider, providerSet) {
|
|
185
|
+
const assessed = registry.notIndexed[slugProvider(original)];
|
|
186
|
+
if (assessed) {
|
|
187
|
+
return `Provider "${original.trim()}" is not indexed: ${assessed.reason} Call list_providers for the providers that are.`;
|
|
188
|
+
}
|
|
178
189
|
const suggestions = providerSuggestions(registry, provider, providerSet);
|
|
179
190
|
const suggestionText = suggestions.length ? ` Did you mean: ${suggestions.join(", ")}?` : "";
|
|
180
191
|
return `Provider "${providerFilterLabel(original, provider)}" is not indexed.${suggestionText} Call list_providers for available provider keys, or use request_update to suggest adding it.`;
|
|
181
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Providers a query names that have no indexed docs: ones assessed and left
|
|
195
|
+
* out (providers.json not_indexed), and registered ones not indexed yet. A
|
|
196
|
+
* query for "Catapult PlayerLoad" otherwise gets Impect chunks, because the
|
|
197
|
+
* Impect docs mention that Catapult owns it, with nothing to say Catapult's own
|
|
198
|
+
* data is not covered. Single words and adjacent pairs are checked, so
|
|
199
|
+
* "Kitman Labs" matches as well as "kitman".
|
|
200
|
+
*/
|
|
201
|
+
function unindexedProviderNote(db, registry, query) {
|
|
202
|
+
const words = query.match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
203
|
+
const candidates = [...words, ...words.slice(1).map((word, index) => `${words[index]} ${word}`)];
|
|
204
|
+
const indexed = indexedProviders(db);
|
|
205
|
+
const notes = new Map();
|
|
206
|
+
for (const candidate of candidates) {
|
|
207
|
+
const slug = slugProvider(candidate);
|
|
208
|
+
const assessed = registry.notIndexed[slug];
|
|
209
|
+
if (assessed) {
|
|
210
|
+
notes.set(assessed.displayName, `${assessed.displayName} is not an indexed provider: ${assessed.reason}`);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
const provider = registry.aliases[slug];
|
|
214
|
+
if (provider && !indexed.has(provider)) {
|
|
215
|
+
const name = registry.providers[provider]?.display_name ?? provider;
|
|
216
|
+
notes.set(name, `${name} is registered but has no indexed docs yet.`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (notes.size === 0)
|
|
220
|
+
return "";
|
|
221
|
+
return `${[...notes.values()].join(" ")} Results below come from other providers and do not cover it.\n\n`;
|
|
222
|
+
}
|
|
182
223
|
function requestProviderKey(provider) {
|
|
183
224
|
return slugProvider(provider).replace(/-/g, "");
|
|
184
225
|
}
|
|
@@ -465,8 +506,11 @@ export function searchDocs(db, args) {
|
|
|
465
506
|
// for missing terms when it did not.
|
|
466
507
|
const missingTerms = strictRows.length === 0 ? unindexedTerms(db, args.query, provider) : [];
|
|
467
508
|
const providerLabel = providerFilterLabel(args.provider, provider);
|
|
509
|
+
// A provider filter already answers "is it indexed", so only check the
|
|
510
|
+
// query text when there is none.
|
|
511
|
+
const providerNote = provider ? "" : unindexedProviderNote(db, registry, args.query);
|
|
468
512
|
if (rows.length === 0) {
|
|
469
|
-
return textResult(
|
|
513
|
+
return textResult(`${providerNote}No results found for "${args.query}"${providerLabel ? ` in ${providerLabel}` : ""}.${unindexedTermsNote(missingTerms)} Try broader football-data terms, remove the provider filter, or call list_providers to inspect coverage.`);
|
|
470
514
|
}
|
|
471
515
|
const results = rows
|
|
472
516
|
.map((row, index) => {
|
|
@@ -474,7 +518,7 @@ export function searchDocs(db, args) {
|
|
|
474
518
|
return `## [${index + 1}] ${row.title}\n**Provider:** ${row.provider} | **Category:** ${row.category} | ${sourceLabel(row)}${match}\n\n${row.content}`;
|
|
475
519
|
})
|
|
476
520
|
.join("\n\n---\n\n");
|
|
477
|
-
return textResult(`Found ${rows.length} result(s) for "${args.query}"${providerLabel ? ` in ${providerLabel}` : ""}:\n\n${partialMatchNote(strictRows.length, rows.length, missingTerms)}${results}`);
|
|
521
|
+
return textResult(`Found ${rows.length} result(s) for "${args.query}"${providerLabel ? ` in ${providerLabel}` : ""}:\n\n${providerNote}${partialMatchNote(strictRows.length, rows.length, missingTerms)}${results}`);
|
|
478
522
|
}
|
|
479
523
|
function dataLine(db, source) {
|
|
480
524
|
const stamp = dataStampValue(db);
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
source_type: curated
|
|
3
|
+
source_url: https://apidocs.firstbeat.com/getting-started/
|
|
4
|
+
upstream_version: Firstbeat Cloud API 1.1.0 (OpenAPI 3.0.1)
|
|
5
|
+
crawled_at: 2026-09-30
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Firstbeat API Access
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Firstbeat Sports records athletes' heart rate and movement with its own sensors and
|
|
13
|
+
analyses the data in Sports Cloud. The Firstbeat Sports Cloud API returns that
|
|
14
|
+
analysis for the customer accounts an API consumer may access.
|
|
15
|
+
|
|
16
|
+
- Documentation: https://apidocs.firstbeat.com/
|
|
17
|
+
- OpenAPI spec (3.0.1, `info.version` "1.1.0"):
|
|
18
|
+
https://apidocs.firstbeat.com/assets/api-specification/openapi.json
|
|
19
|
+
- Local snapshot: `specs/firstbeat/openapi.json`
|
|
20
|
+
- Base URL (the spec's server): `https://api.firstbeat.com/v1`
|
|
21
|
+
- Variable list: https://apidocs.firstbeat.com/variables/ (see Firstbeat variables)
|
|
22
|
+
- API support contact in the spec: sports-cloud-api@firstbeat.com
|
|
23
|
+
|
|
24
|
+
## Who can use the API
|
|
25
|
+
|
|
26
|
+
From the documentation home page, checked 2026-09-30:
|
|
27
|
+
|
|
28
|
+
| Subscription level | What the page says you get |
|
|
29
|
+
|---|---|
|
|
30
|
+
| Standard | "No API access by default. A feature purchase adds the ability to connect through an existing API Partner system (e.g. gpexe, Teamworks), not a standalone API client of your own." |
|
|
31
|
+
| Premium | "Connect through an existing API Partner system, included in your subscription, no separate purchase needed." |
|
|
32
|
+
| Premium+ | "Full access: build and use your own API client, in addition to API Partner connections." |
|
|
33
|
+
|
|
34
|
+
The page names these API partners as examples: gpexe, XPS Network, Kinexon, Kitman
|
|
35
|
+
Lab, Apollo V2, Teamworks and SAP Sports One. It asks AMS vendors and other
|
|
36
|
+
collaborators to contact sports@firstbeat.com.
|
|
37
|
+
|
|
38
|
+
## Registration steps
|
|
39
|
+
|
|
40
|
+
The "Getting Started" page lists five steps:
|
|
41
|
+
|
|
42
|
+
1. Register: `POST /account/register` with a JSON body `{"consumerName": "..."}`
|
|
43
|
+
(2 to 100 characters). It needs no authentication. The response holds `id`,
|
|
44
|
+
`consumerName` and `sharedSecret`. The page says each call creates a new API
|
|
45
|
+
consumer, even with the same name, and the name cannot be changed later.
|
|
46
|
+
2. Get approval: email sports-cloud-api@firstbeat.com with the `consumerName`, the
|
|
47
|
+
`id`, the customer account names to link and contact people. Firstbeat approves
|
|
48
|
+
the consumer and links it to those accounts.
|
|
49
|
+
3. Grant access: a Coach on the customer account opens Sports Cloud settings, then
|
|
50
|
+
"Cloud API", accepts the licence agreement, selects the API consumer and ticks
|
|
51
|
+
the account. The page says only Coaches can grant or revoke API access.
|
|
52
|
+
4. Authenticate: create a JWT and get an API key (below).
|
|
53
|
+
5. Test: `GET /sports/accounts` lists the accounts the consumer can read.
|
|
54
|
+
|
|
55
|
+
## Authentication
|
|
56
|
+
|
|
57
|
+
- JWT: sign with HS256 using the `sharedSecret`. The payload is `iss` (the consumer
|
|
58
|
+
`id`), `iat` and `exp`. The page says "Tokens must be valid for a maximum of 5
|
|
59
|
+
minutes." Send it as `Authorization: Bearer <token>`.
|
|
60
|
+
- API key: `GET /account/api-key` with the JWT returns the key. The page says the key
|
|
61
|
+
is generated once and stays the same on later calls. Send it as `x-api-key`.
|
|
62
|
+
- Which endpoints need what, from the page: `/account/register` needs no
|
|
63
|
+
authentication; `/account/api-key` needs the JWT only; every other endpoint needs
|
|
64
|
+
both the `Authorization` header and the `x-api-key` header.
|
|
65
|
+
- Secret rotation: `GET /account/new-secret` returns a new `sharedSecret`, and
|
|
66
|
+
`POST /account/new-secret/confirm`, called with a JWT signed by the new secret,
|
|
67
|
+
confirms it and invalidates the old one.
|
|
68
|
+
- The spec itself declares no `securitySchemes`; it lists `Authorization` and
|
|
69
|
+
`x-api-key` as required header parameters on each operation.
|
|
70
|
+
|
|
71
|
+
Keep the `sharedSecret` and API key out of code, for example in
|
|
72
|
+
`FIRSTBEAT_SHARED_SECRET` and `FIRSTBEAT_API_KEY`.
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
import os, time, jwt, requests
|
|
76
|
+
|
|
77
|
+
consumer_id = os.environ["FIRSTBEAT_CONSUMER_ID"]
|
|
78
|
+
now = int(time.time())
|
|
79
|
+
token = jwt.encode({"iss": consumer_id, "iat": now, "exp": now + 300},
|
|
80
|
+
os.environ["FIRSTBEAT_SHARED_SECRET"], algorithm="HS256")
|
|
81
|
+
accounts = requests.get(
|
|
82
|
+
"https://api.firstbeat.com/v1/sports/accounts",
|
|
83
|
+
headers={"Authorization": f"Bearer {token}", "x-api-key": os.environ["FIRSTBEAT_API_KEY"]},
|
|
84
|
+
).json()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Usage limits
|
|
88
|
+
|
|
89
|
+
From the "Usage Limits" page (https://apidocs.firstbeat.com/usage-limits/), checked
|
|
90
|
+
2026-09-30. Limits apply per API consumer, and accounts linked to one consumer share
|
|
91
|
+
them.
|
|
92
|
+
|
|
93
|
+
| Usage limit | Value | Description on the page |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| Rate limit | 1 requests per second | Token bucket refilling at 1 token/sec |
|
|
96
|
+
| Burst | 60 requests / minute | Token bucket with 60 token capacity |
|
|
97
|
+
| Daily quota | 5000 requests / day | Fixed window that resets every day at 00:00:00 (midnight) UTC |
|
|
98
|
+
|
|
99
|
+
When a limit is exceeded the API returns HTTP `429`, with an `x-amzn-ErrorType`
|
|
100
|
+
header:
|
|
101
|
+
|
|
102
|
+
| Header value | Cause |
|
|
103
|
+
|---|---|
|
|
104
|
+
| `LimitExceededException` | Daily quota exceeded |
|
|
105
|
+
| `ThrottledException` | Per-minute rate limit exceeded |
|
|
106
|
+
|
|
107
|
+
The page says the API gives no way to read the remaining quota, and returns no
|
|
108
|
+
remaining-quota header. Limits can be changed on request.
|
|
109
|
+
|
|
110
|
+
## Asynchronous results and payload size
|
|
111
|
+
|
|
112
|
+
The four `/results` endpoints can return:
|
|
113
|
+
|
|
114
|
+
- `202`: "Accepted. Analysis job is in progress. You should wait 5 seconds and then
|
|
115
|
+
run the same request again."
|
|
116
|
+
- `204`: "No Content. Analysis job has failed."
|
|
117
|
+
- `413`: "Response Too Large".
|
|
118
|
+
|
|
119
|
+
The "Querying the API" page says `format=list` decodes time series on the server,
|
|
120
|
+
and recommends client-side decoding "to save bandwidth and avoid possible problems of
|
|
121
|
+
hitting the max 6MB response payload size".
|
|
122
|
+
|
|
123
|
+
## Terms
|
|
124
|
+
|
|
125
|
+
The documentation site footer reads "© 2026 Firstbeat Technologies". No licence
|
|
126
|
+
for reusing the documentation was found. The data licence is the agreement a Coach
|
|
127
|
+
accepts in Sports Cloud (registration step 3); its text is not public.
|