oddsapiR 1.1.0
Bug fixes
- An HTTP error from The Odds API is now reported instead of returned as data. The request layer turned off httr2’s status errors, so a 401 (invalid key), 422 (invalid parameter) or 429 (usage quota reached) error body was parsed like a result, and most wrappers returned it as a one-row data frame; only the single-event odds wrappers checked for it. Every request now raises an error of class
oddsapiR_http_error, carryingstatusandurl, on any non-2xx answer, and the function reports it (for exampleHTTP 429 Too Many Requests from https://api.the-odds-api.com/v4/sports/basketball_nba/odds: Usage quota has been reached) and returns an empty data frame. The URL is shown without its query string, so the API key never appears in a message. -
toa_event_odds()andtoa_event_odds_history()no longer print the API key when The Odds API answers with status 200 but an error body whose message repeats the key. That message is now scrubbed the same way as a non-2xx error’s: both checks share one helper, which replaces the key, and also its URL-encoded copy, with<apiKey>. - The API key is now scrubbed from every error a function reports, not only the two status checks. Each wrapper’s error handler printed the cause as it came, so a network failure or a parse error whose message quoted the request URL showed the key; all 11 wrappers now print the cause through the same scrub, and so does the
oddsapiR_warninga wrapper re-raises. A non-2xx answer is also scrubbed with the key the request was sent with and the session key (ODDS_API_KEY), not only the key in the response URL, which a redirect can drop. -
testthatin Suggests now requires version 3.1.9 or later, the release that addedexpect_in(), which the tests use. - Warnings no longer cut a result short. All 11 wrappers ran their request and parse inside a
tryCatch()with awarning =handler, so any warning (a coercionNA, a partial read) stopped the parse there: the warning was printed as a message and the function returned an empty data frame. Each warning is now raised as an R warning of classoddsapiR_warningthat names the function, for exampletoa_sports_odds(): NAs introduced by coercion, and the function finishes and returns its data. Since these are now warnings rather than messages,suppressMessages()no longer hides them; wrap the call assuppressWarnings(toa_sports(), classes = "oddsapiR_warning"). A classed warning (an rlang or lifecycle one, say) also keeps its own class. - Error messages now print the underlying error message (
conditionMessage()) instead of the whole condition object. -
inst/CITATIONis now included in the package: an^inst*pattern in.Rbuildignore, which matches every path starting withins, dropped it from the built tarball, socitation("oddsapiR")fell back to the auto-generated entry.
Dependencies
- rvest is no longer imported; nothing in the package used it.
- utils is now listed in Imports.
- withr is added to Suggests; only the tests use it.
Tests
- Every wrapper now has an offline test that replays a recorded Odds API response (
tests/testthat/fixtures/http/, recorded bydata-raw/http_fixtures/record_fixtures.R), so the suite covers the parsers without anODDS_API_KEYor network access. The API key is replaced byREDACTEDin every recorded URL. New tests also cover each wrapper’s error and warning paths and the internal helpers; local coverage without a key is 100%.
oddsapiR 1.0.1
CRAN release: 2026-08-27
CRAN fix release, addressing the --run-donttest check failure reported on 2026-08-25.
Bug fixes
- Printing an
oddsapiR_datatibble no longer errors with “missing value where TRUE/FALSE needed”. The Odds API omits itsx-requests-*usage headers on error responses, which stored a zero-length quota value; the print method’s guard then evaluated toNA. Absent or unparseable headers are now recorded asNA_integer_, and the guard is length-safe. -
toa_event_odds()andtoa_event_odds_history()no longer report an API error response (an invalid key, say) as “event found, but no bookmaker odds are available yet”. The API’s own error message is surfaced instead, so a failed request is never mistaken for an event with no odds posted.
oddsapiR 1.0.0
CRAN release: 2026-08-24
First major release. Full coverage of The Odds API v4, an httr2 HTTP stack, and per-request usage-quota reporting.
New features
- Five new endpoint wrappers complete the v4 surface:
-
toa_sports_events()– in-play and upcoming events for a sport (/v4/sports/{sport}/events). -
toa_event_markets()– available market keys per bookmaker for a single event (/v4/sports/{sport}/events/{eventId}/markets). -
toa_sports_participants()– teams or players for a sport (/v4/sports/{sport}/participants). -
toa_sports_events_history()– historical events snapshot (/v4/historical/sports/{sport}/events). -
toa_event_odds_history()– historical single-event odds (/v4/historical/sports/{sport}/events/{eventId}/odds).
-
-
toa_quota()– new exported accessor returning the usage credits (requests_remaining,requests_used,requests_last) from the most recent call. The same values are attached as attributes to every returned tibble and echoed when anoddsapiR_dataobject is printed. - Every wrapper’s
@returndocumentation is now a 3-column table (col_name | types | description) and carries a Usage quota cost note.
Breaking changes
- The HTTP stack migrated from
httrtohttr2.httrandjanitorwere removed from Imports;tibblewas promoted to Imports. -
toa_sports_odds_history()now calls the current/v4/historical/sports/{sport}/oddsendpoint (the legacy/v4/sports/{sport}/odds-historypath is deprecated upstream). Its signature changed:dateis now the required second argument andevent_idsis an optional filter. The return gains leadingtimestamp,previous_timestampandnext_timestampcolumns.
Bug fixes
-
toa_event_odds()andtoa_event_odds_history()now return a zero-row tibble carrying the documented column schema (with an informative message) when the event exists but itsbookmakersarray is empty – e.g. no lines posted yet for the requested markets/regions – instead of erroring with a misleading “Invalid arguments” alert (#4). - Wrappers now initialize their return variable before the
tryCatch, so an API error (500/timeout/connection reset) returns an empty tibble and aclimessage instead of throwingobject '...' not found. -
toa_event_odds()parsing is more robust (builds an explicit tibble rather thanas_tibble(data = ".")) and surfacesoutcomes_descriptionfor player-prop markets. - Returns are self-describing:
toa_sports_participants()echoessport_key, and the historical wrappers surface the snapshot timestamps.
Test infrastructure
- Tests added for all new functions; legacy tests hardened to gate on
has_toa_key(), skip on empty/out-of-season responses, and assert columns subset-direction (expect_in(sort(cols), sort(colnames(x)))) so upstream column additions don’t break the suite.
Infrastructure & tooling
- GitHub Actions workflows modernized for the Node 24 runtime (
actions/checkout@v5,r-lib/actions/*@v2,check-r-package, pak-based dependency installs). - Added project meta files:
CLAUDE.md,CONTRIBUTING.md,CODE_OF_CONDUCT.md,.github/copilot-instructions.md, issue templates, and a pull request template. -
READMEinstallation now leads withpak(withdevtoolsas an alternative).
oddsapiR 0.0.3
CRAN release: 2023-03-19
-
toa_event_odds()function added -
toa_sports_odds_history()function added
oddsapiR 0.0.2
CRAN release: 2023-01-05
- Minor under the hood changes for tidyselect deprecation of .data$ masking
oddsapiR 0.0.1
CRAN release: 2022-06-22
- Added a
NEWS.mdfile to track changes to the package. - Four core exported functions:
-
toa_sports(): Get the Sports for which the Odds API provides coverage -
toa_sports_odds(): Get the odds for the sports which the Odds API provides coverage -
toa_sports_scores(): Get the scores for the sports which the Odds API provides coverage -
toa_requests(): Get your usage and remaining calls for your key from The Odds API
-
- Tests added for each of the above functions.
