Skip to content

radkomih/football_api

Repository files navigation

FootballApi

A Ruby interface to the www.api-football.com API v2.3.9 (current).

Installation

Add this line to your application's Gemfile:

gem 'football_api'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install football_api

Configuration

FootballApi.configure do |config|
  config.api_host = 'https://www.api-football.com/demo/v2'
  config.api_key = 'XXXXXXXXXXXXXXXXXXXXXXXXX'
end

Usage

Status

This endpoint does not require any parameters

FootballApi::Status.info


Timezones

This endpoint does not require any parameters

FootballApi::Timezone.all


Seasons

This endpoint does not require any parameters

FootballApi::Season.all


Contries

This endpoint does not require any parameters

FootballApi::Country.all


Leagues

Parameter Type Required Description
league_id integer false Fails if field contains anything other than an integer
team_id integer false Fails if field contains anything other than an integer
search string false 3 characters minimum
country string false Fails if field contains anything other than alpha-numeric characters, underscores or dashes
code string false 2 characters
season integer false Fails if field contains anything other than an integer [YYYY]
current string false Fails if field has anything other than alphabetic characters
type string false Fails if field has anything other than alphabetic characters
FootballApi::League.find
FootballApi::League.all
FootballApi::League.all_by_team
FootballApi::League.all_by_team_and_season
FootballApi::League.search
FootballApi::League.all_by_country
FootballApi::League.all_by_country_and_season
FootballApi::League.all_by_code
FootballApi::League.all_by_code_and_season
FootballApi::League.all_by_season
FootballApi::League.all_seasons_by_league
FootballApi::League.all_by_league_and_season
FootballApi::League.all_current
FootballApi::League.all_current_by_country
FootballApi::League.all_by_type
FootballApi::League.all_by_type_and_country
FootballApi::League.all_by_type_and_country_and_season
FootballApi::League.all_by_type_and_season

Teams

Parameter Type Required Description
team_id integer false Fails if field contains anything other than an integer
league_id integer false Fails if field contains anything other than an integer
search string false 3 characters minimum
FootballApi::Teams::Data.find
FootballApi::Teams::Data.all_by_league
FootballApi::Teams::Data.search

Team Statistics

Parameter Type Required Description
league_id integer true Fails if field contains anything other than an integer
team_id integer true Fails if field contains anything other than an integer
date string false Fails if field does not contain a valid date : [YYYY-MM-DD]
FootballApi::Teams::Statistic.all_by_league_and_team
FootballApi::Teams::Statistic.all_by_league_and_team_and_date

Standings

Parameter Type Required Description
league_id integer true Fails if field contains anything other than an integer
FootballApi::Standing.all_by_league

Rounds

FootballApi::Fixtures::Round.all_by_league
FootballApi::Fixtures::Round.all_by_league_and_current

Fixtures

FootballApi::Fixtures::Fixture.find
FootballApi::Fixtures::Fixture.all_live
FootballApi::Fixtures::Fixture.all_live_and_several_leagues
FootballApi::Fixtures::Fixture.all_by_date
FootballApi::Fixtures::Fixture.all_by_league
FootballApi::Fixtures::Fixture.all_by_league_and_date
FootballApi::Fixtures::Fixture.all_by_league_and_round
FootballApi::Fixtures::Fixture.next_n_by_league
FootballApi::Fixtures::Fixture.last_n_by_league

H2h

FootballApi::Fixtures::H2h.all_by_team

Fixture Statistics

FootballApi::Fixtures::Statistic.all_by_fixture

Fixtures Events

FootballApi::Fixtures::Event.all_by_fixture

Fixtures Lineups

FootballApi::Fixtures::Lineup.all_by_fixture

Predictions

Parameter Type Required Description
fixture_id integer true Fails if field contains anything other than an integer
FootballApi::Prediction.all_by_fixture

Coachs

Parameter Type Required Description
coach_id integer false Fails if field contains anything other than an integer
team_id integer false Fails if field contains anything other than an integer
search string false 3 characters minimum
FootballApi::Coach.find
FootballApi::Coach.all_by_team
FootballApi::Coach.search

Players Seasons

FootballApi::Players::Season.all

Players Top Scorers

FootballApi::Players::TopScorer.all_by_league

Players Search

FootballApi::Players::Search.all_by_name

Players Squad

FootballApi::Players::Squad.all_by_team_and_season

Players Statistics Seasons

FootballApi::Players::StatisticsSeason.all_by_player
FootballApi::Players::StatisticsSeason.all_by_player_and_season
FootballApi::Players::StatisticsSeason.all_by_team_and_season

Players Statistics Fixtures

FootballApi::Players::StatisticsFixture.by_fixture

Transfers

Parameter Type Required Description
player integer false Fails if field contains anything other than an integer
team integer false Fails if field contains anything other than an integer
FootballApi::Transfer.all_by_player
FootballApi::Transfer.all_by_team

Trophies

Parameter Type Required Description
player integer true Fails if field contains anything other than an integer
coach integer true Fails if field contains anything other than an integer
FootballApi::Trophey.all_by_player
FootballApi::Trophey.all_by_coach

Sidelined

FootballApi::Sideline.all_by_player
FootballApi::Sideline.all_by_coach

Odds Bookmakers

FootballApi::Odds::Bookmaker.all
FootballApi::Odds::Bookmaker.find

Odds Labels

FootballApi::Odds::Label.all
FootballApi::Odds::Label.find

Odds Mapping

FootballApi::Odds::Mapping.all

Odds

Parameter Type Required Description
fixture_id integer false Fails if field contains anything other than an integer
league_id integer false Fails if field contains anything other than an integer
date string false Fails if field does not contain a valid date : [YYYY-MM-DD]
page integer false Fails if field contains anything other than an integer
bookmaker_id integer false Fails if field contains anything other than an integer
label_id integer false Fails if field contains anything other than an integer
timezone string false Fails if field is not a result of the endpoint timezone
FootballApi::Odds::Odd.all_by_fixture
FootballApi::Odds::Odd.all_by_date
FootballApi::Odds::Odd.all_by_date_and_bookmaker
FootballApi::Odds::Odd.all_by_fixture_and_bookmaker
FootballApi::Odds::Odd.all_by_fixture_and_label
FootballApi::Odds::Odd.all_by_league
FootballApi::Odds::Odd.all_by_league_and_bookmaker
FootballApi::Odds::Odd.all_by_league_and_label

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/radkomih/football_api.