sportscore 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/LICENSE +21 -0
- data/README.md +22 -0
- data/lib/sportscore/version.rb +3 -0
- data/lib/sportscore.rb +93 -0
- metadata +71 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: efe0fc09b11ae79e5e2a25f96e4b081997024234ebc99520cce6c1a206b9a426
|
|
4
|
+
data.tar.gz: 16c407e9156cd31de6d0ad321b1adcf4b1b3849a5e79d9ae42890bd77fc33834
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 60467e8a301d01852617936def86f9f526cf01f883b504617be369dca1af244fd548c307c1004f172e1d4cccc3372a1c4e18bb9b10926d6f652216651553e0e4
|
|
7
|
+
data.tar.gz: 918176ab7ff23b4ff5f71536363041f6c34f01967570fcaf883b6fee24727925e00651367cdc6c30ff4d65cfe332e04794c955bb172798cf1487801515153d4b
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 John Wu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Sportscore
|
|
2
|
+
A Ruby client for the free [SportScore API](https://sportscore.com/developers/)
|
|
3
|
+
|
|
4
|
+
Per SportScore's terms, apps using this data should display a
|
|
5
|
+
"Powered by SportScore" link back to https://sportscore.com/.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
require "sportscore"
|
|
11
|
+
|
|
12
|
+
Sportscore.matches(sport: "football", limit: 10)
|
|
13
|
+
Sportscore.match(sport: "football", slug: "manchester-united-vs-liverpool")
|
|
14
|
+
Sportscore.standings(sport: "football", slug: "premier-league")
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Development setup
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bundle install
|
|
21
|
+
bundle exec rspec spec/sportscore_spec.rb
|
|
22
|
+
```
|
data/lib/sportscore.rb
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require "net/http"
|
|
2
|
+
require "json"
|
|
3
|
+
require_relative "sportscore/version"
|
|
4
|
+
|
|
5
|
+
module Sportscore
|
|
6
|
+
BASE_URL = "https://sportscore.com"
|
|
7
|
+
|
|
8
|
+
class Error < StandardError; end
|
|
9
|
+
class RequestError < Error; end
|
|
10
|
+
|
|
11
|
+
# Fetches live + recent matches for a given sport.
|
|
12
|
+
# Params: sport=football|basketball|cricket|tennis, limit=1..50
|
|
13
|
+
# Sportscore.matches(sport: "football", limit: 10)
|
|
14
|
+
def self.matches(sport:, limit: 10)
|
|
15
|
+
get("/api/widget/matches", sport: sport, limit: limit)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Fetches a single match's detail (score, status, lineups, timeline).
|
|
19
|
+
# Params: sport=..., slug=<match-slug>
|
|
20
|
+
# Sportscore.match(sport: "football", slug: "manchester-united-vs-liverpool")
|
|
21
|
+
def self.match(sport:, slug:)
|
|
22
|
+
get("/api/widget/match", sport: sport, slug: slug)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Fetches team's recent + upcoming fixtures.
|
|
26
|
+
# Params: sport=..., slug=<team-slug>, limit=1..30
|
|
27
|
+
# Sportscore.team(sport: "cricket", slug: "cricket-team", limit: 12)
|
|
28
|
+
def self.team(sport:, slug:, limit: 10)
|
|
29
|
+
get("/api/widget/team", sport: sport, slug: slug, limit: limit)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Fetches league/competition standings.
|
|
33
|
+
# Params: sport=..., slug=<competition-slug>
|
|
34
|
+
# Sportscore.standings(sport: "football", slug: "premier-league")
|
|
35
|
+
def self.standings(sport:, slug:)
|
|
36
|
+
get("/api/widget/standings", sport: sport, slug: slug)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Fetches top scorers / assists for a competition
|
|
40
|
+
# Params: sport=..., slug=<competition-slug>, limit=1..50, stat=goals|assists
|
|
41
|
+
# /api/widget/topscorers
|
|
42
|
+
def self.topscorers(sport:, slug:, limit: 10, stat: "goals")
|
|
43
|
+
get("/api/widget/topscorers", sport: sport, slug: slug, limit: limit, stat: stat)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Player statistics + metadata.
|
|
47
|
+
# Params: sport=..., slug=<player-slug>
|
|
48
|
+
# /api/widget/player
|
|
49
|
+
def self.player(sport:, slug:)
|
|
50
|
+
get("/api/widget/player", sport: sport, slug: slug)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Knockout tournament bracket
|
|
54
|
+
# Params: sport=..., slug=<competition-slug>
|
|
55
|
+
# /api/widget/bracket
|
|
56
|
+
def self.bracket(sport:, slug:)
|
|
57
|
+
get("/api/widget/bracket", sport: sport, slug: slug)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Live match tracker proxy (position / animation data).
|
|
61
|
+
# Params: sport=..., id=<match-id>
|
|
62
|
+
# /api/widget/tracker
|
|
63
|
+
def self.tracker(sport:, id:)
|
|
64
|
+
get("/api/widget/tracker", sport: sport, id: id)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.get(path, params, redirect_limit = 5)
|
|
68
|
+
|
|
69
|
+
if (redirect_limit == 0)
|
|
70
|
+
raise RequestError, "Too many redirects"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
uri = URI("#{BASE_URL}#{path}")
|
|
75
|
+
uri.query = URI.encode_www_form(params.compact)
|
|
76
|
+
|
|
77
|
+
response = Net::HTTP.get_response(uri)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
case response
|
|
81
|
+
when Net::HTTPSuccess
|
|
82
|
+
JSON.parse(response.body, symbolize_names: true)
|
|
83
|
+
when Net::HTTPRedirection
|
|
84
|
+
new_uri = URI(response["location"])
|
|
85
|
+
get(new_uri.path, URI.decode_www_form(new_uri.query || ""), redirect_limit - 1)
|
|
86
|
+
else
|
|
87
|
+
raise RequestError, "SportScore API returned #{response.code}: #{response.message}"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private_class_method :get
|
|
93
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sportscore
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- johnwu3412
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rspec
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '3.0'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '3.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: webmock
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3.0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '3.0'
|
|
40
|
+
description: A simple Ruby wrapper for the free SportScore sports data API (football,
|
|
41
|
+
basketball, cricket, tennis).
|
|
42
|
+
executables: []
|
|
43
|
+
extensions: []
|
|
44
|
+
extra_rdoc_files: []
|
|
45
|
+
files:
|
|
46
|
+
- LICENSE
|
|
47
|
+
- README.md
|
|
48
|
+
- lib/sportscore.rb
|
|
49
|
+
- lib/sportscore/version.rb
|
|
50
|
+
homepage: https://github.com/johnwu3412/sportscore-ruby
|
|
51
|
+
licenses:
|
|
52
|
+
- MIT
|
|
53
|
+
metadata: {}
|
|
54
|
+
rdoc_options: []
|
|
55
|
+
require_paths:
|
|
56
|
+
- lib
|
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
67
|
+
requirements: []
|
|
68
|
+
rubygems_version: 4.0.16
|
|
69
|
+
specification_version: 4
|
|
70
|
+
summary: Ruby client for the SportScore API
|
|
71
|
+
test_files: []
|