SofaScore Sport API - Complete Tutorial
Table of Contents
- Introduction
- Getting Started
- Authentication
- API Reference
- Common Workflows
- Response Examples
- Reference Tables
- FAQ
Introduction
Sport API provides comprehensive sports data, from simple live scores to deep statistics and detailed player analysis. The API covers 20+ sports, more than 5000 leagues, tournaments and special events.
Supported Sports
Football (Soccer), Tennis, Basketball, Ice Hockey, Handball, Volleyball, Table Tennis, Baseball, American Football, MMA, Motorsport, Cricket, Rugby, Darts, Snooker, Futsal, Badminton, Aussie Rules, Beach Volleyball, Waterpolo, Cycling, Floorball, Bandy, Esports.
Data Similar To
- Opta Sports (statsperform.com)
- SofaScore.com
- AIScore.com
Support
- Email: tipsters@rapi.one
- Telegram: https://t.me/api_tipsters
- Other Sport APIs: https://rapi.one/sports/
Getting Started
Base URL
https://sofasport.p.rapidapi.comor
https://sofascores-api.hgapi.topAPI Reference
Sports
GET Sport List
Get a list of all available sports.
| Method | Endpoint |
|---|---|
| GET | /v1/sports |
Response:
{
"data": [
{"name": "Football", "slug": "football", "id": 1},
{"name": "Basketball", "slug": "basketball", "id": 2},
{"name": "Ice Hockey", "slug": "ice-hockey", "id": 4},
{"name": "Tennis", "slug": "tennis", "id": 5}
// ... more sports
]
}GET Number of Live Events
Get the number of live events across all sports.
| Method | Endpoint |
|---|---|
| GET | /v1/sports/number-live |
Parameters: None
Categories
GET Categories List
Get a list of categories (countries/regions) by sport.
| Method | Endpoint |
|---|---|
| GET | /v1/categories |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| sport_id | integer | Yes | Sport ID | 1 |
GET Categories Number Live
Get the number of live events in each category by sport.
| Method | Endpoint |
|---|---|
| GET | /v1/categories/number-live |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| sport_id | integer | Yes | Sport ID | 1 |
Calendar
GET Actual Categories
Get actual categories by date and sport (categories with events on a specific date).
| Method | Endpoint |
|---|---|
| GET | /v1/calendar/categories |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| sport_id | integer | Yes | Sport ID | 1 |
| date | string | Yes | Date (YYYY-MM-DD) | 2022-05-06 |
| timezone | integer | Yes | Timezone offset (-11 to 13) | 6 |
GET Daily Unique Tournaments
Get daily unique tournaments by month and sport.
| Method | Endpoint |
|---|---|
| GET | /v1/calendar/daily-unique-tournaments |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| sport_id | integer | Yes | Sport ID | 1 |
| month | string | Yes | Month (YYYY-MM) | 2022-05 |
| timezone | integer | Yes | Timezone offset (-11 to 13) | 6 |
Tournaments
GET Unique Tournaments List
Get a list of unique tournaments by category.
| Method | Endpoint |
|---|---|
| GET | /v1/unique-tournaments |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| category_id | integer | Yes | Category ID | 20 |
GET Unique Tournaments Top
Get top tournaments list.
| Method | Endpoint |
|---|---|
| GET | /v1/unique-tournaments-top |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| locale | string | Yes | Locale code | en |
GET Unique Tournament Data
Get detailed data about a unique tournament.
| Method | Endpoint |
|---|---|
| GET | /v1/unique-tournaments/data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
GET Unique Tournament Seasons
Get all seasons of a unique tournament.
| Method | Endpoint |
|---|---|
| GET | /v1/unique-tournaments/seasons |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
GET Unique Tournament Featured Events
Get featured events of a unique tournament.
| Method | Endpoint |
|---|---|
| GET | /v1/unique-tournaments/featured-events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
GET Unique Tournament Media
Get media content of a unique tournament.
| Method | Endpoint |
|---|---|
| GET | /v1/unique-tournaments/media |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
GET Unique Tournament Logo
Get tournament logo.
| Method | Endpoint |
|---|---|
| GET | /v1/unique-tournaments/logo |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| sport_id | integer | No | Sport ID | 1 |
GET Tournament Data
Get tournament data by tournament ID.
| Method | Endpoint |
|---|---|
| GET | /v1/tournaments/data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| tournament_id | integer | Yes | Tournament ID | 1 |
GET Tournament Seasons
Get seasons of a tournament.
| Method | Endpoint |
|---|---|
| GET | /v1/tournaments/seasons |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| tournament_id | integer | Yes | Tournament ID | 1 |
GET Tournament Events
Get events of a tournament.
| Method | Endpoint |
|---|---|
| GET | /v1/tournaments/events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| tournament_id | integer | Yes | Tournament ID | 95741 |
| page | integer | Yes | Page number (0-indexed) | 0 |
| course_events | string | Yes | Event course type | last |
Seasons
GET Season Data
Get detailed data about a season.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| seasons_id | integer | Yes | Season ID | 37036 |
GET Season Details
Get season statistics summary (goals, wins, etc.).
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/details |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| seasons_id | integer | Yes | Season ID | 37036 |
GET Season Standings
Get league standings/table.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/standings |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| seasons_id | integer | Yes | Season ID | 37036 |
| unique_tournament_id | integer | No | Unique Tournament ID | 17 |
| tournament_id | integer | No | Tournament ID | - |
| standing_type | string | Yes | Type of standings | total |
Standing Types: total, home, away
GET Season Cup Trees
Get cup/knockout tournament bracket.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/cup-trees |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 7 |
| seasons_id | integer | Yes | Season ID | 36886 |
GET Season Rounds
Get all rounds of a season.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/rounds |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 7 |
| seasons_id | integer | Yes | Season ID | 52561 |
GET Season Events
Get all events of a season.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| seasons_id | integer | Yes | Season ID | 37036 |
| page | integer | Yes | Page number (0-indexed) | 0 |
| course_events | string | Yes | Event course type | last |
GET Season Team Events
Get team events of a season.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/team-events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| seasons_id | integer | Yes | Season ID | 37036 |
GET Season Players Statistics
Get player statistics for a season.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/players-statistics/result |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| seasons_id | integer | Yes | Season ID | 37036 |
| seasons_statistics_type | string | Yes | Statistics type | overall |
Statistics Types: overall, home, away
GET Season Teams Statistics
Get team statistics for a season.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/teams-statistics/result |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| seasons_id | integer | Yes | Season ID | 37036 |
| seasons_statistics_type | string | Yes | Statistics type | overall |
GET Season Team Week Rounds
Get team of the week rounds.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/team-week/rounds |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| seasons_id | integer | Yes | Season ID | 37036 |
GET Season Team Week Players
Get team of the week players for a specific round.
| Method | Endpoint |
|---|---|
| GET | /v1/seasons/team-week/result |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| seasons_id | integer | Yes | Season ID | 37036 |
| round_id | integer | Yes | Round ID | 7177 |
Events
GET Event Data
Get complete event/match data.
| Method | Endpoint |
|---|---|
| GET | /v1/events/data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 11930405 |
GET Schedule by Category
Get event schedule by category and date.
| Method | Endpoint |
|---|---|
| GET | /v1/events/schedule/category |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| category_id | integer | Yes | Category ID | 26 |
| date | string | Yes | Date (YYYY-MM-DD) | 2022-05-11 |
GET Schedule by Date
Get event schedule by sport and date (±12 hours for all timezones).
| Method | Endpoint |
|---|---|
| GET | /v1/events/schedule/date |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| sport_id | integer | Yes | Sport ID | 1 |
| date | string | Yes | Date (YYYY-MM-DD) | 2024-02-29 |
| inverse | boolean | No | Inverse order | false |
Note: This endpoint is deprecated. Use Schedule by Category instead.
GET Live Schedule
Get all live events by sport.
| Method | Endpoint |
|---|---|
| GET | /v1/events/schedule/live |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| sport_id | integer | Yes | Sport ID | 1 |
GET Popular Events
Get today's popular events.
| Method | Endpoint |
|---|---|
| GET | /v1/events/schedule/popular |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| locale | string | Yes | Locale code | en |
GET Event Statistics
Get match statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/events/statistics |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 11930405 |
GET Event Lineups
Get team lineups.
| Method | Endpoint |
|---|---|
| GET | /v1/events/lineups |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 11930405 |
GET Event Incidents
Get match incidents (goals, cards, substitutions).
| Method | Endpoint |
|---|---|
| GET | /v1/events/incidents |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 11930405 |
GET Event H2H Stats
Get head-to-head statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/events/h2h-stats |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
GET Event H2H Events
Get head-to-head events history.
| Method | Endpoint |
|---|---|
| GET | /v1/events/h2h-events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | No | Event ID | 11930405 |
| custom_event_id | string | No | Custom Event ID | pcWcsWDfd |
GET Event Heatmap
Get team heatmap during the match.
| Method | Endpoint |
|---|---|
| GET | /v1/events/heatmap |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
| team_id | integer | Yes | Team ID | 2819 |
GET Event Player Heatmap
Get individual player heatmap.
| Method | Endpoint |
|---|---|
| GET | /v1/events/player-heatmap |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10023294 |
| player_id | integer | Yes | Player ID | 839410 |
GET Event Player Statistics
Get individual player statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/events/player-statistics |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10023294 |
| player_id | integer | Yes | Player ID | 839410 |
GET Event Best Players
Get best players of the match.
| Method | Endpoint |
|---|---|
| GET | /v1/events/best-players |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
GET Event Form
Get pregame team form.
| Method | Endpoint |
|---|---|
| GET | /v1/events/form |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10236820 |
GET Event Streaks
Get team streaks.
| Method | Endpoint |
|---|---|
| GET | /v1/events/streaks |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 9576298 |
GET Event Predict
Get match prediction.
| Method | Endpoint |
|---|---|
| GET | /v1/events/predict |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
GET Event Media
Get media content (videos, highlights).
| Method | Endpoint |
|---|---|
| GET | /v1/events/media |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
GET Event Tweets
Get related tweets.
| Method | Endpoint |
|---|---|
| GET | /v1/events/tweets |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
GET Event Comments
Get user comments.
| Method | Endpoint |
|---|---|
| GET | /v1/events/comments |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10230638 |
GET Event Graph Points
Get graph points data.
| Method | Endpoint |
|---|---|
| GET | /v1/events/graph-points |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
GET Event Shotmap
Get shotmap data.
| Method | Endpoint |
|---|---|
| GET | /v1/events/shotmap |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10230638 |
GET Event Fan Rating
Get fan ratings.
| Method | Endpoint |
|---|---|
| GET | /v1/events/fan-rating |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
GET Event Managers
Get team managers.
| Method | Endpoint |
|---|---|
| GET | /v1/events/managers |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10236820 |
GET Event Odds All
Get all betting odds.
| Method | Endpoint |
|---|---|
| GET | /v1/events/odds/all |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 11930405 |
| odds_format | string | Yes | Odds format | decimal |
| provider_id | integer | No | Provider ID (1 = Bet365) | 1 |
GET Event Odds Winning
Get winning odds.
| Method | Endpoint |
|---|---|
| GET | /v1/events/odds/winning |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
| odds_format | string | Yes | Odds format | decimal |
| provider_id | integer | No | Provider ID | 1 |
GET Event Point by Point
Get point-by-point data (tennis).
| Method | Endpoint |
|---|---|
| GET | /v1/events/point-by-point |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10290654 |
GET Event Innings
Get innings data (cricket).
| Method | Endpoint |
|---|---|
| GET | /v1/events/innings |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10188874 |
GET Event Sub Events
Get sub events.
| Method | Endpoint |
|---|---|
| GET | /v1/events/sub-events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10277254 |
GET Newly Added Events
Get newly added events.
| Method | Endpoint |
|---|---|
| GET | /v1/events/newly-added-events |
Parameters: None
Esports Events
GET Esports Statistics
Get esports match statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/events/esports-statistics |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10289011 |
GET Esports Lineups
Get esports lineups.
| Method | Endpoint |
|---|---|
| GET | /v1/events/esports-lineups |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10289011 |
GET Esports Bans
Get esports bans.
| Method | Endpoint |
|---|---|
| GET | /v1/events/esports-bans |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10289011 |
GET Esports Games
Get esports games.
| Method | Endpoint |
|---|---|
| GET | /v1/events/esports-games |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10289011 |
GET Esports Rounds
Get esports rounds.
| Method | Endpoint |
|---|---|
| GET | /v1/events/esports-rounds |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 323668 |
Teams
GET Team Data
Get team information.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 44 |
GET Team Players
Get team roster.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/players |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 44 |
GET Team Events
Get team's match history.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 2817 |
| page | integer | Yes | Page number (0-indexed) | 0 |
| course_events | string | Yes | Event course type | last |
GET Team Near Events
Get team's upcoming/recent events.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/near-events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 2817 |
GET Team Current Tournaments
Get team's current tournaments.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/current-tournaments |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 2817 |
GET Team Recent Form
Get team's recent form.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/recent-form |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 2817 |
GET Team Rankings
Get team rankings.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/rankings |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 2817 |
GET Team Logo
Get team logo.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/logo |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 44 |
| sport_id | integer | No | Sport ID | 1 |
GET Team Transfers
Get team transfers.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/transfers |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 2817 |
GET Team News Feed
Get team news feed.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/news-feed |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 44 |
GET Team Statistics Seasons
Get available seasons for team statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/statistics/seasons |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 44 |
GET Team Statistics Result
Get team statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/statistics/result |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 44 |
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| season_id | integer | Yes | Season ID | 37036 |
| team_stat_type | string | No | Statistics type | overall |
GET Team Player Statistics Seasons
Get available seasons for player statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/player-statistics/seasons |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 44 |
GET Team Player Statistics Result
Get player statistics by team.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/player-statistics/result |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 44 |
| unique_tournament_id | integer | Yes | Unique Tournament ID | 17 |
| season_id | integer | Yes | Season ID | 37036 |
| player_stat_type | string | No | Statistics type | overall |
GET Team Standings Seasons
Get seasons for standings.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/standings/seasons |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 44 |
GET Team Recent Unique Tournaments
Get recent unique tournaments.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/recent-unique-tournaments |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 14486 |
Players
GET Player Data
Get player information.
| Method | Endpoint |
|---|---|
| GET | /v1/players/data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
GET Player Photo
Get player photo.
| Method | Endpoint |
|---|---|
| GET | /v1/players/photo |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
GET Player Characteristics
Get player characteristics.
| Method | Endpoint |
|---|---|
| GET | /v1/players/characteristics |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
GET Player Attribute Overviews
Get player attribute overviews.
| Method | Endpoint |
|---|---|
| GET | /v1/players/attribute-overviews |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
GET Player Events
Get player's match history.
| Method | Endpoint |
|---|---|
| GET | /v1/players/events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
| page | integer | Yes | Page number (0-indexed) | 0 |
| course_events | string | Yes | Event course type | last |
GET Player Statistics Seasons
Get available seasons for player statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/players/statistics/seasons |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
GET Player Statistics Result
Get player statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/players/statistics/result |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
| unique_tournament_id | integer | Yes | Unique Tournament ID | 34 |
| seasons_id | integer | Yes | Season ID | 37167 |
| player_stat_type | string | Yes | Statistics type | overall |
Note: Use
regularSeasonfor hockey statistics.
GET Player Heatmap
Get player's heatmap for a season.
| Method | Endpoint |
|---|---|
| GET | /v1/players/heatmap |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
| unique_tournament_id | integer | Yes | Unique Tournament ID | 34 |
| seasons_id | integer | Yes | Season ID | 37167 |
GET Player Last Ratings
Get player's latest ratings.
| Method | Endpoint |
|---|---|
| GET | /v1/players/last-ratings |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
| unique_tournament_id | integer | Yes | Unique Tournament ID | 34 |
| seasons_id | integer | Yes | Season ID | 37167 |
GET Player Transfer History
Get player's transfer history.
| Method | Endpoint |
|---|---|
| GET | /v1/players/transfer-history |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
GET Player National Team Statistics
Get player's national team statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/players/national-team-statistics |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
GET Player Last Year Summary
Get player's last year summary.
| Method | Endpoint |
|---|---|
| GET | /v1/players/last-year-summary |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| player_id | integer | Yes | Player ID | 12994 |
Managers
GET Manager Data
Get manager information.
| Method | Endpoint |
|---|---|
| GET | /v1/managers/data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| manager_id | integer | Yes | Manager ID | 52829 |
GET Manager Photo
Get manager photo.
| Method | Endpoint |
|---|---|
| GET | /v1/managers/photo |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| manager_id | integer | Yes | Manager ID | 52829 |
GET Manager Career History
Get manager's career history.
| Method | Endpoint |
|---|---|
| GET | /v1/managers/career-history |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| manager_id | integer | Yes | Manager ID | 52829 |
GET Manager Events
Get manager's match history.
| Method | Endpoint |
|---|---|
| GET | /v1/managers/events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| manager_id | integer | Yes | Manager ID | 52829 |
| page | integer | Yes | Page number (0-indexed) | 0 |
| course_events | string | Yes | Event course type | last |
Referees
GET Referee Data
Get referee information.
| Method | Endpoint |
|---|---|
| GET | /v1/referees/data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| referee_id | integer | Yes | Referee ID | 72792 |
GET Referee Statistics
Get referee statistics.
| Method | Endpoint |
|---|---|
| GET | /v1/referees/statistics |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| referee_id | integer | Yes | Referee ID | 72792 |
GET Referee Events
Get referee's match history.
| Method | Endpoint |
|---|---|
| GET | /v1/referees/events |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| referee_id | integer | Yes | Referee ID | 72792 |
| page | integer | Yes | Page number (0-indexed) | 0 |
| course_events | string | Yes | Event course type | last |
Rankings
GET Current Rankings
Get current rankings.
| Method | Endpoint |
|---|---|
| GET | /v1/rankings/current |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| ranking | string | Yes | Ranking type | atp |
GET Season Rankings
Get rankings by season/year.
| Method | Endpoint |
|---|---|
| GET | /v1/rankings/season |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| ranking | string | Yes | Ranking type | atp |
| year | integer | Yes | Year | 2022 |
Transfers
GET Search Transfers
Search transfers with filters.
| Method | Endpoint |
|---|---|
| GET | /v1/transfers/search |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| page | integer | Yes | Page number (0-indexed) | 0 |
| nationality | string | No | Country code | ENG |
| min_age | integer | No | Minimum age | 15 |
| max_age | integer | No | Maximum age | 50 |
| position_type | string | No | Position (G, D, M, F) | G |
| popularity | integer | No | Popularity filter | 10 |
| joined | boolean | No | Joined filter | true |
| sort_type | string | No | Sort type | transfer_fee_max |
| unique_tournament_id | integer | No | Unique Tournament ID | - |
TV
GET TV Channels
Get list of TV channels by country.
| Method | Endpoint |
|---|---|
| GET | /v1/tv/channels |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| locale | string | Yes | Locale code | en |
GET TV Country Channels
Get TV channels for an event.
| Method | Endpoint |
|---|---|
| GET | /v1/tv/country-channels |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 11930405 |
GET TV Channel Data
Get channel data.
| Method | Endpoint |
|---|---|
| GET | /v1/tv/channel-data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| event_id | integer | Yes | Event ID | 10253769 |
| channel_id | integer | Yes | Channel ID | 2707 |
Stages (Motorsport)
GET Unique Stages
Get list of unique stages by category.
| Method | Endpoint |
|---|---|
| GET | /v1/unique-stages |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| category_id | integer | Yes | Category ID | 84 |
GET Unique Stages Seasons
Get seasons for a unique stage.
| Method | Endpoint |
|---|---|
| GET | /v1/unique-stages/seasons |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| unique_stage_id | integer | Yes | Unique Stage ID | 28 |
GET Stage Data
Get stage data.
| Method | Endpoint |
|---|---|
| GET | /v1/stages/data |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| stage_id | integer | Yes | Stage ID | 190582 |
GET Stage Substages
Get substages of a stage.
| Method | Endpoint |
|---|---|
| GET | /v1/stages/substages |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| stage_id | integer | Yes | Stage ID | 190582 |
GET Stage Standings Competitor
Get competitor standings.
| Method | Endpoint |
|---|---|
| GET | /v1/stages/standings/competitor |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| stage_id | integer | Yes | Stage ID | 188803 |
GET Stage Standings Teams
Get team standings.
| Method | Endpoint |
|---|---|
| GET | /v1/stages/standings/teams |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| stage_id | integer | Yes | Stage ID | 188803 |
GET Team Races (Motorsport)
Get team races.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/races |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 226818 |
| page | integer | Yes | Page number (0-indexed) | 0 |
| course_events | string | Yes | Event course type | last |
GET Team Career History (Motorsport)
Get team career history.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/career-history |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 226818 |
GET Team Stage Seasons (Motorsport)
Get team stage seasons.
| Method | Endpoint |
|---|---|
| GET | /v1/teams/stage-seasons |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| team_id | integer | Yes | Team ID | 226818 |
Common Workflows
Workflow 1: Get Today's Football Matches
1. GET /v1/sports → Get sport_id for Football (1)
2. GET /v1/calendar/categories?sport_id=1&date=2024-03-15&timezone=0 → Get categories with events
3. GET /v1/events/schedule/category?category_id=1&date=2024-03-15 → Get events for each categoryWorkflow 2: Get Match Details
1. GET /v1/events/data?event_id=11930405 → Get basic match info
2. GET /v1/events/statistics?event_id=11930405 → Get match statistics
3. GET /v1/events/lineups?event_id=11930405 → Get lineups
4. GET /v1/events/incidents?event_id=11930405 → Get incidents (goals, cards)Workflow 3: Get League Standings
1. GET /v1/categories?sport_id=1 → Get categories
2. GET /v1/unique-tournaments?category_id=1 → Get tournaments for category
3. GET /v1/unique-tournaments/seasons?unique_tournament_id=17 → Get seasons
4. GET /v1/seasons/standings?unique_tournament_id=17&seasons_id=37036&standing_type=total → Get standingsWorkflow 4: Get Player Statistics
1. GET /v1/teams/players?team_id=44 → Get team players
2. GET /v1/players/statistics/seasons?player_id=12994 → Get available seasons
3. GET /v1/players/statistics/result?player_id=12994&unique_tournament_id=34&seasons_id=37167&player_stat_type=overall → Get statsWorkflow 5: Get Live Events
1. GET /v1/sports/number-live → Get number of live events per sport
2. GET /v1/events/schedule/live?sport_id=1 → Get all live football matchesResponse Examples
Sport List Response
{
"data": [
{"name": "Football", "slug": "football", "id": 1},
{"name": "Basketball", "slug": "basketball", "id": 2},
{"name": "Ice Hockey", "slug": "ice-hockey", "id": 4},
{"name": "Tennis", "slug": "tennis", "id": 5},
{"name": "Handball", "slug": "handball", "id": 6},
{"name": "Volleyball", "slug": "volleyball", "id": 23},
{"name": "Cricket", "slug": "cricket", "id": 62},
{"name": "American Football", "slug": "american-football", "id": 63},
{"name": "Baseball", "slug": "baseball", "id": 64},
{"name": "eSports", "slug": "esports", "id": 72}
]
}Event Data Response
{
"data": {
"tournament": {
"name": "Premier League",
"category": {"name": "England", "alpha2": "EN"},
"uniqueTournament": {"id": 17, "name": "Premier League"}
},
"season": {"name": "Premier League 25/26", "year": "25/26", "id": 76986},
"roundInfo": {"round": 26},
"status": {"code": 100, "description": "Ended", "type": "finished"},
"winnerCode": 3,
"homeTeam": {"name": "Chelsea", "id": 38, "nameCode": "CHE"},
"awayTeam": {"name": "Leeds United", "id": 34, "nameCode": "LEE"},
"homeScore": {"current": 2, "period1": 1, "period2": 1},
"awayScore": {"current": 2, "period1": 0, "period2": 2},
"venue": {"name": "Stamford Bridge", "city": {"name": "London"}},
"referee": {"name": "Robert Jones"},
"startTimestamp": 1770751800
}
}Categories Response
{
"data": [
{
"category": {
"name": "England",
"slug": "england",
"sport": {"name": "Football", "id": 1},
"id": 1,
"flag": "england",
"alpha2": "EN"
},
"totalEvents": 7,
"totalVideos": 5,
"uniqueTournamentIds": [1044, 17, 18, 25]
}
]
}Reference Tables
Event Status Types
| Status | Description |
|---|---|
notstarted | Match has not started |
live | Match is currently live |
finished | Match has ended |
canceled | Match was canceled |
postponed | Match was postponed |
delayed | Match start delayed |
interrupted | Match was interrupted |
conditional | Conditional status |
will continue | Match will continue |
Player Positions
Football
| Code | Position |
|---|---|
| G | Goalkeeper |
| D | Defender |
| M | Midfielder |
| F | Forward |
| C | Central Forward |
Basketball
| Code | Position |
|---|---|
| C | Center |
| CF | Center Forward |
| F | Forward |
| FC | Heavy Forward |
| FG | Shooting Guard |
| G | Point Guard |
| GF | Small Forward |
Ice Hockey
| Code | Position |
|---|---|
| C | Central Forward |
| D | Defender |
| F | Forward |
| G | Goalkeeper |
| L | Left Wing |
| R | Right Wing |
Incident Types
| Type | Description |
|---|---|
period | Period start/end |
injuryTime | Injury time announced |
card | Yellow/Red card |
goal | Goal scored |
substitution | Player substitution |
Winner Codes
| Code | Result |
|---|---|
| 1 | Home team won |
| 2 | Away team won |
| 3 | Draw |
Sport IDs
| ID | Sport |
|---|---|
| 1 | Football |
| 2 | Basketball |
| 4 | Ice Hockey |
| 5 | Tennis |
| 6 | Handball |
| 7 | Floorball |
| 11 | Motorsport |
| 12 | Rugby |
| 13 | Aussie Rules |
| 15 | Bandy |
| 19 | Snooker |
| 20 | Table Tennis |
| 22 | Darts |
| 23 | Volleyball |
| 26 | Waterpolo |
| 29 | Futsal |
| 31 | Badminton |
| 34 | Beach Volley |
| 62 | Cricket |
| 63 | American Football |
| 64 | Baseball |
| 72 | eSports |
| 109 | Minifootball |
FAQ
How do I get the current match time in soccer?
The API provides timing information in the time object:
"time": {
"initial": 2700,
"max": 5400,
"extra": 540,
"currentPeriodStartTimestamp": 1701068460
}Or in statusTime:
"statusTime": {
"prefix": "",
"initial": 2700,
"max": 5400,
"timestamp": 1701068460,
"extra": 540
}Fields:
initial- Duration of the half (in seconds)max- Duration of the match (in seconds)currentPeriodStartTimestamp/timestamp- Unix timestamp when the half startedextra- Injury time (in seconds)
Calculate current time:
current_time = current_timestamp - currentPeriodStartTimestampIs this API free?
Yes, there is a free tier with monthly request limits. For higher limits or custom plans, contact tipsters@rapi.one or t.me/api_tipsters
How do I handle timezone?
The timezone parameter accepts values from -11 to 13. Use your local timezone offset. For example:
- UTC+0 = 0
- UTC+1 = 1
- UTC-5 = -5
How do I paginate through results?
Many endpoints support pagination with page parameter (0-indexed):
- Page 0 = First page
- Page 1 = Second page
- etc.
Python Code Examples
Setup & Configuration
import requests
import json
from datetime import datetime
# API Configuration
API_BASE_URL = "https://sofasport.p.rapidapi.com"
API_KEY = "YOUR_RAPIDAPI_KEY" # Replace with your RapidAPI key
# Headers for all requests
HEADERS = {
"X-RapidAPI-Key": API_KEY,
"X-RapidAPI-Host": "sofasport.p.rapidapi.com"
}
def make_request(endpoint, params=None):
"""Make API request with error handling"""
url = f"{API_BASE_URL}{endpoint}"
response = requests.get(url, headers=HEADERS, params=params)
if response.status_code == 200:
return response.json()
elif response.status_code == 401:
raise Exception("Invalid API key")
elif response.status_code == 403:
raise Exception("Access forbidden - check subscription")
elif response.status_code == 429:
raise Exception("Rate limit exceeded")
else:
raise Exception(f"API Error: {response.status_code}")Workflow 1: Get All Sports
def get_all_sports():
"""Get list of all available sports"""
data = make_request("/v1/sports")
return data.get('data', [])
# Usage
sports = get_all_sports()
print("Available Sports:")
for sport in sports:
print(f" {sport['id']}: {sport['name']}")
# Output:
# Available Sports:
# 1: Football
# 2: Basketball
# 4: Ice Hockey
# 5: Tennis
# ...Workflow 2: Get Categories by Sport
def get_categories(sport_id):
"""Get categories (countries/leagues) for a sport"""
data = make_request("/v1/categories", {"sport_id": sport_id})
return data.get('data', [])
# Usage - Get football categories
categories = get_categories(1) # 1 = Football
print("\nFootball Categories:")
for cat in categories[:10]:
print(f" {cat['id']}: {cat['name']} ({cat.get('alpha2', 'N/A')})")
# Output:
# Football Categories:
# 1: England (EN)
# 2: Spain (ES)
# 3: Italy (IT)
# ...Workflow 3: Get Today's Matches
def get_today_matches(sport_id=1, timezone_offset=0):
"""
Get all matches for today
Args:
sport_id: Sport ID (default: 1 for Football)
timezone_offset: Timezone offset (-11 to 13)
"""
today = datetime.now().strftime('%Y-%m-%d')
# Step 1: Get categories with events today
data = make_request("/v1/calendar/categories", {
"sport_id": sport_id,
"date": today,
"timezone": timezone_offset
})
categories = data.get('data', [])
all_matches = []
# Step 2: Get events for each category
for cat in categories:
category_id = cat['category']['id']
events_data = make_request("/v1/events/schedule/category", {
"category_id": category_id,
"date": today
})
events = events_data.get('data', [])
all_matches.extend(events)
return all_matches
# Usage
matches = get_today_matches()
print(f"\nFound {len(matches)} matches today")
for match in matches[:5]:
home = match['homeTeam']['name']
away = match['awayTeam']['name']
home_score = match.get('homeScore', {}).get('current', '-')
away_score = match.get('awayScore', {}).get('current', '-')
status = match['status']['description']
tournament = match.get('tournament', {}).get('name', '')
print(f" {home} {home_score} - {away_score} {away} [{status}] ({tournament})")Workflow 4: Get Live Matches
def get_live_matches(sport_id=1):
"""Get all live matches for a sport"""
data = make_request("/v1/events/schedule/live", {"sport_id": sport_id})
return data.get('data', [])
# Usage
live_matches = get_live_matches(1)
print(f"\nLive Matches: {len(live_matches)}")
for match in live_matches[:10]:
home = match['homeTeam']['name']
away = match['awayTeam']['name']
home_score = match.get('homeScore', {}).get('current', 0)
away_score = match.get('awayScore', {}).get('current', 0)
status = match['status']['description']
tournament = match.get('tournament', {}).get('name', '')
print(f" {home} {home_score} - {away_score} {away} [{status}] ({tournament})")Workflow 5: Get Match Details
def get_event_data(event_id):
"""Get detailed event/match data"""
data = make_request("/v1/events/data", {"event_id": event_id})
return data.get('data', {})
def get_event_statistics(event_id):
"""Get match statistics"""
data = make_request("/v1/events/statistics", {"event_id": event_id})
return data.get('data', {})
def get_event_lineups(event_id):
"""Get team lineups"""
data = make_request("/v1/events/lineups", {"event_id": event_id})
return data.get('data', {})
def get_event_incidents(event_id):
"""Get match incidents (goals, cards, substitutions)"""
data = make_request("/v1/events/incidents", {"event_id": event_id})
return data.get('data', {})
# Usage
event_id = 13981507 # Example event ID
# Get event details
event = get_event_data(event_id)
print(f"\nMatch: {event['homeTeam']['name']} vs {event['awayTeam']['name']}")
print(f"Tournament: {event['tournament']['name']}")
print(f"Status: {event['status']['description']}")
print(f"Score: {event.get('homeScore', {}).get('current', 0)} - {event.get('awayScore', {}).get('current', 0)}")
# Get incidents
incidents = get_event_incidents(event_id)
if incidents:
print("\nIncidents:")
for incident in incidents:
inc_type = incident.get('incidentType', 'Unknown')
time = incident.get('time', 0)
print(f" {time}' - {inc_type}")Workflow 6: Get League Standings
def get_unique_tournaments(category_id):
"""Get tournaments for a category"""
data = make_request("/v1/unique-tournaments", {"category_id": category_id})
return data.get('data', [])
def get_tournament_seasons(unique_tournament_id):
"""Get seasons for a tournament"""
data = make_request("/v1/unique-tournaments/seasons", {
"unique_tournament_id": unique_tournament_id
})
return data.get('data', [])
def get_standings(unique_tournament_id, season_id, standing_type="total"):
"""Get league standings"""
data = make_request("/v1/seasons/standings", {
"unique_tournament_id": unique_tournament_id,
"seasons_id": season_id,
"standing_type": standing_type
})
return data.get('data', {})
# Usage - Get Premier League standings
def display_premier_league_table():
tournament_id = 17 # Premier League
# Get current season
seasons = get_tournament_seasons(tournament_id)
if seasons:
current_season = seasons[0]
season_id = current_season['id']
print(f"Season: {current_season['name']}\n")
# Get standings
standings_data = get_standings(tournament_id, season_id)
if standings_data:
table = standings_data['standings'][0]['rows']
print(f"{'Pos':<4} {'Team':<25} {'P':<4} {'W':<4} {'D':<4} {'L':<4} {'GD':<5} {'Pts':<4}")
print("-" * 60)
for team in table:
pos = team['position']
name = team['team']['name'][:24]
played = team['matches']
won = team['wins']
drawn = team['draws']
lost = team['losses']
gd = int(team['scoreDiffFormatted'])
points = team['points']
print(f"{pos:<4} {name:<25} {played:<4} {won:<4} {drawn:<4} {lost:<4} {gd:<+5} {points:<4}")
display_premier_league_table()Workflow 7: Get Team Information
def get_team_data(team_id):
"""Get team information"""
data = make_request("/v1/teams/data", {"team_id": team_id})
return data.get('data', {})
def get_team_players(team_id):
"""Get team roster"""
data = make_request("/v1/teams/players", {"team_id": team_id})
return data.get('data', [])
def get_team_events(team_id, page=0):
"""Get team match history"""
data = make_request("/v1/teams/events", {
"team_id": team_id,
"page": page,
"course_events": "last"
})
return data.get('data', [])
# Usage - Get Chelsea FC info
team_id = 38 # Chelsea FC
team = get_team_data(team_id)
print(f"\nTeam: {team['name']}")
print(f"Country: {team.get('country', {}).get('name', 'N/A')}")
print(f"Founded: {datetime.fromtimestamp(team.get('foundationDateTimestamp', 0)).year if team.get('foundationDateTimestamp') else 'N/A'}")
# Get players
players = get_team_players(team_id)
print(f"\nPlayers ({len(players['players'])}):")
for player in players['players'][:10]:
name = player['player']['name']
position = player['player'].get('position', 'N/A')
print(f" {name} ({position})")Workflow 8: Get Player Statistics
def get_player_data(player_id):
"""Get player information"""
data = make_request("/v1/players/data", {"player_id": player_id})
return data.get('data', {})
def get_player_statistics_seasons(player_id):
"""Get available seasons for player statistics"""
data = make_request("/v1/players/statistics/seasons", {"player_id": player_id})
return data.get('data', [])
def get_player_statistics(player_id, unique_tournament_id, season_id):
"""Get player statistics for a season"""
data = make_request("/v1/players/statistics/result", {
"player_id": player_id,
"unique_tournament_id": unique_tournament_id,
"seasons_id": season_id,
"player_stat_type": "overall"
})
return data.get('data', {})
# Usage
player_id = 12994 # Example player ID
player = get_player_data(player_id)
print(f"\nPlayer: {player['name']}")
print(f"Position: {player.get('position', 'N/A')}")
print(f"Country: {player.get('country', {}).get('name', 'N/A')}")
# Get statistics
seasons = get_player_statistics_seasons(player_id)
if seasons:
recent_season = seasons['uniqueTournamentSeasons'][9]
season_id = recent_season['seasons'][0]['id']
tournament_id = recent_season['uniqueTournament']['id']
stats = get_player_statistics(player_id, tournament_id, season_id)
if stats and 'statistics' in stats:
stat = stats['statistics']
print(f"\nStatistics ({recent_season['seasons'][0]['name']}):")
print(f" Matches: {stat.get('matchesStarted', 0)}")
print(f" Goals: {stat.get('goals', 0)}")
print(f" Assists: {stat.get('assists', 0)}")
print(f" Minutes: {stat.get('minutesPlayed', 0)}")
"""
Player: Lionel Messi
Position: F
Country: Argentina
Statistics (UEFA Champions League 22/23):
Matches: 7
Goals: 4
Assists: 4
Minutes: 615
"""Workflow 9: Live Score Monitor
import time
from collections import deque
class LiveScoreMonitor:
def __init__(self, sport_id=1, refresh_interval=60):
self.sport_id = sport_id
self.refresh_interval = refresh_interval
self.tracked_matches = {}
def get_live_matches(self):
"""Get current live matches"""
data = make_request("/v1/events/schedule/live", {"sport_id": self.sport_id})
return data.get('data', [])
def check_score_changes(self, matches):
"""Check for score changes"""
changes = []
for match in matches:
match_id = match['id']
home_score = match.get('homeScore', {}).get('current', 0)
away_score = match.get('awayScore', {}).get('current', 0)
current_score = (home_score, away_score)
if match_id in self.tracked_matches:
previous_score = self.tracked_matches[match_id]
if current_score != previous_score:
changes.append({
'match': match,
'previous': previous_score,
'current': current_score
})
self.tracked_matches[match_id] = current_score
return changes
def monitor(self, duration_minutes=5):
"""Monitor live matches for changes"""
print(f"Starting live score monitor for {duration_minutes} minutes...")
print(f"Refresh interval: {self.refresh_interval} seconds\n")
end_time = time.time() + (duration_minutes * 60)
while time.time() < end_time:
timestamp = datetime.now().strftime('%H:%M:%S')
print(f"[{timestamp}] Checking for updates...")
try:
matches = self.get_live_matches()
print(f"Live matches: {len(matches)}")
changes = self.check_score_changes(matches)
if changes:
print("\n*** SCORE CHANGES DETECTED! ***")
for change in changes:
match = change['match']
home = match['homeTeam']['name']
away = match['awayTeam']['name']
prev = change['previous']
curr = change['current']
print(f" {home} {prev[0]} -> {curr[0]} - {curr[1]} <- {prev[1]} {away}")
else:
for match in matches[:5]:
home = match['homeTeam']['name']
away = match['awayTeam']['name']
h_score = match.get('homeScore', {}).get('current', 0)
a_score = match.get('awayScore', {}).get('current', 0)
status = match['status']['description']
print(f" {home} {h_score} - {a_score} {away} [{status}]")
except Exception as e:
print(f"Error: {e}")
time.sleep(self.refresh_interval)
print("\nMonitoring ended.")
# Usage
monitor = LiveScoreMonitor(sport_id=1, refresh_interval=30)
monitor.monitor(duration_minutes=10)Workflow 10: Get Match Odds
def get_match_odds(event_id, provider_id=1):
"""
Get betting odds for a match
Args:
event_id: Event ID
provider_id: Odds provider (1 = Bet365)
"""
data = make_request("/v1/events/odds/all", {
"event_id": event_id,
"provider_id": provider_id,
"odds_format": "decimal"
})
return data.get('data', {})
# Usage
event_id = 14442358
# Get event info first
event = get_event_data(event_id)
print(f"\n{event['homeTeam']['name']} vs {event['awayTeam']['name']}")
print("=" * 40)
# Get odds
odds_data = get_match_odds(event_id)
if odds_data:
for market in odds_data:
market_name = market.get('marketName', 'Unknown')
print(f"\n{market_name}:")
for choice in market.get('choices', []):
name = choice.get('name', '')
odds = choice.get('fractionalValue', 0)
print(f" {name}: {odds}")
else:
print("No odds available for this match")Complete Example: Football Dashboard
#!/usr/bin/env python3
"""
Football Dashboard - Complete Example
Displays live scores, standings, and upcoming matches
"""
import requests
from datetime import datetime
class FootballDashboard:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = "https://sofasport.p.rapidapi.com"
self.headers = {
"X-RapidAPI-Key": api_key,
"X-RapidAPI-Host": "sofasport.p.rapidapi.com"
}
def request(self, endpoint, params=None):
url = f"{self.base_url}{endpoint}"
response = requests.get(url, headers=self.headers, params=params)
return response.json() if response.status_code == 200 else None
def get_live_matches(self):
data = self.request("/v1/events/schedule/live", {"sport_id": 1})
return data.get('data', []) if data else []
def get_standings(self, tournament_id=17):
# Get current season
seasons_data = self.request("/v1/unique-tournaments/seasons", {
"unique_tournament_id": tournament_id
})
if not seasons_data or not seasons_data.get('data'):
return None
season_id = seasons_data['data'][0]['id']
# Get standings
standings_data = self.request("/v1/seasons/standings", {
"unique_tournament_id": tournament_id,
"seasons_id": season_id,
"standing_type": "total"
})
return standings_data.get('data') if standings_data else None
def display_dashboard(self):
print("\n" + "=" * 60)
print(f" FOOTBALL DASHBOARD - {datetime.now().strftime('%Y-%m-%d %H:%M')}")
print("=" * 60)
# Live Matches
print("\n LIVE MATCHES")
print(" " + "-" * 56)
live_matches = self.get_live_matches()
if live_matches:
for match in live_matches[:8]:
home = match['homeTeam']['name'][:12]
away = match['awayTeam']['name'][:12]
h_score = match.get('homeScore', {}).get('current', 0)
a_score = match.get('awayScore', {}).get('current', 0)
status = match['status']['description']
tournament = match.get('tournament', {}).get('name', '')[:15]
print(f" {home:<12} {h_score} - {a_score} {away:<12} [{status:<8}] {tournament}")
else:
print(" No live matches at the moment")
# Standings (Top 5)
print("\n PREMIER LEAGUE STANDINGS (Top 5)")
print(" " + "-" * 56)
standings = self.get_standings(17) # Premier League
if standings:
table = standings[0]['rows'][:5]
print(f" {'#':<3} {'Team':<20} {'P':<3} {'GD':<4} {'Pts':<3}")
print(" " + "-" * 36)
for team in table:
pos = team['position']
name = team['team']['name'][:18]
played = team['matches']
gd = int(team['scoreDiffFormatted'])
points = team['points']
print(f" {pos:<3} {name:<20} {played:<3} {gd:<+4} {points:<3}")
print("\n" + "=" * 60)
# Usage
if __name__ == "__main__":
API_KEY = "YOUR_RAPIDAPI_KEY"
dashboard = FootballDashboard(API_KEY)
dashboard.display_dashboard()Support
Email: tipsters@rapi.one
Telegram: https://t.me/api_tipsters
Other Sport APIs: https://rapi.one/sports/
OpenAPI Specification: https://hugeapi.com/collection/sofascores