- Which sports APIs are suitable for tracking match dynamics in real time
- Which match events should be considered a sharp change in dynamics for setting up notifications
- How to set up triggers for score changes and key events using a sports API
- How to receive notifications about sharp changes in match dynamics via API webhooks
- How to process data from a sports API and send push notifications to the user
- Limitations, delays, and limits of sports APIs when working with live notifications
Which sports APIs are suitable for tracking match dynamics in real time
To respond promptly to sharp changes in the course of the game, it is not enough to just know the current score. A sports API is needed that provides not only the basic result in real time but also a stream of live events, detailed statistics, and dynamics of bookmaker odds. This approach allows for building intelligent notifications for betting services, media projects, analytical platforms, and mobile applications.
Key requirements for such an API: support for multiple sports, a unified data structure, stable update speed, and the presence of specialized fields for analyzing dynamics. por el API de eventos deportivos api-sport.ru All major sports (football, hockey, basketball, tennis, table tennis, esports, and others) use a common match model. For live games, the fields are available minutoDelPartidoActual (current minute), array eventosEnVivo (goals, cards, penalties, VAR decisions, etc.), array estadísticasDelPartido (shots, possession, dangerous moments, and others) and block oddsBase with current bookmaker odds. All this forms the complete context of the match and provides a basis for the triggers of «sharp changes in dynamics.».
Technically, access to the data is implemented through REST endpoints of the type /v2/{sportSlug}/partidos и /v2/{sportSlug}/matches/{matchId} with filters by match status, tournament, date, and teams. This allows requesting only the ongoing games at the moment and saving limits. In upcoming releases, the API will be supplemented with WebSocket connections and AI modules, which will simplify the construction of streaming notification systems and intelligent dynamics analysis without complex logic on the developer’s side.
Example: obtaining a list of live matches to track dynamics
[prompt]Below is an example of a request in JavaScript that retrieves all current football matches and outputs the score and current minute — based on this data, triggers for dynamics analysis can be launched.[/prompt]
const API_KEY = 'YOUR_API_KEY';
async function getLiveFootballMatches() {
const url = 'https://api.api-sport.ru/v2/football/matches?status=inprogress';
const res = await fetch(url, {
headers: {
Authorization: API_KEY,
},
});
const data = await res.json();
data.matches.forEach(match => {
const home = match.homeTeam.name;
const away = match.awayTeam.name;
const score = `${match.homeScore.current}:${match.awayScore.current}`;
const minute = match.currentMatchMinute;
console.log(`${home} vs ${away} — ${score}, ${minute}-я минута`);
});
}
getLiveFootballMatches().catch(console.error);
Which match events should be considered a sharp change in dynamics for setting up notifications
A «sharp change in match dynamics» usually refers to a segment of the game when the balance of power or the probability of the outcome changes sharply. In terms of the sports API, this can be a series of important events in the array eventosEnVivo, a spike in indicators in estadísticasDelPartido or a sharp movement of odds in the block oddsBase. For example, a scored goal, a red card, a awarded penalty, several dangerous shots in a row, or a sudden drop in the underdog’s winning odds — all of these are typical reasons for a trigger notification.
В eventosEnVivo each event stores the type (type: goal, tarjeta, inGamePenalty, varDecision, substitution and others), the team (equipo: home/away), the score after the event (puntajeLocal, puntajeVisitante) and the minute. For football, a sharp change in dynamics can be considered a goal at the end, a quick reduction of the deficit, a red card, or a series of penalties. In the match statistics (block estadísticasDelPartido) it is useful to track the growth of metrics such as Total shots, Shots on target, Big chances, Touches in penalty area and similar indicators of attacking activity. And in oddsBase bookmaker analysis, the fields are important decimal, initialDecimal и cambiar, that show how quickly the odds move on different outcomes.
In practice, it is better to pre-formulate a set of «game-changing scenarios» for each sport and type of product. A media service may only need notifications about goals and red cards. A betting application is more concerned with the sequence of dangerous attacks and abnormal movements of bookmaker lines. An analytical platform will require combined signals: for example, if within 5 minutes a team made several shots on target, increased possession, and at the same time the odds on their victory decreased. All this is possible due to the detailed data structure provided by the sports events API.
Example: selection of key events from the match timeline
[prompt]Below is an example of a request that retrieves events from a specific football match and selects only those that can be considered a sharp change in dynamics: goals, cards, and penalties.[/prompt]
const API_KEY = 'YOUR_API_KEY';
const matchId = 14570728; // пример ID матча
async function getCriticalEvents() {
const url = `https://api.api-sport.ru/v2/football/matches/${matchId}/events`;
const res = await fetch(url, {
headers: {
Authorization: API_KEY,
},
});
const data = await res.json();
const criticalTypes = ['goal', 'card', 'inGamePenalty', 'varDecision'];
const criticalEvents = data.events.filter(ev =>
criticalTypes.includes(ev.type)
);
console.log(criticalEvents);
}
getCriticalEvents().catch(console.error);
How to set up triggers for score changes and key events using a sports API
The basis of any notification system is correctly configured triggers. In the context of a sports API, a trigger can be a single event (goal, red card, awarded penalty) or a complex combination of several conditions. For this, you need to regularly receive complete match data via the endpoint /v2/{sportSlug}/matches/{matchId}, compare it with the previous state, and record the moment of sharp change in dynamics.
The most obvious trigger is a change in score. The match object has fields homeScore.current и awayScore.current, and in eventosEnVivo there is a detailed timeline of goals scored. However, in advanced scenarios, it is worth considering not only the fact of the goal itself but also the context: red cards (type: card with the corresponding class), penalties (type: inGamePenalty), VAR decisions (type: varDecision) and even sharp fluctuations in odds in oddsBase. For example, if the odds on a team’s victory sharply decreased simultaneously with an increase in attacking statistics, this is a clear signal for user notification.
Triggers can be configured at the business level: some projects react only to score changes, others track «goal threats» based on statistics, and others focus on bookmaker line movements. In the future, with the emergence of AI modules on the API side, such rules can be supplemented with a model that automatically determines the «turning point» based on a combination of parameters. Even now, you can implement a flexible config: store thresholds and conditions in a database and apply them to each match in your backend.
Example: a simple trigger for score change and goal in liveEvents
[prompt]Below is an example of a JavaScript function that requests match details, compares the score with the previous state, and returns a flag for the trigger firing, as well as the last goal event. ev.type === ‘goal’)
.sort((a, b) => a.time – b.time)
.pop() || null;
const triggerFired = scoreChanged || !!lastGoal;
return {
triggerFired,
currentScore,
lastGoal,
};
}
[/code]
How to receive notifications about sharp changes in match dynamics via API webhooks
The classic scheme for working with sports data involves periodic polling of the API from your server. However, for end systems — mobile applications, partner services, CRM — it is much more convenient to receive events via a webhook model, that is, in the form of incoming HTTP requests. In the case of api-sport.ru, the logic looks like this: your backend calls the sports API, analyzes the received data, determines the fact of a sharp change in dynamics, and sends POST requests to the pre-configured URLs of your clients or internal services.
To implement such a scheme, you will need a background worker or a cron job that polls the endpoints at the required frequency. /v2/{sportSlug}/partidos и /v2/{sportSlug}/matches/{matchId}, It stores the previous state and compares it with the current one. As soon as a trigger is activated (the score changed, a goal appeared in eventosEnVivo, the odds changed sharply in oddsBase or attack statistics), the server forms a compact JSON package with key fields (match ID, score, minute, event type, required odds) and sends it to the registered webhook addresses. In the near future, the emergence of a WebSocket interface will simplify this task: you will be able to subscribe to a stream of live updates and use webhooks only as an external delivery channel.
It is important to think through the format of the webhook payload: it should be stable, versioned, and not carry unnecessary fields. Usually, it is enough to transmit the match identifier, sport type, current score, minute, type of key event, and several aggregated indicators (for example, how many goals were scored in the last N minutes, how much the odds for the main outcome changed). You determine the specific rules and polling frequency yourself, based on the tariff limits and SLA of your service.
Example: sending a webhook when a trigger is activated
[prompt]Below is a simple example of a function that receives a dynamics event object and sends it to the webhook URL of a third-party service.[/prompt]
async function sendWebhook(webhookUrl, payload) {
await fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
}
// Пример полезной нагрузки вебхука
const examplePayload = {
sport: 'football',
matchId: 14570728,
minute: 78,
homeTeam: 'Home FC',
awayTeam: 'Away FC',
score: {
home: 2,
away: 1,
},
type: 'goal',
description: 'Гол хозяев, счёт стал 2:1',
};
sendWebhook('https://partner-service.com/webhooks/match-dynamics', examplePayload)
.catch(console.error);
How to process data from a sports API and send push notifications to the user
After your server has learned to capture sharp changes in match dynamics and generate webhooks, the next step is delivering events to the end user. Usually, this involves a combination: a backend that works with the sports events API, a message queue, and one or more channels for delivering push notifications (mobile push services, web push, internal notification system of the site or application). It is important not only to technically send the push but also to form a user-friendly message based on the match data.
The process looks like this: the worker polls the API, applies triggers, and saves the «triggered» events in storage. Then a separate module takes these events, matches them with user subscriptions (for example, who follows specific teams, tournaments, or types of events), generates the notification text, and sends it through the chosen channel. An API key is used for authorization in the sports API, which can be obtained at the developer’s personal account, and the requests are made to the endpoints /v2/{sportSlug}/partidos и /v2/{sportSlug}/matches/{matchId}. Based on the fields homeTeam, awayTeam, puntajeLocal, puntajeVisitante, minutoDelPartidoActual and the last event from eventosEnVivo it is possible to automatically generate personalized text.
Special attention should be paid to anti-spam measures and event grouping. If a team scores two goals and receives a red card within a couple of minutes, there is no point in sending three separate push notifications. It is better to record all changes, combine them into one message, and send the user a brief but informative digest. In the future, AI modules will allow for automatic prioritization of events and selection of the optimal format for presenting information to different audience segments.
Example: generating push notification text based on match data
[prompt] Below is an example of a function that takes a match object and the last key event as input and outputs a ready string for the push notification.
Limitations, delays, and limits of sports APIs when working with live notifications
Any live notification system on top of the sports API must consider technical limitations: network delays, data refresh rates on the provider’s side, request limits, and possible load peaks during top matches. Even with very fast data delivery, there is always a small delta between the actual moment of the event on the field and its appearance in the API. Typically, it is measured in seconds and depends on the partners’ infrastructure, so the trigger system should be designed with a margin and avoid excessively aggressive polling.
To optimize requests, it is important to use filters available in the endpoint /v2/{sportSlug}/partidos: match status (status=inprogress), list of interested tournaments (torneo_id with multiple IDs), date, teams, and categories. This allows requesting only the truly needed live games and not wasting limits on completed or not yet started matches. When designing the architecture, it is advisable to consider caching, exponential backoff in case of network errors or responses indicating limit exceedance, as well as transitioning to WebSocket streaming as it becomes available to reduce the number of HTTP requests.
Specific limit values for tariffs, SLA, and API usage policies should be clarified in the current documentation and contracts. For your part, you can additionally smooth the load: separate polling by sports and tournaments, group several checks into one request, set different update frequencies for high and low priority matches. For example, a top league derby can be polled more frequently than games in lower divisions. Detailed recommendations on working with limits and examples of requests are provided in the documentation on the official website. api-sport.ru.
Example: request only the needed live matches with sampling limit.
[prompt]Below is an example of a request that retrieves only the currently ongoing matches of the selected tournaments, which helps save limits and speed up processing. console.log(‘Live matches received:’, matches.length))
.catch(console.error);
[/code]




