From 05e9ac891756c5f335b168c6e20af8a58e41b0bb Mon Sep 17 00:00:00 2001 From: odds-api-io Date: Thu, 12 Nov 2026 23:28:58 +0100 Subject: [PATCH 1/5] feat: same game parlay quotes --- CHANGELOG.md | 5 +++ README.md | 18 ++++++++ odds_api/async_client.py | 85 +++++++++++++++++++++++++++++++++++ odds_api/client.py | 85 +++++++++++++++++++++++++++++++++++ odds_api/constants.py | 4 ++ odds_api/types.py | 92 ++++++++++++++++++++++++++++++++++++++ tests/test_async_client.py | 12 +++++ tests/test_client.py | 24 ++++++++++ 8 files changed, 325 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 423b7f0..ef93f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +### Added +- Same game parlays: `get_sgp_bookmakers`, `get_sgp_legs` and `quote_sgp` (sync and async) for `GET /sgp/bookmakers`, `GET /sgp/legs` and `POST /sgp/quote`, with types. + ## 1.2.3 (2026-11-13) ### Docs diff --git a/README.md b/README.md index b51e2cc..bce2c76 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ You need an API key from a paid plan: **[get your API key at odds-api.io/pricing - **Golf outrights**: Winner, Top 5/10/20, the "(Incl. Ties)" variants and Make Cut, plus results (Outrights add-on) - **Historical data**: past events, stored odds and closing lines for up to 10 leagues and a full season per sweep - **Settlement**: final scores with a `final` flag, and grading of up to 50 bets per call (won, lost, void, half won, half lost) +- **Same game parlays**: list the legs of an event and quote 2 to 10 of them per bookmaker (enabled per key) - **Analysis**: arbitrage and value bets with sport, league, market and margin filters; dropping odds from sharp bookmakers - **Odds movements**: pre-match price history per market line - **Id mappings**: our events and selections mapped to Polymarket and Kalshi ids @@ -119,6 +120,20 @@ for grade in result["grades"]: `get_settlements([ids])` returns status, final score and a `final` flag for up to 50 events. Period scores use the keys `p1`..`pN`, `ft`, `ot` and `ap`; the older keys (`period1`, `overtime`, `penalties`, `fulltime`) stop on 12 November 2026. +### Same game parlays + +Enabled per key. List the legs of a pre-match event, then quote 2 to 10 of them. Each bookmaker answers with a price (decimal string) or a `status` and `nextAction`. + +```python +legs = client.get_sgp_legs(61234567, "DraftKings", markets=["ML", "Totals"])["legs"] +quotes = client.quote_sgp( + 61234567, + "DraftKings", + [{"legId": leg["legId"]} for leg in legs[:2]], +)["quotes"] +print(quotes[0]["status"], quotes[0].get("price"), quotes[0].get("links")) +``` + ### Arbitrage and value bets ```python @@ -243,6 +258,9 @@ Comma-separated parameters accept a string or a list. Dates accept RFC3339 strin | `get_closing_lines(sport, leagues, from_, to, markets, bookmakers, limit, skip)`, `iter_closing_lines(...)` | `GET /historical/closing-lines` | | `get_settlements(event_ids)` | `GET /settlements` | | `grade_bets(selections)` | `POST /settlements/grade` | +| `get_sgp_bookmakers(sport)` | `GET /sgp/bookmakers` | +| `get_sgp_legs(event_id, bookmakers, markets, limit, skip)` | `GET /sgp/legs` | +| `quote_sgp(event_id, bookmakers, legs)` | `POST /sgp/quote` | | `get_outrights(sport="golf", league, status)` | `GET /outrights` | | `get_outright_odds(outright_id, bookmakers)` | `GET /outrights/odds` | | `get_outright_results(outright_id)` | `GET /outrights/results` | diff --git a/odds_api/async_client.py b/odds_api/async_client.py index 46812d6..6b9205f 100644 --- a/odds_api/async_client.py +++ b/odds_api/async_client.py @@ -50,6 +50,10 @@ OutrightResults, Participant, SettlementsResponse, + SgpBookmaker, + SgpLegsResponse, + SgpQuoteLeg, + SgpQuoteResponse, Sport, ValueBet, ) @@ -866,6 +870,87 @@ async def grade_bets(self, selections: Sequence[GradeSelection]) -> GradesRespon check_max("selections", list(selections), MAX_SETTLEMENT_EVENTS) return await self._post(Endpoints.GRADE_BETS, {"selections": list(selections)}) + # Same game parlays + + async def get_sgp_bookmakers(self, sport: Optional[str] = None) -> List[SgpBookmaker]: + """ + List the bookmakers that can quote same game parlays. + + Args: + sport: Sport slug from ``get_sports``; keeps bookmakers that cover it + + Example: + >>> (await client.get_sgp_bookmakers("basketball")) + """ + return await self._get(Endpoints.SGP_BOOKMAKERS, build_params(sport=sport)) + + async def get_sgp_legs( + self, + event_id: Union[int, str], + bookmakers: StrList, + markets: Optional[StrList] = None, + limit: Optional[int] = None, + skip: Optional[int] = None, + ) -> SgpLegsResponse: + """ + List the legs of a pre-match event that can go into a same game parlay. + + Each leg has a ``legId`` to pass to ``quote_sgp`` and, per bookmaker, + whether it can be combined (``eligible``) and its current ``price``. + Call again with a higher ``skip`` while ``hasMore`` is true. + + Args: + event_id: Event id from ``get_events`` + bookmakers: Bookmaker names (max 8) + markets: Market names to keep (max 40) + limit: Legs to return (default 200, max 1000) + skip: Legs to skip, for paging + + Example: + >>> client.get_sgp_legs(61234567, "DraftKings", markets=["ML", "Totals"]) + """ + params = build_params( + eventId=event_id, + bookmakers=bookmakers, + markets=markets, + limit=limit, + skip=skip, + ) + return await self._get(Endpoints.SGP_LEGS, params) + + async def quote_sgp( + self, + event_id: Union[int, str], + bookmakers: StrList, + legs: Sequence[SgpQuoteLeg], + ) -> SgpQuoteResponse: + """ + Quote 2 to 10 legs as a same game parlay at each bookmaker. + + Every requested bookmaker gets one entry in ``quotes``: ``status`` is + ``ok`` with a ``price``, or explains what to do through ``nextAction``. + Prices are decimal strings. + + Args: + event_id: Event id from ``get_events`` + bookmakers: Bookmaker names (max 8) + legs: ``{"legId": ...}`` or ``{"market", "hdp", "label", "side"}``, + optionally with ``expectedPrice`` + + Example: + >>> (await client.quote_sgp( + ... 61234567, + ... "DraftKings", + ... [{"legId": "61234567|ML|||home"}, {"legId": "61234567|Totals|221.5||over"}], + ... ))["quotes"] + """ + body = { + "eventId": event_id, + "bookmakers": build_params(bookmakers=bookmakers)["bookmakers"], + "legs": list(legs), + } + return await self._post(Endpoints.SGP_QUOTE, body) + # Outrights (add-on) async def get_outrights( diff --git a/odds_api/client.py b/odds_api/client.py index 6315f97..74e0731 100644 --- a/odds_api/client.py +++ b/odds_api/client.py @@ -50,6 +50,10 @@ OutrightResults, Participant, SettlementsResponse, + SgpBookmaker, + SgpLegsResponse, + SgpQuoteLeg, + SgpQuoteResponse, Sport, ValueBet, ) @@ -853,6 +857,87 @@ def grade_bets(self, selections: Sequence[GradeSelection]) -> GradesResponse: check_max("selections", list(selections), MAX_SETTLEMENT_EVENTS) return self._post(Endpoints.GRADE_BETS, {"selections": list(selections)}) + # Same game parlays + + def get_sgp_bookmakers(self, sport: Optional[str] = None) -> List[SgpBookmaker]: + """ + List the bookmakers that can quote same game parlays. + + Args: + sport: Sport slug from ``get_sports``; keeps bookmakers that cover it + + Example: + >>> client.get_sgp_bookmakers("basketball") + """ + return self._get(Endpoints.SGP_BOOKMAKERS, build_params(sport=sport)) + + def get_sgp_legs( + self, + event_id: Union[int, str], + bookmakers: StrList, + markets: Optional[StrList] = None, + limit: Optional[int] = None, + skip: Optional[int] = None, + ) -> SgpLegsResponse: + """ + List the legs of a pre-match event that can go into a same game parlay. + + Each leg has a ``legId`` to pass to ``quote_sgp`` and, per bookmaker, + whether it can be combined (``eligible``) and its current ``price``. + Call again with a higher ``skip`` while ``hasMore`` is true. + + Args: + event_id: Event id from ``get_events`` + bookmakers: Bookmaker names (max 8) + markets: Market names to keep (max 40) + limit: Legs to return (default 200, max 1000) + skip: Legs to skip, for paging + + Example: + >>> client.get_sgp_legs(61234567, "DraftKings", markets=["ML", "Totals"]) + """ + params = build_params( + eventId=event_id, + bookmakers=bookmakers, + markets=markets, + limit=limit, + skip=skip, + ) + return self._get(Endpoints.SGP_LEGS, params) + + def quote_sgp( + self, + event_id: Union[int, str], + bookmakers: StrList, + legs: Sequence[SgpQuoteLeg], + ) -> SgpQuoteResponse: + """ + Quote 2 to 10 legs as a same game parlay at each bookmaker. + + Every requested bookmaker gets one entry in ``quotes``: ``status`` is + ``ok`` with a ``price``, or explains what to do through ``nextAction``. + Prices are decimal strings. + + Args: + event_id: Event id from ``get_events`` + bookmakers: Bookmaker names (max 8) + legs: ``{"legId": ...}`` or ``{"market", "hdp", "label", "side"}``, + optionally with ``expectedPrice`` + + Example: + >>> client.quote_sgp( + ... 61234567, + ... "DraftKings", + ... [{"legId": "61234567|ML|||home"}, {"legId": "61234567|Totals|221.5||over"}], + ... )["quotes"] + """ + body = { + "eventId": event_id, + "bookmakers": build_params(bookmakers=bookmakers)["bookmakers"], + "legs": list(legs), + } + return self._post(Endpoints.SGP_QUOTE, body) + # Outrights (add-on) def get_outrights( diff --git a/odds_api/constants.py b/odds_api/constants.py index e6bd45d..f5332db 100644 --- a/odds_api/constants.py +++ b/odds_api/constants.py @@ -72,6 +72,10 @@ class Endpoints: GET_SETTLEMENTS = "settlements" GRADE_BETS = "settlements/grade" + SGP_BOOKMAKERS = "sgp/bookmakers" + SGP_LEGS = "sgp/legs" + SGP_QUOTE = "sgp/quote" + GET_OUTRIGHTS = "outrights" GET_OUTRIGHT_ODDS = "outrights/odds" GET_OUTRIGHT_RESULTS = "outrights/results" diff --git a/odds_api/types.py b/odds_api/types.py index ea89e1f..909a35e 100644 --- a/odds_api/types.py +++ b/odds_api/types.py @@ -349,6 +349,98 @@ class GradesResponse(TypedDict, total=False): grades: List[Grade] +SgpBookmakerStatus = Literal["live", "paused", "degraded"] +SgpQuoteStatus = Literal[ + "ok", + "not_combinable", + "leg_unavailable", + "suspended", + "unsupported", + "timeout", + "temporarily_unavailable", +] + + +class SgpBookmaker(TypedDict, total=False): + name: str + sports: List[str] + maxLegs: int + prebuilt: bool + jurisdiction: str + status: SgpBookmakerStatus + + +class SgpLegBook(TypedDict, total=False): + eligible: bool + price: str + updatedAt: str + + +class SgpLeg(TypedDict, total=False): + legId: str + market: str + hdp: float + label: str + side: str + bookmakers: Dict[str, SgpLegBook] + + +class SgpLegsResponse(TypedDict, total=False): + eventId: int + date: str + status: str + legs: List[SgpLeg] + hasMore: bool + + +class SgpQuoteLeg(TypedDict, total=False): + """Give either ``legId`` or ``market``, ``hdp``, ``label`` and ``side``.""" + + legId: str + market: str + hdp: float + label: str + side: str + expectedPrice: str + + +class SgpQuoteLegResult(TypedDict, total=False): + legId: str + price: str + hdp: float + priceMoved: bool + + +class SgpQuoteLinks(TypedDict, total=False): + desktop: str + mobile: str + + +class SgpBookQuote(TypedDict, total=False): + bookmaker: str + status: SgpQuoteStatus + price: str + legsMultiplied: str + priceAdjustmentPct: str + legs: List[SgpQuoteLegResult] + legIds: List[str] + links: SgpQuoteLinks + jurisdiction: str + durationMs: int + quotedAt: str + cached: bool + cacheExpiresAt: str + retryable: bool + retryAfter: int + nextAction: str + reason: str + + +class SgpQuoteResponse(TypedDict, total=False): + eventId: int + quotes: List[SgpBookQuote] + + class Outright(TypedDict, total=False): """A tournament from ``/outrights`` (golf today).""" diff --git a/tests/test_async_client.py b/tests/test_async_client.py index 2583e4d..b42c470 100644 --- a/tests/test_async_client.py +++ b/tests/test_async_client.py @@ -109,6 +109,18 @@ async def test_put_and_post(api, client): assert api.requests[-1]["query"] == {"apiKey": "test-key"} +async def test_quote_sgp_posts_json_body(api, client): + api.add("POST", "sgp/quote", {"eventId": 1, "quotes": []}) + legs = [{"legId": "1|ML|||home"}, {"legId": "1|Totals|221.5||over"}] + assert await client.quote_sgp(1, ["DraftKings"], legs) == {"eventId": 1, "quotes": []} + assert api.requests[-1]["json"] == { + "eventId": 1, + "bookmakers": "DraftKings", + "legs": legs, + } + assert api.requests[-1]["query"] == {"apiKey": "test-key"} + + async def test_logo_bytes(api, client): api.add("GET", "participants/45/logo", body=b"\x89PNG", content_type="image/png") assert await client.get_participant_logo(45) == b"\x89PNG" diff --git a/tests/test_client.py b/tests/test_client.py index c6b1e81..bffd0d6 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -36,6 +36,12 @@ def last_call(): CASES = [ + (lambda c: c.get_sgp_bookmakers("basketball"), "sgp/bookmakers", {"sport": "basketball"}), + ( + lambda c: c.get_sgp_legs(1, ["DraftKings"], markets=["ML", "Totals"], limit=50, skip=10), + "sgp/legs", + {"eventId": "1", "bookmakers": "DraftKings", "markets": "ML,Totals", "limit": "50", "skip": "10"}, + ), (lambda c: c.get_sports(), "sports", {}), ( lambda c: c.get_leagues("football", all=True), @@ -329,6 +335,24 @@ def test_grade_bets_posts_json_body(client): assert json.loads(request.body) == {"selections": selections} +@responses.activate +def test_quote_sgp_posts_json_body(client): + responses.post( + f"{BASE}/sgp/quote", + json={"eventId": 1, "quotes": [{"bookmaker": "DraftKings", "status": "ok", "price": "3.38"}]}, + ) + legs = [{"legId": "1|ML|||home"}, {"legId": "1|Totals|221.5||over", "expectedPrice": "1.95"}] + result = client.quote_sgp(1, ["DraftKings", "Bet365"], legs) + assert result["quotes"][0]["price"] == "3.38" + method, path, query, request = last_call() + assert method == "POST" and path == "sgp/quote" and query == {"apiKey": "test-key"} + assert json.loads(request.body) == { + "eventId": 1, + "bookmakers": "DraftKings,Bet365", + "legs": legs, + } + + @responses.activate def test_participant_logo_returns_bytes(client): responses.get( From 72da8fa19a4f351beb8058fc52775b9333d43a4a Mon Sep 17 00:00:00 2001 From: odds-api-io Date: Thu, 12 Nov 2026 23:28:58 +0100 Subject: [PATCH 2/5] refactor: direct csv for quote_sgp bookmakers and fuller async test --- odds_api/async_client.py | 3 ++- odds_api/client.py | 3 ++- tests/test_async_client.py | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/odds_api/async_client.py b/odds_api/async_client.py index 6b9205f..b7b00c7 100644 --- a/odds_api/async_client.py +++ b/odds_api/async_client.py @@ -16,6 +16,7 @@ format_time, next_retry_delay, parse_rate_limit, + to_csv, ) from .constants import ( BASE_API_URL, @@ -946,7 +947,7 @@ async def quote_sgp( """ body = { "eventId": event_id, - "bookmakers": build_params(bookmakers=bookmakers)["bookmakers"], + "bookmakers": to_csv(bookmakers), "legs": list(legs), } return await self._post(Endpoints.SGP_QUOTE, body) diff --git a/odds_api/client.py b/odds_api/client.py index 74e0731..1a94ed6 100644 --- a/odds_api/client.py +++ b/odds_api/client.py @@ -16,6 +16,7 @@ format_time, next_retry_delay, parse_rate_limit, + to_csv, ) from .constants import ( BASE_API_URL, @@ -933,7 +934,7 @@ def quote_sgp( """ body = { "eventId": event_id, - "bookmakers": build_params(bookmakers=bookmakers)["bookmakers"], + "bookmakers": to_csv(bookmakers), "legs": list(legs), } return self._post(Endpoints.SGP_QUOTE, body) diff --git a/tests/test_async_client.py b/tests/test_async_client.py index b42c470..00b8764 100644 --- a/tests/test_async_client.py +++ b/tests/test_async_client.py @@ -111,11 +111,11 @@ async def test_put_and_post(api, client): async def test_quote_sgp_posts_json_body(api, client): api.add("POST", "sgp/quote", {"eventId": 1, "quotes": []}) - legs = [{"legId": "1|ML|||home"}, {"legId": "1|Totals|221.5||over"}] - assert await client.quote_sgp(1, ["DraftKings"], legs) == {"eventId": 1, "quotes": []} + legs = [{"legId": "1|ML|||home"}, {"legId": "1|Totals|221.5||over", "expectedPrice": "1.95"}] + assert await client.quote_sgp(1, ["DraftKings", "Bet365"], legs) == {"eventId": 1, "quotes": []} assert api.requests[-1]["json"] == { "eventId": 1, - "bookmakers": "DraftKings", + "bookmakers": "DraftKings,Bet365", "legs": legs, } assert api.requests[-1]["query"] == {"apiKey": "test-key"} From f63858c27cf203d76e1f1f8fe1fe9192aafc9b2c Mon Sep 17 00:00:00 2001 From: odds-api-io Date: Thu, 19 Nov 2026 10:55:43 +0100 Subject: [PATCH 3/5] feat: per-bookmaker status on SGP legs, typed next actions, release 1.3.0 --- CHANGELOG.md | 4 ++- CITATION.cff | 4 +-- README.md | 35 ++++++++++++++------ odds_api/__init__.py | 2 +- odds_api/async_client.py | 13 +++++--- odds_api/client.py | 13 +++++--- odds_api/types.py | 69 ++++++++++++++++++++++++++++++++++------ pyproject.toml | 2 +- tests/test_client.py | 30 +++++++++++++++++ 9 files changed, 140 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef93f04..50ad163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,11 @@ # Changelog -## Unreleased +## 1.3.0 (2026-11-19) ### Added - Same game parlays: `get_sgp_bookmakers`, `get_sgp_legs` and `quote_sgp` (sync and async) for `GET /sgp/bookmakers`, `GET /sgp/legs` and `POST /sgp/quote`, with types. +- `SgpLegsResponse["bookmakers"]`: per requested bookmaker, whether its legs could be checked (`status`, `retryable`, `nextAction`, `reason`, `retryAfter`). +- `SgpNextAction` and `SgpSide` literal types. `reason` on a quote is a sentence for display; branch on `status` and `nextAction`. ## 1.2.3 (2026-11-13) diff --git a/CITATION.cff b/CITATION.cff index 3963f52..fbee6b5 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: "If you use this software, please cite it using the metadata from this file." type: software title: "odds-api-io: Official Python SDK for Odds-API.io" -version: 1.2.3 -date-released: "2026-11-13" +version: 1.3.0 +date-released: "2026-11-19" authors: - name: "Outlier AS" email: "hello@odds-api.io" diff --git a/README.md b/README.md index bce2c76..52e8f67 100644 --- a/README.md +++ b/README.md @@ -122,18 +122,35 @@ for grade in result["grades"]: ### Same game parlays -Enabled per key. List the legs of a pre-match event, then quote 2 to 10 of them. Each bookmaker answers with a price (decimal string) or a `status` and `nextAction`. +Enabled per key. List the legs of a pre-match event, then quote 2 to 10 of them. Each bookmaker answers with a price (decimal string) or a `status` and `nextAction`. Branch on those two; `reason` is a sentence for display and its wording can change. ```python -legs = client.get_sgp_legs(61234567, "DraftKings", markets=["ML", "Totals"])["legs"] -quotes = client.quote_sgp( - 61234567, - "DraftKings", - [{"legId": leg["legId"]} for leg in legs[:2]], -)["quotes"] -print(quotes[0]["status"], quotes[0].get("price"), quotes[0].get("links")) +event_id = 61234567 +listed = client.get_sgp_legs(event_id, ["DraftKings", "BetMGM"], markets=["ML", "Totals"]) +# A bookmaker whose legs could not be checked says why; its legs all read eligible False. +books = [b["bookmaker"] for b in listed["bookmakers"] if b["status"] == "ok"] + + +def eligible(leg): + return all(leg["bookmakers"].get(b, {}).get("eligible") for b in books) + + +ml = next((l for l in listed["legs"] if l["market"] == "ML" and l["side"] == "home" and eligible(l)), None) +total = next((l for l in listed["legs"] if l["market"] == "Totals" and l["side"] == "over" and eligible(l)), None) + +if ml and total and books: + quotes = client.quote_sgp(event_id, books, [{"legId": ml["legId"]}, {"legId": total["legId"]}])["quotes"] + for q in quotes: + if q["status"] == "ok": + print(q["bookmaker"], q["price"], "vs", q.get("legsMultiplied"), (q.get("links") or {}).get("desktop")) + elif q.get("nextAction") in ("retry", "retry_later"): + print(q["bookmaker"], f"retry in {q.get('retryAfter', 2)}s") + else: + print(q["bookmaker"], q.get("nextAction"), q.get("legIds", []), q.get("reason")) ``` +`nextAction` is one of `change_legs`, `remove_leg` (drop the legs in `legIds`), `refresh_legs` (call `get_sgp_legs` again), `retry`, `retry_later` (wait `retryAfter` seconds) or `choose_other_bookmaker`. A quote can take up to 8 seconds, and at most 2 quotes run at once per account. See the [same game parlay guide](https://docs.odds-api.io/guides/sgp). + ### Arbitrage and value bets ```python @@ -307,5 +324,5 @@ MIT. See [LICENSE](LICENSE). If you use this package in research or a publication, please cite it. Citation metadata is in [CITATION.cff](CITATION.cff) (GitHub renders a "Cite this repository" button from it) and Zenodo metadata is in `.zenodo.json`. ``` -Outlier AS. odds-api-io: Official Python SDK for Odds-API.io (version 1.2.3). https://github.com/odds-api-io/odds-api-python +Outlier AS. odds-api-io: Official Python SDK for Odds-API.io (version 1.3.0). https://github.com/odds-api-io/odds-api-python ``` diff --git a/odds_api/__init__.py b/odds_api/__init__.py index 8cd0085..50ee9bc 100644 --- a/odds_api/__init__.py +++ b/odds_api/__init__.py @@ -3,7 +3,7 @@ Official Python client for the Odds-API.io sports betting odds API. """ -__version__ = "1.2.3" +__version__ = "1.3.0" from .client import OddsAPIClient from .async_client import AsyncOddsAPIClient diff --git a/odds_api/async_client.py b/odds_api/async_client.py index b7b00c7..7dd66f0 100644 --- a/odds_api/async_client.py +++ b/odds_api/async_client.py @@ -898,7 +898,10 @@ async def get_sgp_legs( Each leg has a ``legId`` to pass to ``quote_sgp`` and, per bookmaker, whether it can be combined (``eligible``) and its current ``price``. - Call again with a higher ``skip`` while ``hasMore`` is true. + The top-level ``bookmakers`` says, per requested bookmaker, whether its + legs could be checked: when its ``status`` is not ``ok``, every leg reads + ``eligible: False`` there. Call again with a higher ``skip`` while + ``hasMore`` is true. Args: event_id: Event id from ``get_events`` @@ -928,9 +931,11 @@ async def quote_sgp( """ Quote 2 to 10 legs as a same game parlay at each bookmaker. - Every requested bookmaker gets one entry in ``quotes``: ``status`` is - ``ok`` with a ``price``, or explains what to do through ``nextAction``. - Prices are decimal strings. + Every requested bookmaker gets one entry in ``quotes``, in request + order: ``status`` is ``ok`` with a ``price``, or explains what to do + through ``nextAction``. Branch on those two; ``reason`` is a sentence for + display. Prices are decimal strings. A quote can take up to 8 seconds, + and at most 2 run at once per account (a third gets a 429). Args: event_id: Event id from ``get_events`` diff --git a/odds_api/client.py b/odds_api/client.py index 1a94ed6..ddbe9ba 100644 --- a/odds_api/client.py +++ b/odds_api/client.py @@ -885,7 +885,10 @@ def get_sgp_legs( Each leg has a ``legId`` to pass to ``quote_sgp`` and, per bookmaker, whether it can be combined (``eligible``) and its current ``price``. - Call again with a higher ``skip`` while ``hasMore`` is true. + The top-level ``bookmakers`` says, per requested bookmaker, whether its + legs could be checked: when its ``status`` is not ``ok``, every leg reads + ``eligible: False`` there. Call again with a higher ``skip`` while + ``hasMore`` is true. Args: event_id: Event id from ``get_events`` @@ -915,9 +918,11 @@ def quote_sgp( """ Quote 2 to 10 legs as a same game parlay at each bookmaker. - Every requested bookmaker gets one entry in ``quotes``: ``status`` is - ``ok`` with a ``price``, or explains what to do through ``nextAction``. - Prices are decimal strings. + Every requested bookmaker gets one entry in ``quotes``, in request + order: ``status`` is ``ok`` with a ``price``, or explains what to do + through ``nextAction``. Branch on those two; ``reason`` is a sentence for + display. Prices are decimal strings. A quote can take up to 8 seconds, + and at most 2 run at once per account (a third gets a 429). Args: event_id: Event id from ``get_events`` diff --git a/odds_api/types.py b/odds_api/types.py index 909a35e..7917584 100644 --- a/odds_api/types.py +++ b/odds_api/types.py @@ -350,6 +350,8 @@ class GradesResponse(TypedDict, total=False): SgpBookmakerStatus = Literal["live", "paused", "degraded"] +SgpSide = Literal["home", "away", "draw", "over", "under", "yes", "no"] +SgpLegsBookmakerStatus = Literal["ok", "leg_unavailable", "unsupported", "temporarily_unavailable"] SgpQuoteStatus = Literal[ "ok", "not_combinable", @@ -359,9 +361,23 @@ class GradesResponse(TypedDict, total=False): "timeout", "temporarily_unavailable", ] +SgpNextAction = Literal[ + "change_legs", + "remove_leg", + "refresh_legs", + "retry", + "retry_later", + "choose_other_bookmaker", +] class SgpBookmaker(TypedDict, total=False): + """``jurisdiction`` is the region the parlay price applies to. + + ``status`` is ``paused`` when quotes are switched off for now and + ``degraded`` when the status cannot be checked right now. + """ + name: str sports: List[str] maxLegs: int @@ -371,6 +387,8 @@ class SgpBookmaker(TypedDict, total=False): class SgpLegBook(TypedDict, total=False): + """``price`` is a decimal string, left out when the bookmaker does not price the leg.""" + eligible: bool price: str updatedAt: str @@ -381,14 +399,33 @@ class SgpLeg(TypedDict, total=False): market: str hdp: float label: str - side: str + side: SgpSide bookmakers: Dict[str, SgpLegBook] +class SgpLegsBookmaker(TypedDict, total=False): + """Whether a requested bookmaker's legs could be checked. + + When ``status`` is not ``ok`` every leg reads ``eligible: False`` at that + bookmaker. ``reason`` is a sentence for display; branch on ``status`` and + ``nextAction``. ``retryAfter`` is in seconds. + """ + + bookmaker: str + status: SgpLegsBookmakerStatus + retryable: bool + nextAction: Literal["retry_later", "choose_other_bookmaker"] + reason: str + retryAfter: int + + class SgpLegsResponse(TypedDict, total=False): + """``bookmakers`` has one entry per requested bookmaker, in request order.""" + eventId: int - date: str status: str + date: str + bookmakers: List[SgpLegsBookmaker] legs: List[SgpLeg] hasMore: bool @@ -400,7 +437,7 @@ class SgpQuoteLeg(TypedDict, total=False): market: str hdp: float label: str - side: str + side: SgpSide expectedPrice: str @@ -411,12 +448,24 @@ class SgpQuoteLegResult(TypedDict, total=False): priceMoved: bool -class SgpQuoteLinks(TypedDict, total=False): - desktop: str - mobile: str +class SgpQuoteLinks(TypedDict): + desktop: Optional[str] + mobile: Optional[str] class SgpBookQuote(TypedDict, total=False): + """One bookmaker's answer to ``quote_sgp``. + + ``price``, ``legsMultiplied``, ``priceAdjustmentPct`` and ``links`` are only + set on ``ok``. Every other status carries ``retryable``, ``nextAction`` and + ``reason``. ``reason`` is a sentence for display whose wording can change, + so branch on ``status`` and ``nextAction``; on ``ok`` the only reason is the + code ``redundant_leg``. ``legIds`` lists the legs that made the quote fail + (always on ``leg_unavailable``; on ``not_combinable`` and ``suspended`` when + the bookmaker names them), or on ``ok`` with ``redundant_leg`` the legs the + bookmaker ignored as implied by the others. + """ + bookmaker: str status: SgpQuoteStatus price: str @@ -426,14 +475,14 @@ class SgpBookQuote(TypedDict, total=False): legIds: List[str] links: SgpQuoteLinks jurisdiction: str + retryable: bool + nextAction: SgpNextAction + reason: str + retryAfter: int durationMs: int quotedAt: str cached: bool cacheExpiresAt: str - retryable: bool - retryAfter: int - nextAction: str - reason: str class SgpQuoteResponse(TypedDict, total=False): diff --git a/pyproject.toml b/pyproject.toml index 28aa060..e18ae0b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "odds-api-io" -version = "1.2.3" +version = "1.3.0" description = "Official Python SDK for Odds-API.io, the sports betting odds API: live and pre-match odds from 450+ bookmakers across 34 sports, player props, golf outrights, closing lines, settlement, arbitrage, value bets and WebSocket" readme = "README.md" requires-python = ">=3.8" diff --git a/tests/test_client.py b/tests/test_client.py index bffd0d6..9e3be11 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -353,6 +353,36 @@ def test_quote_sgp_posts_json_body(client): } +@responses.activate +def test_get_sgp_legs_returns_per_bookmaker_status(client): + responses.get( + f"{BASE}/sgp/legs", + json={ + "eventId": 1, + "status": "pending", + "date": "2026-11-14T00:30:00Z", + "bookmakers": [ + {"bookmaker": "DraftKings", "status": "ok"}, + { + "bookmaker": "Hard Rock", + "status": "temporarily_unavailable", + "retryable": True, + "nextAction": "retry_later", + "reason": "This bookmaker's same game parlay legs could not be read right now.", + "retryAfter": 2, + }, + ], + "legs": [], + "hasMore": False, + }, + ) + result = client.get_sgp_legs(1, ["DraftKings", "Hard Rock"]) + assert [b["status"] for b in result["bookmakers"]] == ["ok", "temporarily_unavailable"] + assert result["bookmakers"][1]["nextAction"] == "retry_later" + _, path, query, _ = last_call() + assert path == "sgp/legs" and query["bookmakers"] == "DraftKings,Hard Rock" + + @responses.activate def test_participant_logo_returns_bytes(client): responses.get( From 33b66f034e176e66e0ce6162e2cc88f981c0ba86 Mon Sep 17 00:00:00 2001 From: odds-api-io Date: Thu, 19 Nov 2026 10:56:27 +0100 Subject: [PATCH 4/5] docs: same game parlays are included in all paid plans --- README.md | 4 ++-- odds_api/async_client.py | 4 ++-- odds_api/client.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 52e8f67..186a7ba 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ You need an API key from a paid plan: **[get your API key at odds-api.io/pricing - **Golf outrights**: Winner, Top 5/10/20, the "(Incl. Ties)" variants and Make Cut, plus results (Outrights add-on) - **Historical data**: past events, stored odds and closing lines for up to 10 leagues and a full season per sweep - **Settlement**: final scores with a `final` flag, and grading of up to 50 bets per call (won, lost, void, half won, half lost) -- **Same game parlays**: list the legs of an event and quote 2 to 10 of them per bookmaker (enabled per key) +- **Same game parlays**: list the legs of an event and quote 2 to 10 of them per bookmaker - **Analysis**: arbitrage and value bets with sport, league, market and margin filters; dropping odds from sharp bookmakers - **Odds movements**: pre-match price history per market line - **Id mappings**: our events and selections mapped to Polymarket and Kalshi ids @@ -122,7 +122,7 @@ for grade in result["grades"]: ### Same game parlays -Enabled per key. List the legs of a pre-match event, then quote 2 to 10 of them. Each bookmaker answers with a price (decimal string) or a `status` and `nextAction`. Branch on those two; `reason` is a sentence for display and its wording can change. +Included in all paid plans. `get_sgp_bookmakers()` (`GET /v3/sgp/bookmakers`) returns the bookmakers that quote same game parlays right now; more are being added. List the legs of a pre-match event, then quote 2 to 10 of them. Each bookmaker answers with a price (decimal string) or a `status` and `nextAction`. Branch on those two; `reason` is a sentence for display and its wording can change. ```python event_id = 61234567 diff --git a/odds_api/async_client.py b/odds_api/async_client.py index 7dd66f0..713b849 100644 --- a/odds_api/async_client.py +++ b/odds_api/async_client.py @@ -905,7 +905,7 @@ async def get_sgp_legs( Args: event_id: Event id from ``get_events`` - bookmakers: Bookmaker names (max 8) + bookmakers: Bookmaker names (max 8 per request) markets: Market names to keep (max 40) limit: Legs to return (default 200, max 1000) skip: Legs to skip, for paging @@ -939,7 +939,7 @@ async def quote_sgp( Args: event_id: Event id from ``get_events`` - bookmakers: Bookmaker names (max 8) + bookmakers: Bookmaker names (max 8 per request) legs: ``{"legId": ...}`` or ``{"market", "hdp", "label", "side"}``, optionally with ``expectedPrice`` diff --git a/odds_api/client.py b/odds_api/client.py index ddbe9ba..5b8a68c 100644 --- a/odds_api/client.py +++ b/odds_api/client.py @@ -892,7 +892,7 @@ def get_sgp_legs( Args: event_id: Event id from ``get_events`` - bookmakers: Bookmaker names (max 8) + bookmakers: Bookmaker names (max 8 per request) markets: Market names to keep (max 40) limit: Legs to return (default 200, max 1000) skip: Legs to skip, for paging @@ -926,7 +926,7 @@ def quote_sgp( Args: event_id: Event id from ``get_events`` - bookmakers: Bookmaker names (max 8) + bookmakers: Bookmaker names (max 8 per request) legs: ``{"legId": ...}`` or ``{"market", "hdp", "label", "side"}``, optionally with ``expectedPrice`` From a235c2029638682e962a56f820517a17f3acf529 Mon Sep 17 00:00:00 2001 From: odds-api-io Date: Thu, 19 Nov 2026 11:47:11 +0100 Subject: [PATCH 5/5] refactor: drop the always-false prebuilt field from SGP bookmakers --- odds_api/types.py | 1 - 1 file changed, 1 deletion(-) diff --git a/odds_api/types.py b/odds_api/types.py index 7917584..a6433ae 100644 --- a/odds_api/types.py +++ b/odds_api/types.py @@ -381,7 +381,6 @@ class SgpBookmaker(TypedDict, total=False): name: str sports: List[str] maxLegs: int - prebuilt: bool jurisdiction: str status: SgpBookmakerStatus