Identifiers nomenclature is changing at Sportradar, and this is highly relevant for users of Sportradar widgets.
Widgets follow old nomenclature, the tournament related properties are named tournamentId and uniqueTournamentId, but most backend data sources mentioned in this document already follow new nomenclature, where these two identifiers are respectively named simpleTournamentId and tournamentId
This means that if you get tournamentId from e.g. Coverage feed, you must pass it to a widget as uniqueTournamentId, and if you read simpleTournamentId from the same source, you pass it to a widget as tournamentId.
| property from API source | property passed to widgets |
|---|---|
simpleTournamentId | tournamentId |
tournamentId | uniqueTournamentId |
Below is a code example showing a hypothetical fetching of tourname properties from an API and passing them to the widget loading SIR() function.
// Browser example: call a REST endpoint, display results,
// then map tournamentId/simpleTournamentId for SIR().
async function loadTournamentData() {
const endpoint = "https://example-api.sportradar.com/tournament"; // this is a bogus exmaple endpoint
// Equivalent curl command for reference:
// curl -s "https://example-api.sportradar.com/tournament"
const response = await fetch(endpoint, {
method: "GET",
headers: {
Accept: "application/json",
},
});
if (!response.ok) {
throw new Error(`Request failed with status ${response.status}`);
}
const result = await response.json();
console.log("REST result:", result);
const { tournamentId, simpleTournamentId } = result;
if (!tournamentId || !simpleTournamentId) {
throw new Error("Response must contain tournamentId and simpleTournamentId");
}
// Here you map the new nomenclature properties from APIs to the old nomenclature properties in widgets
const sirPayload = {
uniqueTournamentId: tournamentId, // from tournamentId
tournamentId: simpleTournamentId, // from simpleTournamentId
};
SIR('addWidget', '#sr-widget', 'season.fixtures', sirPayload);
}
// Example SIR implementation placeholder:
function SIR(payload) {
console.log("Calling SIR with:", payload);
}
loadTournamentData().catch((error) => {
console.error("Failed to load tournament data:", error);
});