Skip to content

Instantly share code, notes, and snippets.

@sandalsoft
Created June 3, 2025 00:48
Show Gist options
  • Save sandalsoft/1cfdb230368f100fd2779d28eaeddc79 to your computer and use it in GitHub Desktop.
Save sandalsoft/1cfdb230368f100fd2779d28eaeddc79 to your computer and use it in GitHub Desktop.
FBRAPI OpenAPI
openapi: 3.0.3
info:
title: FBR API
description: |
The FBR API provides developers, statistics enthusiasts, and football (soccer) fans with convenient access to data from fbref.com.
As a premier source of football statistics, fbref.com offers comprehensive information on leagues, teams, and players from around the world.
**Rate Limiting**: Users are limited to one request every 3 seconds to comply with fbref.com scraping restrictions.
**Authentication**: All endpoints require an API key obtained from the `/generate_api_key` endpoint.
version: 1.0.0
contact:
url: https://fbrapi.com/documentation
license:
name: API License
url: https://fbrapi.com
servers:
- url: https://fbrapi.com
description: Production server
security:
- ApiKeyAuth: []
components:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-Key
description: API key for authentication
schemas:
ApiKeyResponse:
type: object
properties:
api_key:
type: string
description: Generated API key for authentication
required:
- api_key
Country:
type: object
properties:
country:
type: string
description: Name of the country
country_code:
type: string
description: Three-letter country code
governing_body:
type: string
description: Governing body (e.g., UEFA, AFC)
"#_clubs":
type: integer
description: Number of clubs
"#_players":
type: integer
description: Number of players
national_teams:
type: array
items:
type: string
description: National team types (M for men, F for women)
League:
type: object
properties:
league_id:
type: integer
description: Unique league identifier
competition_name:
type: string
description: Name of the competition
gender:
type: string
enum: [M, F]
description: Gender (M for men, F for women)
first_season:
type: string
description: First season tracked
last_season:
type: string
description: Last season tracked
tier:
type: string
description: League tier (e.g., "1st", "2nd")
LeagueType:
type: object
properties:
league_type:
type: string
enum: [domestic_leagues, international_competitions, national_team_competitions]
leagues:
type: array
items:
$ref: '#/components/schemas/League'
Season:
type: object
properties:
season_id:
type: string
description: Season identifier (YYYY or YYYY-YYYY format)
competition_name:
type: string
description: Name of the competition
"#_squads":
type: integer
description: Number of squads
champion:
type: string
description: Season champion
top_scorer:
type: object
properties:
player:
oneOf:
- type: string
- type: array
items:
type: string
description: Top scorer(s)
goals_scored:
type: integer
description: Goals scored by top scorer
LeagueSeasonDetails:
type: object
properties:
lg_id:
type: integer
description: League ID
season_id:
type: string
description: Season ID
league_start:
type: string
format: date
description: League start date
league_end:
type: string
description: League end date
league_type:
type: string
enum: [league, cup]
description: Type of league
has_adv_stats:
type: string
enum: [yes, no]
description: Whether advanced stats are available
rounds:
type: array
items:
type: string
description: Available rounds
StandingsTeam:
type: object
properties:
rk:
type: integer
description: Rank
team_name:
type: string
description: Team name
team_id:
type: string
description: Team ID
mp:
type: integer
description: Matches played
w:
type: integer
description: Wins
d:
type: integer
description: Draws
l:
type: integer
description: Losses
gf:
type: integer
description: Goals for
ga:
type: integer
description: Goals against
gd:
type: string
description: Goal difference
pts:
type: integer
description: Points
"pts/mp":
type: number
description: Points per match
xg:
type: number
description: Expected goals
xga:
type: number
description: Expected goals against
xgd:
type: string
description: Expected goal difference
"xgd/90":
type: string
description: Expected goal difference per 90 minutes
attendance:
type: string
description: Average attendance
goalkeeper:
type: string
description: Primary goalkeeper
top_team_scorer:
type: object
properties:
player:
oneOf:
- type: string
- type: array
items:
type: string
goals_scored:
type: integer
Standings:
type: object
properties:
standings_type:
type: string
description: Type of standings table
standings:
type: array
items:
$ref: '#/components/schemas/StandingsTeam'
Player:
type: object
properties:
player:
type: string
description: Player name
player_id:
type: string
description: Player ID
nationality:
type: string
description: Player nationality
position:
type: string
description: Player position
age:
type: integer
description: Player age
mp:
type: integer
description: Matches played
starts:
type: integer
description: Starts
Match:
type: object
properties:
date:
type: string
format: date
description: Match date
time:
type: string
description: Match time
match_id:
type: string
description: Match ID
league_name:
type: string
description: League name
league_id:
type: integer
description: League ID
opponent:
type: string
description: Opponent name
opponent_id:
type: string
description: Opponent ID
home_away:
type: string
enum: [Home, Away]
description: Home or away
result:
type: string
enum: [W, D, L]
description: Match result
gf:
type: integer
description: Goals for
ga:
type: integer
description: Goals against
attendance:
type: string
description: Attendance
captain:
type: string
description: Team captain
formation:
type: string
description: Formation used
referee:
type: string
description: Match referee
PlayerDetails:
type: object
properties:
player_id:
type: string
description: Player ID
full_name:
type: string
description: Full name
positions:
type: array
items:
type: string
description: Positions played
footed:
type: string
description: Preferred foot
date_of_birth:
type: string
format: date
description: Date of birth
birth_city:
type: string
description: Birth city
nationality:
type: string
description: Nationality
wages:
type: string
description: Wages
height:
type: number
description: Height in cm
photo_url:
type: string
format: uri
description: Photo URL
birth_country:
type: string
description: Birth country
weight:
type: number
description: Weight in kg
Error:
type: object
properties:
error:
type: string
description: Error message
code:
type: integer
description: Error code
paths:
/documentation:
get:
summary: View FBR API documentation
description: Retrieve the API documentation
responses:
'200':
description: Documentation retrieved successfully
content:
text/html:
schema:
type: string
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/generate_api_key:
post:
summary: Generate a new API key
description: Generate a unique API key for accessing the FBR API endpoints
security: []
responses:
'200':
description: API key generated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/ApiKeyResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/countries:
get:
summary: Retrieve football-related meta-data for countries
description: Get meta-data for all available countries or a specific country
parameters:
- name: country
in: query
description: Name of the country to retrieve data for
required: false
schema:
type: string
responses:
'200':
description: Countries data retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Country'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/leagues:
get:
summary: Retrieve meta-data for leagues by country
description: Get meta-data for all unique leagues associated with a specified country
parameters:
- name: country_code
in: query
description: Three-letter country code
required: true
schema:
type: string
minLength: 3
maxLength: 3
responses:
'200':
description: Leagues data retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/LeagueType'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/league-seasons:
get:
summary: Retrieve all season IDs for a league
description: Get meta-data for all season IDs tracked for a specific league
parameters:
- name: league_id
in: query
description: League ID
required: true
schema:
type: integer
responses:
'200':
description: League seasons retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Season'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: League not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/league-season-details:
get:
summary: Retrieve meta-data for a specific league and season
description: Get detailed information for a specific league ID and season ID
parameters:
- name: league_id
in: query
description: League ID
required: true
schema:
type: integer
- name: season_id
in: query
description: Season ID (YYYY or YYYY-YYYY format)
required: false
schema:
type: string
responses:
'200':
description: League season details retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/LeagueSeasonDetails'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: League or season not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/league-standings:
get:
summary: Retrieve standings tables for a league and season
description: Get all standings tables for a given league and season ID
parameters:
- name: league_id
in: query
description: League ID
required: true
schema:
type: integer
- name: season_id
in: query
description: Season ID (YYYY or YYYY-YYYY format)
required: false
schema:
type: string
responses:
'200':
description: League standings retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Standings'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: League or season not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/teams:
get:
summary: Retrieve team roster and schedule data
description: Get team roster and schedule information for a given team and season
parameters:
- name: team_id
in: query
description: 8-character team ID
required: true
schema:
type: string
minLength: 8
maxLength: 8
- name: season_id
in: query
description: Season ID (YYYY or YYYY-YYYY format)
required: false
schema:
type: string
responses:
'200':
description: Team data retrieved successfully
content:
application/json:
schema:
type: object
properties:
team_roster:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Player'
team_schedule:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Match'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Team not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/players:
get:
summary: Retrieve player meta-data
description: Get detailed information for a specific player
parameters:
- name: player_id
in: query
description: 8-character player ID
required: true
schema:
type: string
minLength: 8
maxLength: 8
responses:
'200':
description: Player data retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/PlayerDetails'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Player not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/matches:
get:
summary: Retrieve match meta-data
description: Get match meta-data for a team or league
parameters:
- name: team_id
in: query
description: 8-character team ID (for team match data)
required: false
schema:
type: string
minLength: 8
maxLength: 8
- name: league_id
in: query
description: League ID (for league match data)
required: false
schema:
type: integer
- name: season_id
in: query
description: Season ID (YYYY or YYYY-YYYY format)
required: false
schema:
type: string
responses:
'200':
description: Match data retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Match'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Team or league not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/team-season-stats:
get:
summary: Retrieve season-level team statistics
description: Get aggregate season statistics for teams in a specific league and season
parameters:
- name: league_id
in: query
description: League ID
required: true
schema:
type: integer
- name: season_id
in: query
description: Season ID (YYYY or YYYY-YYYY format)
required: false
schema:
type: string
responses:
'200':
description: Team season statistics retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
type: object
properties:
meta_data:
type: object
properties:
team_id:
type: string
team_name:
type: string
stats:
type: object
description: Comprehensive team statistics (varies by league)
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: League or season not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/team-match-stats:
get:
summary: Retrieve match-level team statistics
description: Get match-by-match team statistics for a specific team, league, and season
parameters:
- name: team_id
in: query
description: 8-character team ID
required: true
schema:
type: string
minLength: 8
maxLength: 8
- name: league_id
in: query
description: League ID
required: true
schema:
type: integer
- name: season_id
in: query
description: Season ID (YYYY or YYYY-YYYY format)
required: true
schema:
type: string
responses:
'200':
description: Team match statistics retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
type: object
properties:
meta_data:
type: object
properties:
match_id:
type: string
date:
type: string
format: date
round:
type: string
home_away:
type: string
opponent:
type: string
opponent_id:
type: string
stats:
type: object
description: Detailed match statistics for the team
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Team, league, or season not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/player-season-stats:
get:
summary: Retrieve season-level player statistics
description: Get aggregate season stats for all players in a team-league-season combination
parameters:
- name: team_id
in: query
description: 8-character team ID
required: true
schema:
type: string
minLength: 8
maxLength: 8
- name: league_id
in: query
description: League ID
required: true
schema:
type: integer
- name: season_id
in: query
description: Season ID (YYYY or YYYY-YYYY format)
required: false
schema:
type: string
responses:
'200':
description: Player season statistics retrieved successfully
content:
application/json:
schema:
type: object
properties:
players:
type: array
items:
type: object
properties:
meta_data:
type: object
properties:
player_id:
type: string
player_name:
type: string
player_country_code:
type: string
age:
type: integer
stats:
type: object
description: Comprehensive player statistics
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Team, league, or season not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/player-match-stats:
get:
summary: Retrieve match-level player statistics
description: Get match-by-match statistics for a specific player in a league and season
parameters:
- name: player_id
in: query
description: 8-character player ID
required: true
schema:
type: string
minLength: 8
maxLength: 8
- name: league_id
in: query
description: League ID
required: true
schema:
type: integer
- name: season_id
in: query
description: Season ID (YYYY or YYYY-YYYY format)
required: false
schema:
type: string
responses:
'200':
description: Player match statistics retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
type: object
properties:
meta_data:
type: object
properties:
match_id:
type: string
date:
type: string
format: date
round:
type: string
home_away:
type: string
team_name:
type: string
team_id:
type: string
opponent:
type: string
opponent_id:
type: string
stats:
type: object
description: Detailed match statistics for the player
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Player, league, or season not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/all-players-match-stats:
get:
summary: Retrieve match statistics for all players in a match
description: Get match-level player statistics for both teams in a specific match
parameters:
- name: match_id
in: query
description: 8-character match ID
required: true
schema:
type: string
minLength: 8
maxLength: 8
responses:
'200':
description: All players match statistics retrieved successfully
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
type: object
properties:
team_name:
type: string
home_away:
type: string
enum: [home, away]
players:
type: array
items:
type: object
properties:
meta_data:
type: object
properties:
player_id:
type: string
player_name:
type: string
player_country_code:
type: string
player_number:
type: string
age:
type: string
stats:
type: object
description: Detailed player match statistics
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Match not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment