sleeper_api 1.7.0 → 1.8.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/CLAUDE.md +1 -1
- data/README.md +5 -0
- data/lib/sleeper_api/client.rb +14 -0
- data/lib/sleeper_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da00a42dc3d3fa73feab8e1c2278f0cdcf7a274b12709c540c2f988782828269
|
|
4
|
+
data.tar.gz: 8b2fc35f6dd3a3b546cafae1679ac0dbca75193d7886fcb12b57c5bf616da667
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c953ad4e95e986db6ef5f6f559a7cf464a9cdeaf98ccf83e4cb25f1e99008152066e5b15ad7b852de444a13fafd81b795d6b338b5ced2cebe3e9710223aa966a
|
|
7
|
+
data.tar.gz: 4ccdabb09c1bd25a39e7f32ce6cd97c58b5237b8c18f9a030aa3d9307f26b0f736cd63cf6f3f9cfb6381305aa0f9b0b8cc038431f06bd52d37f3c74bb5edb75d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [1.8.0] - 2026-10-02
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **`Client#player_news(player_id, sport: "nfl", limit: 10)`** fetches one
|
|
6
|
+
player's recent news from the undocumented
|
|
7
|
+
`api.sleeper.com/players/{sport}/{id}/news`, newest first: RotoWire,
|
|
8
|
+
FantasyPros and RotoBaller items with a `metadata` title, description and
|
|
9
|
+
usually an analysis. Measured 2026-10-02: Sleeper returns at most 10 whatever
|
|
10
|
+
the limit, there is no paging, and an unknown id answers `200` with `[]`. The
|
|
11
|
+
path exists on the web host only.
|
|
12
|
+
|
|
1
13
|
## [1.7.0] - 2026-10-02
|
|
2
14
|
|
|
3
15
|
### Added
|
data/CLAUDE.md
CHANGED
|
@@ -70,7 +70,7 @@ Four layers, with a deliberate split between HTTP and modeling:
|
|
|
70
70
|
|
|
71
71
|
**Guard nil defensively.** Sleeper omits fields freely — users without `metadata`, rosters without `players`, matchups without `points`. Real leagues hit these; the spec fixtures often don't. Use `&.dig` rather than `[]` on anything nested off an API response.
|
|
72
72
|
|
|
73
|
-
**Never fan out `get_players`.** It's a multi-megabyte payload of every NFL player. It's cached for 24h in an ivar on the client instance — which means the cache dies with the client. Consumers holding a short-lived client re-download it every time. For one player, `#player(id)` fetches `/v1/players/nfl/{id}` live (~1.2 KB, undocumented, uncached); an unknown id is a **404** there, not the `200`/`null` an unknown user gets, and becomes `PlayerNotFound`.
|
|
73
|
+
**Never fan out `get_players`.** It's a multi-megabyte payload of every NFL player. It's cached for 24h in an ivar on the client instance — which means the cache dies with the client. Consumers holding a short-lived client re-download it every time. For one player, `#player(id)` fetches `/v1/players/nfl/{id}` live (~1.2 KB, undocumented, uncached); an unknown id is a **404** there, not the `200`/`null` an unknown user gets, and becomes `PlayerNotFound`. `#player_news(id)` is that player's news on `WEB_HOST` only (`.app` 404s the path): at most 10 items whatever `limit` says, and an unknown id is `200` with `[]`, not a 404.
|
|
74
74
|
|
|
75
75
|
### Undocumented endpoints carry undocumented vocabularies
|
|
76
76
|
|
data/README.md
CHANGED
|
@@ -252,6 +252,11 @@ puts "#{player['first_name']} #{player['last_name']} - #{player['position']}"
|
|
|
252
252
|
fresh = client.player("1234")
|
|
253
253
|
puts "#{fresh['injury_status']} (#{fresh['injury_body_part']})"
|
|
254
254
|
|
|
255
|
+
# One player's recent news, newest first (at most 10, from api.sleeper.com)
|
|
256
|
+
client.player_news("1234").each do |item|
|
|
257
|
+
puts "#{item['source']}: #{item.dig('metadata', 'title')}"
|
|
258
|
+
end
|
|
259
|
+
|
|
255
260
|
# Get trending players
|
|
256
261
|
trending_adds = client.trending_players(type: "add", limit: 10)
|
|
257
262
|
trending_drops = client.trending_players(type: "drop", limit: 10)
|
data/lib/sleeper_api/client.rb
CHANGED
|
@@ -487,6 +487,20 @@ module SleeperApi
|
|
|
487
487
|
not_found: -> { PlayerNotFound.new("No Sleeper player #{player_id.to_s.inspect}") })
|
|
488
488
|
end
|
|
489
489
|
|
|
490
|
+
# One player's recent news, newest first: RotoWire, FantasyPros and
|
|
491
|
+
# RotoBaller items, each with a `metadata` title, description and usually
|
|
492
|
+
# an analysis. Undocumented and on WEB_HOST only; Sleeper returns at most
|
|
493
|
+
# 10 whatever the limit, and an unknown id answers 200 with [].
|
|
494
|
+
#
|
|
495
|
+
# @param player_id [String] Player ID
|
|
496
|
+
# @param sport [String] Sport code (default: "nfl")
|
|
497
|
+
# @param limit [Integer] How many items, up to 10
|
|
498
|
+
# @return [HTTParty::Response] The items, newest first
|
|
499
|
+
def player_news(player_id, sport: "nfl", limit: 10)
|
|
500
|
+
query = URI.encode_www_form(limit: limit)
|
|
501
|
+
make_request("#{path("players", sport, player_id, "news")}?#{query}", host: WEB_HOST)
|
|
502
|
+
end
|
|
503
|
+
|
|
490
504
|
private
|
|
491
505
|
|
|
492
506
|
# Every request path is built here, from escaped segments. An unescaped
|
data/lib/sleeper_api/version.rb
CHANGED