All Projects → ali-sheiba → opta_sd

ali-sheiba / opta_sd

Licence: MIT license
OPTA Sports Data Soccer API Client (OPTA SDAPI)

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to opta sd

vmware-vra-gem
A Ruby Gem for interacting with the VMware vRealize Automation system
Stars: ✭ 16 (-42.86%)
Mutual labels:  ruby-gem
make model searchable
Adds simlpe search functionality to models
Stars: ✭ 27 (-3.57%)
Mutual labels:  ruby-gem
nhl-twitter-bot
🚨 Hockey Game Bot is a Python application that sends important NHL events to social media platforms in (near) real time.
Stars: ✭ 18 (-35.71%)
Mutual labels:  sports
ethereal-jekyll-theme
A Jekyll version of the "Ethereal" theme by HTML5 UP.
Stars: ✭ 13 (-53.57%)
Mutual labels:  ruby-gem
has placeholder image
A Ruby gem for generating string based placeholder images in Rails.
Stars: ✭ 20 (-28.57%)
Mutual labels:  ruby-gem
busser
Kitchen Busser - Runs tests for projects in test-kitchen
Stars: ✭ 47 (+67.86%)
Mutual labels:  ruby-gem
highlights-jekyll-theme
A Jekyll version of the "Highlights" theme by HTML5 UP.
Stars: ✭ 26 (-7.14%)
Mutual labels:  ruby-gem
parse-stack
Parse Server Ruby Client SDK
Stars: ✭ 59 (+110.71%)
Mutual labels:  ruby-gem
openrowingmonitor
A free and open source performance monitor for rowing machines
Stars: ✭ 29 (+3.57%)
Mutual labels:  sports
ruby attic
💍 Unmaintained ruby projects needing people!
Stars: ✭ 26 (-7.14%)
Mutual labels:  ruby-gem
dewdle
A remote video-feed drawing tool (telestrator) for streaming and broadcast environments.
Stars: ✭ 29 (+3.57%)
Mutual labels:  sports
space-invaders
👾 Space Invaders 2d game with Ruby/Gosu
Stars: ✭ 16 (-42.86%)
Mutual labels:  ruby-gem
secrets cli
CLI for storing and reading your secrets via vault
Stars: ✭ 24 (-14.29%)
Mutual labels:  ruby-gem
multi-tenancy-devise
mtdevise adds basecamp style user logins to your ruby on rails application.
Stars: ✭ 27 (-3.57%)
Mutual labels:  ruby-gem
mobility-actiontext
Translate Rails Action Text rich text with Mobility.
Stars: ✭ 27 (-3.57%)
Mutual labels:  ruby-gem
sideroo
Declarative, auditable, object-oriented key management Ruby gem for Redis
Stars: ✭ 13 (-53.57%)
Mutual labels:  ruby-gem
lazylead
Eliminate the annoying work within ticketing systems (Jira, GitHub, Trello). Allows automating (without admin access) daily actions like tickets fields verification, email notifications by JQL/GQL, meeting requests to your (or teammates) calendar.
Stars: ✭ 42 (+50%)
Mutual labels:  ruby-gem
instagram graph api
This is a version of koala gem which provides commonly used Instagram Graph APIs
Stars: ✭ 28 (+0%)
Mutual labels:  ruby-gem
jsonapi-serializer-formats
💎 Gem to enrich jsonapi-serializer with multiple formats
Stars: ✭ 20 (-28.57%)
Mutual labels:  ruby-gem
detectify
Detectify is a gem for multi-tenant Rack apps, to help you retrieve domain and subdomain-related data from a database.
Stars: ✭ 79 (+182.14%)
Mutual labels:  ruby-gem

OPTA Sports Data Soccer API (OPTA SDAPI)

Ruby Gem Build Status

Ruby API Client for OPTA SDAPI (Sports Data Soccer API)

WARNING: This project is not maintained anymore.

Installation

Add this line to your application's Gemfile:

gem 'opta_sd'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install opta_sd

Using Guide

This Gem is just a class builder for the APIs, every api have a Class for it, and for every api's parameters there are methods to build them, and those parameter methods are explained down below for each Class.

Available Classes :

Available Feeds Class API End Point
Fixtures and Results Match /soccerdata/match/...
Match Statistics MatchStatistics /soccerdata/matchstats/...
Match Events MatchEvent /soccerdata/matchevent/...
Pass Matrix and Average Formation PassMatrix /soccerdata/passmatrix/...
Possession Possession /soccerdata/possession/...
Commentary Commentary /soccerdata/Commentary/...
Match Facts MatchFacts /soccerdata/matchfacts/...
Seasonal Stats SeasonalStats /soccerdata/seasonstats/...
Squads Squads /soccerdata/squads/...
Team Standings TeamStandings /soccerdata/standings/...
Player Career PlayerCareer /soccerdata/playercareer/...
Tournament Calendars TournamentCalendar /soccerdata/tournamentcalendar/...
Match Preview MatchPreview /soccerdata/matchpreview/...
Rankings Rankings /soccerdata/rankings/...
Tournament Schedule TournamentSchedule /soccerdata/tournamentschedule/...
Venues Venues /soccerdata/venues/...

Parameter Methods :

Parameters are changed in this gem to be more readable, and will be transulated to Opta keys in the backend.

There are two types of parameters, core parameters that can be used in all apis, and api parameters those are specific for each api.

Core Parameters are have _ prefix, and they are:

Method Actual Parameter
_rt _rt
_format _fmt
_locale _lcl
_callback _clbk
_sort _ordSrt
_page_size _pgSz
_page_number _pgNm

Example of using core parameters

OptaSD::Soccer::Match.new.competition('722fdbecxzcq9788l6jqclzlw').time_range(Time.now - 86400, Time.now + 86400)

Response Format

OPTA SD provides the response in json and xml format, you can use _format method to define the required response format, json is the default.

JSON response will be Parsed by JSON.parse and XML will be parsed by nokogiri gem. you can override parse_xml method from Core Class in case you need to change the behaviour.

The Final Call

After building the required parameters, you will call get method at the end of the chain to build the request and pull the data. after that you can retrieve the response by calling data.

Example:

# Build the request hit the api
match = OptaSD::Soccer::Match.new.resource('bsu6pjne1eqz2hs8r3685vbhl').live.lineups.get

# retrieve the response data
match.data['match']

Use this Gem with Rails

To be able to use this gem with your own key, you need to create a opta_sd.yml in config dir and override config_file method from Core Class to read the opta_sd.yml from your app directory.

# config/opta_sd.yml
opta_domain:     'http://api.performfeeds.com'
opta_auth_token: 'YOUR-OWN-KEY'
# config/initializers/opta_sd.rb
class OptaSD::Core
  def config_file
    YAML::load(File.open(Rails.root.join('config/opta_sd.yml')))
  end
end

APIS

Sports Data Soccer API guide

http://api.performfeeds.com/soccerdata/match/sdapidocumentation?_docu

1. Fixtures and Results

Examples:

# Get Match details with live and lineups
OptaSD::Soccer::Match.new.resource('bsu6pjne1eqz2hs8r3685vbhl').live.lineups.get

# Using Old OPTA Core Match ID
OptaSD::Soccer::Match.new.fixture('urn:perform:optacore:fixture:2366080').live.lineups.get

# Get competition matches between two time stamps
OptaSD::Soccer::Match.new.competition('722fdbecxzcq9788l6jqclzlw').time_range(Time.now - 86400, Time.now + 86400).get

Available Parameters:

  • resource(match_id)
  • fixture(match_id)
  • tournament(tournament_id)
  • stage(stage_id)
  • competition(competition_id)
  • contestant(contestant_id)
  • live(ture/false) by default will pass true
  • lineups(ture/false) by default will pass true
  • status(status) statuses : (all - fixture - played - playing - cancelled - postponed - suspended)
  • time_range(from, to) from and to should be a valid Time, like Time.now

2. Match Statistics

# Get Statistics Of Match
OptaSD::Soccer::MatchStatistics.new.resource('bsu6pjne1eqz2hs8r3685vbhl').get

# Get Statistics Of Match with more details
OptaSD::Soccer::MatchStatistics.new.fixture('bsu6pjne1eqz2hs8r3685vbhl').detailed.get

Available Parameters:

  • resource(match_id)
  • fixture(match_id)
  • detailed(ture/false) by default will pass true

3. Match Events

# Get Match Events
OptaSD::Soccer::MatchEvent.new.fixture('bsu6pjne1eqz2hs8r3685vbhl').get

Available Parameters:

  • resource(match_id)
  • fixture(match_id)

4. Pass Matrix and Average Formation

# Get Match Matrix
OptaSD::Soccer::PassMatrix.new.fixture('bsu6pjne1eqz2hs8r3685vbhl').get

Available Parameters:

  • resource(match_id)
  • fixture(match_id)

5. Possession

# Get Possession Throughout A Match
OptaSD::Soccer::Possession.new.fixture('bsu6pjne1eqz2hs8r3685vbhl').get

Available Parameters:

  • resource(match_id)
  • fixture(match_id)

6. Commentary

# Get Match Commentary
OptaSD::Soccer::Commentary.new.fixture('bsu6pjne1eqz2hs8r3685vbhl').get

# Get Match Commentary with type
OptaSD::Soccer::Commentary.new.fixture('bsu6pjne1eqz2hs8r3685vbhl').type('auto').get
# Or
OptaSD::Soccer::Commentary.new.fixture('bsu6pjne1eqz2hs8r3685vbhl').auto.get

Available Parameters:

  • resource(match_id)
  • fixture(match_id)
  • type(type) types are : auto - fallback - manual
  • auto
  • fallback
  • manual

7. Match Facts

# Get Match Facts
OptaSD::Soccer::MatchFacts.new.fixture('bsu6pjne1eqz2hs8r3685vbhl').get

Available Parameters:

  • resource(match_id)
  • fixture(match_id)

8. Seasonal Stats

# Get Seasonal Stats by Competition Contestants
OptaSD::Soccer::SeasonalStats.new.competition('722fdbecxzcq9788l6jqclzlw').contestant('884uzyf1wosc7ykji6e18gifp').get

# Get Seasonal Stats by Tournament Contestants
OptaSD::Soccer::SeasonalStats.new.tournament('408bfjw6uz5k19zk4am50ykmh').contestant('884uzyf1wosc7ykji6e18gifp').get

Available Parameters:

  • competition(competition_id)
  • tournament(tournament_id)
  • contestant(contestant_id)

9. Squads

# Get Squads By Tournament
OptaSD::Soccer::Squads.new.tournament('408bfjw6uz5k19zk4am50ykmh').get

# Get Squads By Contestant
OptaSD::Soccer::Squads.new.contestant('884uzyf1wosc7ykji6e18gifp').get

# Get Detailed Squads
OptaSD::Soccer::Squads.new.tournament('408bfjw6uz5k19zk4am50ykmh').detailed.get

# Get People Squads
OptaSD::Soccer::Squads.new.tournament('408bfjw6uz5k19zk4am50ykmh').people.get

Available Parameters:

  • tournament(tournament_id)
  • contestant(contestant_id)
  • detailed(ture/false)
  • people(ture/false)

10. Team Standings

# Get Team Standings By Tournament
OptaSD::Soccer::TeamStandings.new.tournament('408bfjw6uz5k19zk4am50ykmh').get

# Get Team Standings By Tournament And Stage
OptaSD::Soccer::TeamStandings.new.tournament('408bfjw6uz5k19zk4am50ykmh').stage('123').get

# Get Team Standings With Live Data
OptaSD::Soccer::TeamStandings.new.tournament('408bfjw6uz5k19zk4am50ykmh').live.get

# Get Team Standings By Type
OptaSD::Soccer::TeamStandings.new.tournament('408bfjw6uz5k19zk4am50ykmh').type('total').get
OptaSD::Soccer::TeamStandings.new.tournament('408bfjw6uz5k19zk4am50ykmh').total.get

Available Parameters:

  • stage(stage_id)
  • tournament(tournament_id)
  • type(type) types are : total - home - away - form-total - form-home - form-away
  • live(ture/false)
  • total
  • home
  • away
  • form_total
  • form_home
  • form_away

11. Player Career

# Get Player Career By Person ID
OptaSD::Soccer::PlayerCareer.new.resource('1c4gmhsc0mfjl2or3oxggg6hh').get
OptaSD::Soccer::PlayerCareer.new.person('1c4gmhsc0mfjl2or3oxggg6hh').get

# Get Players Career By Contestant ID
OptaSD::Soccer::PlayerCareer.new.contestant('apoawtpvac4zqlancmvw4nk4o').get

# Get Players Career By Contestant ID and Active on In-Active
OptaSD::Soccer::PlayerCareer.new.contestant('apoawtpvac4zqlancmvw4nk4o').active.get
OptaSD::Soccer::PlayerCareer.new.contestant('apoawtpvac4zqlancmvw4nk4o').active(false).get

Available Parameters:

  • resource(person_id)
  • person(person_id)
  • contestant(contestant_id)
  • active(ture/false)

12. Tournament Calendars

# Get All Competitions With All Tournaments
OptaSD::Soccer::TournamentCalendar.new.get

# Get Tournaments Of Competitions
OptaSD::Soccer::TournamentCalendar.new.competition('722fdbecxzcq9788l6jqclzlw').get

# Get All Competitions With Only Active Tournaments
OptaSD::Soccer::TournamentCalendar.new.active.get

# Get Only Authorized Competitions With Only Active Tournaments
OptaSD::Soccer::TournamentCalendar.new.active.authorized.get

Available Parameters:

  • competition(competition_id)
  • active
  • authorized

13. Match Preview

# Get Preview of Match
OptaSD::Soccer::MatchPreview.new.fixture('bsu6pjne1eqz2hs8r3685vbhl').get

Available Parameters:

  • resource(match_id)
  • fixture(match_id)

14. Rankings

# Get Tournament Rankings
OptaSD::Soccer::Rankings.new.resource('408bfjw6uz5k19zk4am50ykmh').get
OptaSD::Soccer::Rankings.new.tournament('408bfjw6uz5k19zk4am50ykmh').get

Available Parameters:

  • resource(tournament_id)
  • tournament(tournament_id)

15. Tournament Schedule

# Get Tournament Schedule
OptaSD::Soccer::TournamentSchedule.new.resource('408bfjw6uz5k19zk4am50ykmh').get
OptaSD::Soccer::TournamentSchedule.new.tournament('408bfjw6uz5k19zk4am50ykmh').get

Available Parameters:

  • resource(tournament_id)
  • tournament(tournament_id)

16. Venues

# Get Venues
OptaSD::Soccer::Venues.new.venue('bdkmbkf8yi951wrjraknp9wad').get
OptaSD::Soccer::Venues.new.tournament('9xjsbe05up1jqycf7no90as4p').get
OptaSD::Soccer::Venues.new.contestant('c8h9bw1l82s06h77xxrelzhur').get

Available Parameters:

  • venue(venue_id)
  • tournament(tournament_id)
  • contestant(contestant_id)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].