sportradar-api 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/.env.sample +33 -0
- data/.gitignore +20 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +102 -0
- data/README.md +74 -0
- data/Rakefile +10 -0
- data/bin/console +13 -0
- data/bin/setup +8 -0
- data/lib/sportradar/api.rb +60 -0
- data/lib/sportradar/api/config.rb +35 -0
- data/lib/sportradar/api/error.rb +23 -0
- data/lib/sportradar/api/nfl.rb +96 -0
- data/lib/sportradar/api/request.rb +41 -0
- data/lib/sportradar/api/soccer.rb +83 -0
- data/lib/sportradar/api/version.rb +5 -0
- data/sportradar-api.gemspec +43 -0
- metadata +245 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 1375039806670a04b628f8bacb62b2022cb83584
|
|
4
|
+
data.tar.gz: 806f1fac9a3328443eb81b917a9e338b07a98718
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ff799d3f643fc2bbde17e2971e9299089dad60648d019c8d6b90ddb94f779b40f88f34db33d742bc7c8c1063d3d3e420f4299ef91f63db5ad735912c817ae8fb
|
|
7
|
+
data.tar.gz: 91dbb9c76739a8d233034a0777c2d943540a9b72924bc903b60f31fd0f29a0a2ff4f8273b5010d69175a1e53e0feb1e6149b06b4c84987a76cc5b79ecfa8b0d9
|
data/.env.sample
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
SPORTRADAR_CRICKET: your-cricket-api-key
|
|
2
|
+
SPORTRADAR_ESPORTS_CSGO: your-esports_csgo-api-key
|
|
3
|
+
SPORTRADAR_GOLF: your-golf-api-key
|
|
4
|
+
SPORTRADAR_MLB: your-mlb-api-key
|
|
5
|
+
SPORTRADAR_MMA: your-mma-api-key
|
|
6
|
+
SPORTRADAR_NASCAR: your-nascar-api-key
|
|
7
|
+
SPORTRADAR_NBA: your-nba-api-key
|
|
8
|
+
SPORTRADAR_NCAAF: your-ncaaf-api-key
|
|
9
|
+
SPORTRADAR_NCAAMB: your-ncaamb-api-key
|
|
10
|
+
SPORTRADAR_NCAAWB: your-ncaawb-api-key
|
|
11
|
+
SPORTRADAR_NFL: your-nfl-api-key
|
|
12
|
+
SPORTRADAR_NHL: your-nhl-api-key
|
|
13
|
+
SPORTRADAR_NPB: your-npb-api-key
|
|
14
|
+
SPORTRADAR_RUGBY: your-rugby-api-key
|
|
15
|
+
SPORTRADAR_SOCCER_AF: your-soccer_africa-api-key
|
|
16
|
+
SPORTRADAR_SOCCER_AS: your-soccer_asia-api-key
|
|
17
|
+
SPORTRADAR_SOCCER_EU: your-soccer_europe-api-key
|
|
18
|
+
SPORTRADAR_SOCCER_NA: your-soccer_north-america-api-key
|
|
19
|
+
SPORTRADAR_SOCCER_SA: your-soccer_south-america-api-key
|
|
20
|
+
SPORTRADAR_SOCCER_WC: your-soccer_world-cup-api-key
|
|
21
|
+
SPORTRADAR_TENNIS: your-tennis-api-key
|
|
22
|
+
SPORTRADAR_WNBA: your-wnba-api-key
|
|
23
|
+
SPORTRADAR_IMAGES_NFL: your-images_nfl-api-key
|
|
24
|
+
SPORTRADAR_IMAGES_NBA: your-images_nba-api-key
|
|
25
|
+
SPORTRADAR_IMAGES_MLS: your-images_mls-api-key
|
|
26
|
+
SPORTRADAR_LIVE_IMAGES_NFL: your-live_images_nfl-api-key
|
|
27
|
+
SPORTRADAR_LIVE_IMAGES_NBA: your-live_images_nba-api-key
|
|
28
|
+
SPORTRADAR_LIVE_IMAGES_MLS: your-live_images_mls-api-key
|
|
29
|
+
SPORTRADAR_CONTENT_NBA_V2: your-content_nba_v2-api-key
|
|
30
|
+
SPORTRADAR_CONTENT_NFL_V2: your-content_nfl_v2-api-key
|
|
31
|
+
SPORTRADAR_CONTENT_NBA: your-content_nba-api-key
|
|
32
|
+
SPORTRADAR_CONTENT_NFL: your-content_nfl-api-key
|
|
33
|
+
SPORTRADAR_ODDS: your-odds-api-key
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
sportradar-api (0.1.0)
|
|
5
|
+
httparty (>= 0.13.3)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.4.0)
|
|
11
|
+
coderay (1.1.1)
|
|
12
|
+
coveralls (0.8.14)
|
|
13
|
+
json (>= 1.8, < 3)
|
|
14
|
+
simplecov (~> 0.12.0)
|
|
15
|
+
term-ansicolor (~> 1.3)
|
|
16
|
+
thor (~> 0.19.1)
|
|
17
|
+
tins (~> 1.6.0)
|
|
18
|
+
crack (0.4.3)
|
|
19
|
+
safe_yaml (~> 1.0.0)
|
|
20
|
+
docile (1.1.5)
|
|
21
|
+
dotenv (2.1.1)
|
|
22
|
+
ffi (1.9.14)
|
|
23
|
+
formatador (0.2.5)
|
|
24
|
+
guard (2.14.0)
|
|
25
|
+
formatador (>= 0.2.4)
|
|
26
|
+
listen (>= 2.7, < 4.0)
|
|
27
|
+
lumberjack (~> 1.0)
|
|
28
|
+
nenv (~> 0.1)
|
|
29
|
+
notiffany (~> 0.0)
|
|
30
|
+
pry (>= 0.9.12)
|
|
31
|
+
shellany (~> 0.0)
|
|
32
|
+
thor (>= 0.18.1)
|
|
33
|
+
guard-compat (1.2.1)
|
|
34
|
+
guard-minitest (2.4.5)
|
|
35
|
+
guard-compat (~> 1.2)
|
|
36
|
+
minitest (>= 3.0)
|
|
37
|
+
hashdiff (0.3.0)
|
|
38
|
+
httparty (0.13.7)
|
|
39
|
+
json (~> 1.8)
|
|
40
|
+
multi_xml (>= 0.5.2)
|
|
41
|
+
json (1.8.3)
|
|
42
|
+
listen (3.1.5)
|
|
43
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
44
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
|
45
|
+
ruby_dep (~> 1.2)
|
|
46
|
+
lumberjack (1.0.10)
|
|
47
|
+
method_source (0.8.2)
|
|
48
|
+
minitest (5.9.0)
|
|
49
|
+
minitest-focus (1.1.2)
|
|
50
|
+
minitest (>= 4, < 6)
|
|
51
|
+
multi_xml (0.5.5)
|
|
52
|
+
nenv (0.3.0)
|
|
53
|
+
notiffany (0.1.0)
|
|
54
|
+
nenv (~> 0.1)
|
|
55
|
+
shellany (~> 0.0)
|
|
56
|
+
pry (0.10.4)
|
|
57
|
+
coderay (~> 1.1.0)
|
|
58
|
+
method_source (~> 0.8.1)
|
|
59
|
+
slop (~> 3.4)
|
|
60
|
+
rake (10.5.0)
|
|
61
|
+
rb-fsevent (0.9.7)
|
|
62
|
+
rb-inotify (0.9.7)
|
|
63
|
+
ffi (>= 0.5.0)
|
|
64
|
+
ruby_dep (1.3.1)
|
|
65
|
+
safe_yaml (1.0.4)
|
|
66
|
+
shellany (0.0.1)
|
|
67
|
+
simplecov (0.12.0)
|
|
68
|
+
docile (~> 1.1.0)
|
|
69
|
+
json (>= 1.8, < 3)
|
|
70
|
+
simplecov-html (~> 0.10.0)
|
|
71
|
+
simplecov-html (0.10.0)
|
|
72
|
+
slop (3.6.0)
|
|
73
|
+
term-ansicolor (1.3.2)
|
|
74
|
+
tins (~> 1.0)
|
|
75
|
+
thor (0.19.1)
|
|
76
|
+
tins (1.6.0)
|
|
77
|
+
vcr (3.0.3)
|
|
78
|
+
webmock (2.1.0)
|
|
79
|
+
addressable (>= 2.3.6)
|
|
80
|
+
crack (>= 0.3.2)
|
|
81
|
+
hashdiff
|
|
82
|
+
|
|
83
|
+
PLATFORMS
|
|
84
|
+
ruby
|
|
85
|
+
|
|
86
|
+
DEPENDENCIES
|
|
87
|
+
bundler (~> 1.12)
|
|
88
|
+
coveralls
|
|
89
|
+
dotenv
|
|
90
|
+
guard
|
|
91
|
+
guard-minitest
|
|
92
|
+
minitest (~> 5.0)
|
|
93
|
+
minitest-focus
|
|
94
|
+
pry
|
|
95
|
+
rake (~> 10.0)
|
|
96
|
+
simplecov
|
|
97
|
+
sportradar-api!
|
|
98
|
+
vcr
|
|
99
|
+
webmock
|
|
100
|
+
|
|
101
|
+
BUNDLED WITH
|
|
102
|
+
1.12.5
|
data/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Sportradar API
|
|
2
|
+
|
|
3
|
+
The SportRadar API extensively covers league & sports data. This gem wraps it up, marshals the data into Ruby Objects we know and love.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Currently (July 2016) the SportRadar API has 23 documented APIs.
|
|
7
|
+
|
|
8
|
+
Our goal is to incrementally integrate with them. **Contributions are welcome**
|
|
9
|
+
|
|
10
|
+
## SportRadar APIs
|
|
11
|
+
|
|
12
|
+
[Current API Versions](http://developer.sportradar.us/api_gallery)
|
|
13
|
+
|
|
14
|
+
| API | Version | Docs | Implemented? | Priority |
|
|
15
|
+
| --- | --- | --- | --- | --- |
|
|
16
|
+
| NFL | 1 | [📚](http://developer.sportradar.us/page/NFL_Official) | - | 👍 |
|
|
17
|
+
| MLB | 5 | [📚](http://developer.sportradar.us/docs/MLB_API) | - | - |
|
|
18
|
+
| NHL | 3 | [📚](http://developer.sportradar.us/docs/NHL_API) | - | - |
|
|
19
|
+
| NBA | 3 | [📚](http://developer.sportradar.us/docs/NBA_API) | - | - |
|
|
20
|
+
| NCAAMB | 3 | [📚](http://developer.sportradar.us/docs/NCAA_Mens_Basketball) | - | - |
|
|
21
|
+
| NCAAFB | 1 | [📚](http://developer.sportradar.us/docs/NCAA_Football_API) | - | - |
|
|
22
|
+
| Golf | 2 | [📚](http://developer.sportradar.us/docs/Golf_API) | - | - |
|
|
23
|
+
| NASCAR | 3 | [📚](http://developer.sportradar.us/page/NASCAR_Official) | - | - |
|
|
24
|
+
| Odds | 1 | [📚](http://developer.sportradar.us/docs/Odds_API) | - | 👍 |
|
|
25
|
+
| Content | 3 | [📚](http://developer.sportradar.us/docs/Content_API) | - | 👍 |
|
|
26
|
+
| Images | 2 | [📚](http://developer.sportradar.us/docs/Images_API) | - | 👍 |
|
|
27
|
+
| Live Images | 1 | [📚](http://developer.sportradar.us/docs/Live_Images_API) | - | 👍 |
|
|
28
|
+
| Olympics | 2 | [📚](http://developer.sportradar.us/docs/Olympics_API_v2) | - | - |
|
|
29
|
+
| Soccer | 2 | [📚](http://developer.sportradar.us/docs/Soccer_API) | - | 👍 |
|
|
30
|
+
| NCAAWB | 3 | [📚](http://developer.sportradar.us/docs/read/NCAA_Womens_Basketball) | - | - |
|
|
31
|
+
| MMA | 1 | [📚](http://developer.sportradar.us/docs/MMA_API) | - | - |
|
|
32
|
+
| Cricket | 1 | [📚](http://developer.sportradar.us/docs/cricket_API) | - | - |
|
|
33
|
+
| WNBA | 3 | [📚](http://developer.sportradar.us/docs/WNBA_API) | - | - |
|
|
34
|
+
| NCAAMH | 3 | [📚](http://developer.sportradar.us/docs/read/NCAA_Mens_Hockey) | - | - |
|
|
35
|
+
| NPB | 1 | [📚](http://developer.sportradar.us/docs/NPB_API) | - | - |
|
|
36
|
+
| Rugby | 1 | [📚](http://developer.sportradar.us/docs/Rugby_API) | - | - |
|
|
37
|
+
| Tennis | 1 | [📚](http://developer.sportradar.us/docs/Tennis_API) | - | - |
|
|
38
|
+
| ESPORTS | 1 | [📚](http://developer.sportradar.us/docs/ESPORTS_API) | - | - |
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
Add this line to your application's Gemfile:
|
|
43
|
+
|
|
44
|
+
```ruby
|
|
45
|
+
gem 'sportradar-api'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
And then execute:
|
|
49
|
+
|
|
50
|
+
$ bundle
|
|
51
|
+
|
|
52
|
+
Or install it yourself as:
|
|
53
|
+
|
|
54
|
+
$ gem install sportradar-api
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
### Configuration
|
|
59
|
+
|
|
60
|
+
Manage your ruby environment through `.ruby-version` and `.ruby-gemset` files.
|
|
61
|
+
|
|
62
|
+
Create `.env` for environment variables. Follow the `.env.sample` for guidance.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## Development
|
|
66
|
+
|
|
67
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
68
|
+
|
|
69
|
+
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](https://rubygems.org).
|
|
70
|
+
|
|
71
|
+
## Contributing
|
|
72
|
+
|
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/beneggett/sportradar-api.
|
|
74
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
|
|
3
|
+
require "httparty"
|
|
4
|
+
|
|
5
|
+
require "sportradar/api/version"
|
|
6
|
+
|
|
7
|
+
require "sportradar/api/config"
|
|
8
|
+
require "sportradar/api/error"
|
|
9
|
+
require "sportradar/api/request"
|
|
10
|
+
|
|
11
|
+
require "sportradar/api/soccer"
|
|
12
|
+
require "sportradar/api/nfl"
|
|
13
|
+
|
|
14
|
+
module Sportradar
|
|
15
|
+
module Api
|
|
16
|
+
|
|
17
|
+
API_GALLERY = [
|
|
18
|
+
{api: :nfl, version: 1},
|
|
19
|
+
{api: :mlb, version: 5},
|
|
20
|
+
{api: :nhl, version: 3},
|
|
21
|
+
{api: :nba, version: 3},
|
|
22
|
+
{api: :ncaamb, version: 3},
|
|
23
|
+
{api: :ncaafb, version: 1},
|
|
24
|
+
{api: :golf, version: 2},
|
|
25
|
+
{api: :nascar, version: 3},
|
|
26
|
+
{api: :odds, version: 1},
|
|
27
|
+
{api: :content, version: 3},
|
|
28
|
+
{api: :images, version: 2},
|
|
29
|
+
{api: :live_images, version: 1},
|
|
30
|
+
{api: :olympics, version: 2},
|
|
31
|
+
{api: :soccer, version: 2},
|
|
32
|
+
{api: :ncaawb, version: 3},
|
|
33
|
+
{api: :mma, version: 1},
|
|
34
|
+
{api: :cricket, version: 1},
|
|
35
|
+
{api: :wnba, version: 3},
|
|
36
|
+
{api: :ncaamh, version: 3},
|
|
37
|
+
{api: :npb, version: 1},
|
|
38
|
+
{api: :rugby, version: 1},
|
|
39
|
+
{api: :tennis, version: 1},
|
|
40
|
+
{api: :esports, version: 1}
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def self.api_key_params(api)
|
|
47
|
+
{ api_key: self.api_key(api) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.api_key(api)
|
|
51
|
+
ENV.fetch("SPORTRADAR_#{api.to_s.upcase}", "api_key missing for #{api}")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.version(api)
|
|
55
|
+
find_api = API_GALLERY.find{ |x| x[:api] == api.downcase.to_sym }
|
|
56
|
+
!find_api.nil? ? find_api[:version] : "version missing for #{api}"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
class << self
|
|
4
|
+
attr_accessor :config
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.config
|
|
8
|
+
@config ||= Config.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Set options via block
|
|
12
|
+
def self.configure
|
|
13
|
+
yield(config) if block_given?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Config
|
|
17
|
+
attr_accessor :api_key, :api_timeout, :use_ssl, :format
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
@api_key = ENV['API_KEY']
|
|
21
|
+
@api_timeout = ENV.fetch('SPORTRADAR_API_TIMEOUT', 15 )
|
|
22
|
+
@use_ssl = ENV.fetch('SPORTRADAR_API_USE_SSL', true)
|
|
23
|
+
@format = ENV.fetch("SPORTRADAR_API_FORMAT", :xml).to_s
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def reset
|
|
27
|
+
self.api_key = ENV['API_KEY']
|
|
28
|
+
self.api_timeout = ENV.fetch('SPORTRADAR_API_TIMEOUT', 15 )
|
|
29
|
+
self.use_ssl = ENV.fetch('SPORTRADAR_API_USE_SSL', true)
|
|
30
|
+
self.format = ENV.fetch("SPORTRADAR_API_FORMAT", :xml).to_s
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
class Error
|
|
4
|
+
class AuthenticationError < StandardError; end
|
|
5
|
+
class NoApiKey < AuthenticationError; end
|
|
6
|
+
class InvalidResponseFormat < TypeError; end
|
|
7
|
+
class InvalidLeague < StandardError; end
|
|
8
|
+
class InvalidAccessLevel < StandardError; end
|
|
9
|
+
class InvalidSeason < StandardError; end
|
|
10
|
+
class Timeout < Timeout::Error ; end
|
|
11
|
+
class NoData < EOFError; end
|
|
12
|
+
|
|
13
|
+
attr_reader :message, :status_code, :status
|
|
14
|
+
|
|
15
|
+
def initialize(response_status, response_code, response_message = nil)
|
|
16
|
+
@status_code = response_code
|
|
17
|
+
@status = response_status
|
|
18
|
+
@message = response_message
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
class Nfl
|
|
4
|
+
attr_accessor :league, :access_level
|
|
5
|
+
def initialize( access_level = 'ot')
|
|
6
|
+
@league = 'nfl'
|
|
7
|
+
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
|
|
8
|
+
@access_level = access_level
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def league_hierarchy
|
|
12
|
+
results = Sportradar::Api::Request.new.get(request_url("league/hierarchy"), api_key )
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def schedule(year = Date.today.year, season = 'reg')
|
|
16
|
+
raise Sportradar::Api::Error::InvalidLeague unless allowed_seasons.include? season
|
|
17
|
+
results = Sportradar::Api::Request.new.get(request_url("games/#{ year }/#{ season }/schedule"), api_key )
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def weekly_schedule(year = Date.today.year, season = 'reg', week = 1)
|
|
21
|
+
results = Sportradar::Api::Request.new.get(request_url("games/#{ year }/#{ season }/#{ week }/schedule"), api_key )
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def standings(year = Date.today.year)
|
|
25
|
+
results = Sportradar::Api::Request.new.get(request_url("seasontd/#{ year }/standings"), api_key )
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def weekly_depth_charts(year = Date.today.year, season = 'reg', week = 1)
|
|
29
|
+
results = Sportradar::Api::Request.new.get(request_url("seasontd/#{ year }/#{ season }/#{ week }/depth_charts"), api_key )
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def weekly_injuries(year = Date.today.year, season = 'reg', week = 1)
|
|
33
|
+
results = Sportradar::Api::Request.new.get(request_url("seasontd/#{ year }/#{ season }/#{ week }/injuries"), api_key )
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def daily_change_log(date = Date.today)
|
|
37
|
+
results = Sportradar::Api::Request.new.get(request_url("league/#{ date.year }/#{ date.month }/#{ date.day }/changes"), api_key )
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# past_game_id = "0141a0a5-13e5-4b28-b19f-0c3923aaef6e"
|
|
41
|
+
# future_game_id = "28290722-4ceb-4a4c-a4e5-1f9bec7283b3"
|
|
42
|
+
def game_boxscore(game_id)
|
|
43
|
+
results = Sportradar::Api::Request.new.get(request_url("games/#{ game_id }/boxscore"), api_key )
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def game_roster(game_id)
|
|
47
|
+
results = Sportradar::Api::Request.new.get(request_url("games/#{ game_id }/roster"), api_key )
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def game_statistics(game_id)
|
|
51
|
+
results = Sportradar::Api::Request.new.get(request_url("games/#{ game_id }/statistics"), api_key )
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def play_by_play(game_id)
|
|
55
|
+
results = Sportradar::Api::Request.new.get(request_url("games/#{ game_id }/pbp"), api_key )
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# player_id = "ede260be-5ae6-4a06-887b-e4a130932705"
|
|
59
|
+
def player_profile(player_id)
|
|
60
|
+
results = Sportradar::Api::Request.new.get(request_url("players/#{ player_id }/profile"), api_key )
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# team_id = "97354895-8c77-4fd4-a860-32e62ea7382a"
|
|
64
|
+
def seasonal_statistics(team_id, year = Date.today.year, season = 'reg')
|
|
65
|
+
raise Sportradar::Api::Error::InvalidLeague unless allowed_seasons.include? season
|
|
66
|
+
results = Sportradar::Api::Request.new.get(request_url("seasontd/#{ year }/#{ season }/teams/#{ team_id }/statistics"), api_key )
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def team_profile(team_id)
|
|
70
|
+
results = Sportradar::Api::Request.new.get(request_url("teams/#{ team_id }/profile"), api_key )
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
def request_url(path)
|
|
76
|
+
"/nfl-#{access_level}#{version}/#{path}"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def api_key
|
|
80
|
+
Sportradar::Api.api_key_params("nfl")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def version
|
|
84
|
+
Sportradar::Api.version('nfl')
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def allowed_access_levels
|
|
88
|
+
['o', 'ot']
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def allowed_seasons
|
|
92
|
+
['pre', 'reg', 'pst']
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
class Request
|
|
4
|
+
|
|
5
|
+
include HTTParty
|
|
6
|
+
|
|
7
|
+
attr_reader :url, :headers, :timeout, :api_key
|
|
8
|
+
|
|
9
|
+
def base_setup(path, options={})
|
|
10
|
+
@url = set_base(path)
|
|
11
|
+
@headers = set_headers
|
|
12
|
+
@api_key = options[:api_key]
|
|
13
|
+
@timeout = options.delete(:api_timeout) || Sportradar::Api.config.api_timeout
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def get(path, options={})
|
|
17
|
+
base_setup(path, options)
|
|
18
|
+
results = self.class.get(url, headers: headers, query: options, timeout: timeout)
|
|
19
|
+
rescue Net::ReadTimeout, Net::OpenTimeout
|
|
20
|
+
raise Sportradar::Api::Error::Timeout
|
|
21
|
+
rescue EOFError
|
|
22
|
+
raise Sportradar::Api::Error::NoData
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def set_base(path)
|
|
28
|
+
protocol = !!Sportradar::Api.config.use_ssl ? "https://" : "http://"
|
|
29
|
+
url = "#{protocol}api.sportradar.us"
|
|
30
|
+
url += path
|
|
31
|
+
url += ".#{Sportradar::Api.config.format}"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def set_headers
|
|
35
|
+
{'Content-Type' => "application/#{Sportradar::Api.config.format}", 'Accept' => "application/#{Sportradar::Api.config.format}"}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
class Soccer
|
|
4
|
+
attr_accessor :league, :access_level
|
|
5
|
+
def initialize(league = 'na', access_level = 't')
|
|
6
|
+
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
|
|
7
|
+
raise Sportradar::Api::Error::InvalidLeague unless allowed_leagues.include? league
|
|
8
|
+
@league = league
|
|
9
|
+
@access_level = access_level
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def schedule
|
|
13
|
+
results = Sportradar::Api::Request.new.get(request_url("matches/schedule"), api_key )
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def daily_schedule(date = Date.today)
|
|
17
|
+
results = Sportradar::Api::Request.new.get(request_url("matches/#{date.year}/#{date.month}/#{date.day}/schedule"), api_key )
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def daily_summary(date = Date.today)
|
|
21
|
+
results = Sportradar::Api::Request.new.get(request_url("matches/#{date.year}/#{date.month}/#{date.day}/summary"), api_key )
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def daily_boxscore(date = Date.today)
|
|
25
|
+
results = Sportradar::Api::Request.new.get(request_url("matches/#{date.year}/#{date.month}/#{date.day}/boxscore"), api_key )
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# match_id = "357607e9-87cd-4848-b53e-0485d9c1a3bc"
|
|
29
|
+
def match_summary(match_id)
|
|
30
|
+
results = Sportradar::Api::Request.new.get(request_url("matches/#{match_id}/summary"), api_key )
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# match_id = "357607e9-87cd-4848-b53e-0485d9c1a3bc"
|
|
34
|
+
def match_boxscore(match_id)
|
|
35
|
+
results = Sportradar::Api::Request.new.get(request_url("matches/#{match_id}/boxscore"), api_key )
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def team_hierarchy
|
|
39
|
+
results = Sportradar::Api::Request.new.get(request_url("teams/hierarchy"), api_key )
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# team_id = "b78b9f61-0697-4347-a1b6-b7685a130eb1"
|
|
43
|
+
def team_profile(team_id)
|
|
44
|
+
results = Sportradar::Api::Request.new.get(request_url("teams/#{team_id}/profile"), api_key )
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def team_standings
|
|
48
|
+
results = Sportradar::Api::Request.new.get(request_url("teams/standing"), api_key )
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# player_id = "2aeacd39-3f9c-42af-957e-9df8573973c4"
|
|
52
|
+
def player_profile(player_id)
|
|
53
|
+
results = Sportradar::Api::Request.new.get(request_url("players/#{player_id}/profile"), api_key )
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def player_rankings
|
|
57
|
+
results = Sportradar::Api::Request.new.get(request_url("players/leader"), api_key )
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
def request_url(path)
|
|
63
|
+
"/soccer-#{access_level}#{version}/#{league}/#{path}"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def api_key
|
|
67
|
+
Sportradar::Api.api_key_params("soccer_#{league}")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def version
|
|
71
|
+
Sportradar::Api.version('soccer')
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def allowed_access_levels
|
|
75
|
+
['p', 't']
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def allowed_leagues
|
|
79
|
+
['eu', 'na', 'sa', 'wc', 'as', 'af']
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'sportradar/api/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "sportradar-api"
|
|
8
|
+
spec.version = Sportradar::Api::VERSION
|
|
9
|
+
spec.authors = ["Ben Eggett"]
|
|
10
|
+
spec.email = ["beneggett@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{ Sportradar API client }
|
|
13
|
+
spec.description = %q{ Ruby wrapper for interacting with the SportRadar API. SportRadar has over 23 published APIs. This library aims to support them incrementally. Contributions welcome! }
|
|
14
|
+
spec.homepage = "https://github.com/beneggett/sportradar-api"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
if spec.respond_to?(:metadata)
|
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
20
|
+
else
|
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
+
spec.bindir = "exe"
|
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
|
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
31
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
32
|
+
spec.add_development_dependency "vcr"
|
|
33
|
+
spec.add_development_dependency "webmock"
|
|
34
|
+
spec.add_development_dependency "pry"
|
|
35
|
+
spec.add_development_dependency "guard"
|
|
36
|
+
spec.add_development_dependency "guard-minitest"
|
|
37
|
+
spec.add_development_dependency "coveralls"
|
|
38
|
+
spec.add_development_dependency "simplecov"
|
|
39
|
+
spec.add_development_dependency "minitest-focus"
|
|
40
|
+
spec.add_development_dependency "dotenv"
|
|
41
|
+
spec.add_dependency "httparty", ">= 0.13.3"
|
|
42
|
+
|
|
43
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sportradar-api
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ben Eggett
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.12'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.12'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: minitest
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '5.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '5.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: vcr
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: webmock
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: pry
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: guard
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: guard-minitest
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: coveralls
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: simplecov
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: minitest-focus
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
160
|
+
type: :development
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ">="
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '0'
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: dotenv
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - ">="
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: '0'
|
|
174
|
+
type: :development
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - ">="
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '0'
|
|
181
|
+
- !ruby/object:Gem::Dependency
|
|
182
|
+
name: httparty
|
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
|
184
|
+
requirements:
|
|
185
|
+
- - ">="
|
|
186
|
+
- !ruby/object:Gem::Version
|
|
187
|
+
version: 0.13.3
|
|
188
|
+
type: :runtime
|
|
189
|
+
prerelease: false
|
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
191
|
+
requirements:
|
|
192
|
+
- - ">="
|
|
193
|
+
- !ruby/object:Gem::Version
|
|
194
|
+
version: 0.13.3
|
|
195
|
+
description: " Ruby wrapper for interacting with the SportRadar API. SportRadar has
|
|
196
|
+
over 23 published APIs. This library aims to support them incrementally. Contributions
|
|
197
|
+
welcome! "
|
|
198
|
+
email:
|
|
199
|
+
- beneggett@gmail.com
|
|
200
|
+
executables: []
|
|
201
|
+
extensions: []
|
|
202
|
+
extra_rdoc_files: []
|
|
203
|
+
files:
|
|
204
|
+
- ".env.sample"
|
|
205
|
+
- ".gitignore"
|
|
206
|
+
- ".travis.yml"
|
|
207
|
+
- Gemfile
|
|
208
|
+
- Gemfile.lock
|
|
209
|
+
- README.md
|
|
210
|
+
- Rakefile
|
|
211
|
+
- bin/console
|
|
212
|
+
- bin/setup
|
|
213
|
+
- lib/sportradar/api.rb
|
|
214
|
+
- lib/sportradar/api/config.rb
|
|
215
|
+
- lib/sportradar/api/error.rb
|
|
216
|
+
- lib/sportradar/api/nfl.rb
|
|
217
|
+
- lib/sportradar/api/request.rb
|
|
218
|
+
- lib/sportradar/api/soccer.rb
|
|
219
|
+
- lib/sportradar/api/version.rb
|
|
220
|
+
- sportradar-api.gemspec
|
|
221
|
+
homepage: https://github.com/beneggett/sportradar-api
|
|
222
|
+
licenses: []
|
|
223
|
+
metadata:
|
|
224
|
+
allowed_push_host: https://rubygems.org
|
|
225
|
+
post_install_message:
|
|
226
|
+
rdoc_options: []
|
|
227
|
+
require_paths:
|
|
228
|
+
- lib
|
|
229
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
|
+
requirements:
|
|
231
|
+
- - ">="
|
|
232
|
+
- !ruby/object:Gem::Version
|
|
233
|
+
version: '0'
|
|
234
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
|
+
requirements:
|
|
236
|
+
- - ">="
|
|
237
|
+
- !ruby/object:Gem::Version
|
|
238
|
+
version: '0'
|
|
239
|
+
requirements: []
|
|
240
|
+
rubyforge_project:
|
|
241
|
+
rubygems_version: 2.5.1
|
|
242
|
+
signing_key:
|
|
243
|
+
specification_version: 4
|
|
244
|
+
summary: Sportradar API client
|
|
245
|
+
test_files: []
|