sportmonks 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/sportmonks.rb +231 -0
- data/lib/sportmonks/api.rb +21 -0
- metadata +59 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 822d0a1e8394f523f2ea40d09d5570c065985b91d49aa39e4155f25bd60b43e5
|
|
4
|
+
data.tar.gz: f193040bd83615026ed836bdbf3f8abab11d36df7c9a0806571a3e9da1d8f19e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f2d64bb7a1e60012ada901112e35a15135cf7419b5427cca9167785b10aa864a01b70e09aa751bdad6118786ebd6e4210047adc6c38c694e917996a6346ffa79
|
|
7
|
+
data.tar.gz: dbfac76e5f90f420ed82fe736c274ef684ab1f308bd90d3917582fb2f3b56dfbdf15846b62f741ddd211a14732e1e8463f7f7a88b53f4320d67c74ecd5ca6836
|
data/lib/sportmonks.rb
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
module Sportmonks
|
|
2
|
+
class << self
|
|
3
|
+
attr_accessor :configuration
|
|
4
|
+
|
|
5
|
+
def configure
|
|
6
|
+
self.configuration ||= Configuration.new
|
|
7
|
+
yield(configuration)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def continents(options = {})
|
|
11
|
+
Sportmonks::Api.api_get("/continents", options)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def continent(id, options = {})
|
|
15
|
+
Sportmonks::Api.api_get("/continents/#{id}", options)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def countries(options = {})
|
|
19
|
+
Sportmonks::Api.api_get("/countries", options)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def country(id, options = {})
|
|
23
|
+
Sportmonks::Api.api_get("/countries/#{id}", options)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def leagues(options = {})
|
|
27
|
+
Sportmonks::Api.api_get("/leagues", options)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def league(id, options = {})
|
|
31
|
+
Sportmonks::Api.api_get("/leagues/#{id}", options)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def seasons(options = {})
|
|
35
|
+
Sportmonks::Api.api_get("/seasons", options)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def season(id, options = {})
|
|
39
|
+
Sportmonks::Api.api_get("/seasons/#{id}", options)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def fixture(id, options = {})
|
|
43
|
+
Sportmonks::Api.api_get("/fixtures/#{id}", options)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def fixtures(ids, options = {})
|
|
47
|
+
ids_param = ids.join(",")
|
|
48
|
+
Sportmonks::Api.api_get("/fixtures/multi/#{ids_param}", options)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def fixtures_by_date(date, options = {})
|
|
52
|
+
date_str = format_date(date)
|
|
53
|
+
Sportmonks::Api.api_get("/fixtures/date/#{date_str}", options)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def fixtures_between(from, to, league_ids = [], options = {})
|
|
57
|
+
from_str = format_date(from)
|
|
58
|
+
to_str = format_date(to)
|
|
59
|
+
leagues_param = format_league_ids(league_ids)
|
|
60
|
+
|
|
61
|
+
if leagues_param
|
|
62
|
+
Sportmonks::Api.api_get(
|
|
63
|
+
"/fixtures/between/#{from_str}/#{to_str}",
|
|
64
|
+
options.merge({leagues: leagues_param})
|
|
65
|
+
)
|
|
66
|
+
else
|
|
67
|
+
Sportmonks::Api.api_get("/fixtures/between/#{from_str}/#{to_str}", options)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def fixtures_between_by_team(from, to, team_id, league_ids = [], options = {})
|
|
72
|
+
from_str = format_date(from)
|
|
73
|
+
to_str = format_date(to)
|
|
74
|
+
leagues_param = format_league_ids(league_ids)
|
|
75
|
+
|
|
76
|
+
if leagues_param
|
|
77
|
+
Sportmonks::Api.api_get(
|
|
78
|
+
"/fixtures/between/#{from_str}/#{to_str}/#{team_id}",
|
|
79
|
+
options.merge({leagues: leagues_param})
|
|
80
|
+
)
|
|
81
|
+
else
|
|
82
|
+
Sportmonks::Api.api_get("/fixtures/between/#{from_str}/#{to_str}/#{team_id}", options)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def stages_by_season(season_id, options = {})
|
|
87
|
+
Sportmonks::Api.api_get("/stages/season/#{season_id}", options)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def stages(id, options = {})
|
|
91
|
+
Sportmonks::Api.api_get("/stages/#{id}", options)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def live_scores(league_ids = [], options = {})
|
|
95
|
+
leagues_param = format_league_ids(league_ids)
|
|
96
|
+
|
|
97
|
+
if leagues_param
|
|
98
|
+
Sportmonks::Api.api_get("/livescores", options.merge({leagues: leagues_param}))
|
|
99
|
+
else
|
|
100
|
+
Sportmonks::Api.api_get("/livescores", options)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def live_scores_in_play(league_ids = [], options = {})
|
|
105
|
+
leagues_param = format_league_ids(league_ids)
|
|
106
|
+
|
|
107
|
+
if leagues_param
|
|
108
|
+
Sportmonks::Api.api_get("/livescores/now", options.merge({leagues: leagues_param}))
|
|
109
|
+
else
|
|
110
|
+
Sportmonks::Api.api_get("/livescores/now", options)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def commentaries_by_fixture(fixture_id, options = {})
|
|
115
|
+
Sportmonks::Api.api_get("/commentaries/fixture/#{fixture_id}", options)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def highlights(options = {})
|
|
119
|
+
Sportmonks::Api.api_get("/highlights", options)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def head_2_head(team1_id, team2_id, options = {})
|
|
123
|
+
Sportmonks::Api.api_get("/head2head/#{team1_id}/#{team2_id}", options)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def tv_stations_by_fixture(fixture_id, options = {})
|
|
127
|
+
Sportmonks::Api.api_get("/tvstations/fixture/#{fixture_id}", options)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def standings_by_season(season_id, options = {})
|
|
131
|
+
Sportmonks::Api.api_get("/standings/season/#{season_id}", options)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def team(id, options = {})
|
|
135
|
+
Sportmonks::Api.api_get("/teams/#{id}", options)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def teams_by_season(season_id, options = {})
|
|
139
|
+
Sportmonks::Api.api_get("/teams/season/#{season_id}", options)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def top_scorer_by_season(season_id, options = {})
|
|
143
|
+
Sportmonks::Api.api_get("/topscorers/season/#{season_id}", options)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def aggregated_top_scorer_by_season(season_id, options = {})
|
|
147
|
+
Sportmonks::Api.api_get("/topscorers/season/#{season_id}/aggregated", options)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def venue(id, options = {})
|
|
151
|
+
Sportmonks::Api.api_get("/venues/#{id}", options)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def venues_by_season(season_id, options = {})
|
|
155
|
+
Sportmonks::Api.api_get("/venues/season/#{season_id}", options)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def round(id)
|
|
159
|
+
Sportmonks::Api.api_get("/rounds/#{id}")
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def rounds_by_season(season_id, options = {})
|
|
163
|
+
Sportmonks::Api.api_get("/rounds/season/#{season_id}", options)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def odds_by_fixure_and_bookmaker(fixture_id, bookmaker_id, options = {})
|
|
167
|
+
Sportmonks::Api.api_get("odds/fixture/#{fixture_id}/bookmaker/#{bookmaker_id}", options)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def odds_by_fixure(fixture_id, options = {})
|
|
171
|
+
Sportmonks::Api.api_get("odds/fixture/#{fixture_id}", options)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def odds_by_fixure_and_market(fixture_id, market_id, options = {})
|
|
175
|
+
Sportmonks::Api.api_get("odds/fixture/#{fixture_id}/market/#{market_id}", options)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def bookmakers(options = {})
|
|
179
|
+
Sportmonks::Api.api_get("bookmakers", options)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def bookmaker(bookmaker_id, options = {})
|
|
183
|
+
Sportmonks::Api.api_get("bookmakers/#{bookmaker_id}", options)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def markets(options = {})
|
|
187
|
+
Sportmonks::Api.api_get("markets", options)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def market(market_id, options = {})
|
|
191
|
+
Sportmonks::Api.api_get("markets/#{market_id}", options)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# notice that this api is for bet365 only
|
|
195
|
+
def in_play_odds_by_fixure(fixture_id, options = {})
|
|
196
|
+
Sportmonks::Api.api_get("odds/inplay/fixture/#{fixture_id}", options)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def player(player_id, options = {})
|
|
200
|
+
Sportmonks::Api.api_get("players/#{player_id}", options)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def squad_by_season_and_team(season_id, team_id, options = {})
|
|
204
|
+
Sportmonks::Api.api_get("squad/season/#{season_id}/team/#{team_id}", options)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def coach(coach_id, options = {})
|
|
208
|
+
Sportmonks::Api.api_get("coaches/#{coach_id}", options)
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
private
|
|
212
|
+
|
|
213
|
+
def format_date(date)
|
|
214
|
+
date.strftime("%Y-%m-%d")
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def format_league_ids(league_ids)
|
|
218
|
+
if league_ids.size > 0
|
|
219
|
+
league_ids.join(",")
|
|
220
|
+
else
|
|
221
|
+
nil
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
class Configuration
|
|
228
|
+
attr_accessor :api_token
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
require 'sportmonks/api'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
|
|
3
|
+
class Sportmonks::Api
|
|
4
|
+
include HTTParty
|
|
5
|
+
|
|
6
|
+
base_uri "https://soccer.sportmonks.com/api/v2.0"
|
|
7
|
+
|
|
8
|
+
def self.api_get(path, query_opts = {})
|
|
9
|
+
query_opts = query_opts.merge({api_token: Sportmonks.configuration.api_token})
|
|
10
|
+
resp = self.get(path, headers: headers(), query: query_opts)
|
|
11
|
+
if resp.success?
|
|
12
|
+
JSON.parse(resp.body)
|
|
13
|
+
else
|
|
14
|
+
resp
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.headers()
|
|
19
|
+
{'Content-Type' => 'application/json'}
|
|
20
|
+
end
|
|
21
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sportmonks
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Vũ Minh Tân
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-12-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: httparty
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.16'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.16'
|
|
27
|
+
description: A Ruby Client for Sportmonks Soccer API 2.0 at https://www.sportmonks.com/products/soccer/docs/2.0
|
|
28
|
+
email: tan@thekirinlab.com
|
|
29
|
+
executables: []
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files: []
|
|
32
|
+
files:
|
|
33
|
+
- lib/sportmonks.rb
|
|
34
|
+
- lib/sportmonks/api.rb
|
|
35
|
+
homepage: http://rubygems.org/gems/sportmonks
|
|
36
|
+
licenses:
|
|
37
|
+
- MIT
|
|
38
|
+
metadata: {}
|
|
39
|
+
post_install_message:
|
|
40
|
+
rdoc_options: []
|
|
41
|
+
require_paths:
|
|
42
|
+
- lib
|
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
53
|
+
requirements: []
|
|
54
|
+
rubyforge_project:
|
|
55
|
+
rubygems_version: 2.7.8
|
|
56
|
+
signing_key:
|
|
57
|
+
specification_version: 4
|
|
58
|
+
summary: A Ruby Client for Sportmonks Soccer API
|
|
59
|
+
test_files: []
|