An unofficial Ruby wrapper for the FotMob API. Get football/soccer data including team stats, match details, player information, and league standings.
- 🏆 Team Data - Get comprehensive team information and statistics
- ⚽ Match Details - Detailed match information and live scores
- 👤 Player Stats - Player profiles and performance data
- 📊 League Standings - League tables and competition data
- 🛡️ Error Handling - Custom error classes for different scenarios
- ⏱️ Timeout Support - Configurable request timeouts
- 📝 Well Documented - YARD documentation included
Add to your Gemfile:
gem 'fotmob'Or install directly:
gem install fotmobrequire 'fotmob'
# Create a client
client = Fotmob.new
# Get team information
team = client.get_team("8540") # Palermo
puts team[:details][:name]
# Get match details
match = client.get_match_details("4193741")
puts "#{match[:general][:homeTeam][:name]} vs #{match[:general][:awayTeam][:name]}"
# Get player data
player = client.get_player("961995") # Mbappé
puts player[:name]
# Get league standings
league = client.get_league("47") # Premier League
puts league[:details][:name]Get comprehensive team information.
team = client.get_team("8540")
# Returns: Hash with team details, fixtures, squad, etc.Get detailed match information.
match = client.get_match_details("4193741")
# Returns: Hash with match details, lineups, events, statsGet player profile and statistics.
player = client.get_player("961995")
# Returns: Hash with player info and statsGet league/competition information.
league = client.get_league("47")
# Returns: Hash with league details and standingsNote: This endpoint currently requires special authentication headers and may not work reliably.
matches = client.get_matches("20250114")
# Returns: Hash with matches for the specified date# Default timeout is 10 seconds
client = Fotmob.new(timeout: 30)The gem includes custom error classes for different scenarios:
begin
team = client.get_team("invalid_id")
rescue Fotmob::NotFoundError => e
puts "Team not found: #{e.message}"
rescue Fotmob::RateLimitError => e
puts "Rate limit exceeded: #{e.message}"
rescue Fotmob::TimeoutError => e
puts "Request timed out: #{e.message}"
rescue Fotmob::APIError => e
puts "API error: #{e.message} (Status: #{e.status_code})"
rescue Fotmob::Error => e
puts "Error: #{e.message}"
endFotmob::Error- Base error classFotmob::APIError- API returned an error responseFotmob::NotFoundError- Resource not found (404)Fotmob::RateLimitError- Rate limit exceeded (429)Fotmob::TimeoutError- Request timed outFotmob::InvalidResponseError- Invalid JSON response
# Clone the repository
git clone https://github.com/bjrsti/fotmob.git
cd fotmob
# Install dependencies
bundle install
# Run tests
bundle exec rspec
# Run linter
bundle exec rubocop
# Open console
bundle exec rake consoleThe gem uses RSpec for testing with VCR for recording API responses:
bundle exec rspec- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a Pull Request
To use the API, you need IDs for teams, players, matches, and leagues:
- Teams: Visit fotmob.com, search for a team, the ID is in the URL
- Example:
fotmob.com/teams/8540/overview/palermo→ Team ID:8540
- Example:
- Players: Search for a player, ID is in the URL
- Example:
fotmob.com/players/961995/kylian-mbappe→ Player ID:961995
- Example:
- Matches: Browse matches, ID is in the match URL
- Example:
fotmob.com/match/4193741→ Match ID:4193741
- Example:
- Leagues: Browse leagues, ID is in the league URL
- Example:
fotmob.com/leagues/47/overview/premier-league→ League ID:47
- Example:
This is an unofficial API wrapper and is not affiliated with FotMob. Use at your own risk and be mindful of rate limits.
MIT License. See LICENSE for details.