Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.6.0 (2026-11-19)

### Added
- Same game parlays: `getSgpBookmakers`, `getSgpLegs` and `quoteSgp` 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` types. `reason` on a quote is a sentence for display; branch on `status` and `nextAction`.

## 1.5.4 (2026-11-13)

### Docs
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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 Node.js SDK for Odds-API.io"
version: 1.5.4
date-released: "2026-11-13"
version: 1.6.0
date-released: "2026-11-19"
authors:
- name: "Outlier AS"
email: "[email protected]"
Expand Down
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,33 @@ for (const g of grades) {

Re-send selections that are not `final`, at most once a minute.

## Same game parlays

Included in all paid plans. `getSgpBookmakers()` (`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.

```typescript
import type { SgpLeg } from 'odds-api-io';

const eventId = 61234567;
const listed = await client.getSgpLegs({ eventId, bookmakers: ['DraftKings', 'BetMGM'], markets: ['ML', 'Totals'] });
// A bookmaker whose legs could not be checked says why; its legs all read eligible: false.
const books = listed.bookmakers.filter((b) => b.status === 'ok').map((b) => b.bookmaker);
const eligible = (l: SgpLeg) => books.every((b) => l.bookmakers[b]?.eligible);
const ml = listed.legs.find((l) => l.market === 'ML' && l.side === 'home' && eligible(l));
const total = listed.legs.find((l) => l.market === 'Totals' && l.side === 'over' && eligible(l));

if (ml && total && books.length) {
const { quotes } = await client.quoteSgp({ eventId, bookmakers: books, legs: [{ legId: ml.legId }, { legId: total.legId }] });
for (const q of quotes) {
if (q.status === 'ok') console.log(q.bookmaker, q.price, 'vs', q.legsMultiplied, q.links?.desktop);
else if (q.nextAction === 'retry' || q.nextAction === 'retry_later') console.log(q.bookmaker, `retry in ${q.retryAfter ?? 2}s`);
else console.log(q.bookmaker, q.nextAction, q.legIds ?? [], q.reason);
}
}
```

`nextAction` is one of `change_legs`, `remove_leg` (drop the legs in `legIds`), `refresh_legs` (call `getSgpLegs` 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).

## Outrights (golf)

Outrights are a paid add-on: PGA Tour, DP World Tour, LIV Golf and the majors. A key without the add-on gets a `ForbiddenError` whose message links to the billing page.
Expand Down Expand Up @@ -349,6 +376,9 @@ await client.clearSelectedBookmakers(); // once every 12 hours
| | `getClosingLines(params)`, `iterateClosingLines(params)` | `GET /historical/closing-lines` |
| Settlement | `getSettlements(eventIds)` | `GET /settlements` |
| | `gradeBets(selections)` (alias `gradeSelections`) | `POST /settlements/grade` |
| Same game parlays | `getSgpBookmakers(sport?)` | `GET /sgp/bookmakers` |
| | `getSgpLegs(params)` | `GET /sgp/legs` |
| | `quoteSgp(params)` | `POST /sgp/quote` |
| Outrights | `getOutrights(params)` | `GET /outrights` |
| | `getOutrightOdds(params)` | `GET /outrights/odds` |
| | `getOutrightResults(id)` | `GET /outrights/results` |
Expand Down Expand Up @@ -452,5 +482,5 @@ This is the official SDK for Odds-API.io. This tool is for informational purpose
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 Node.js SDK for Odds-API.io (version 1.5.4). https://github.com/odds-api-io/odds-api-node
Outlier AS. odds-api-io: Official Node.js SDK for Odds-API.io (version 1.6.0). https://github.com/odds-api-io/odds-api-node
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "odds-api-io",
"version": "1.5.4",
"version": "1.6.0",
"description": "Official Node.js and TypeScript SDK for the Odds-API.io sports betting odds API: real-time odds API for 450+ bookmakers, REST and WebSocket",
"keywords": [
"odds api",
Expand Down
56 changes: 56 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ import type {
GetOutrightsParams,
GetOutrightOddsParams,
GetMappingsParams,
GetSgpLegsParams,
QuoteSgpParams,
SgpBookmaker,
SgpLegsResponse,
SgpQuoteResponse,
PageOptions,
CommaList,
} from './types.js';
Expand Down Expand Up @@ -818,6 +823,57 @@ export class OddsAPIClient {
return this.gradeBets(selections);
}

// ============================================================================
// SAME GAME PARLAYS (included in all paid plans)
// ============================================================================

/** Bookmakers that can quote same game parlays, optionally for one sport. */
async getSgpBookmakers(sport?: string): Promise<SgpBookmaker[]> {
return this.get<SgpBookmaker[]>('sgp/bookmakers', { sport });
}

/**
* The legs of one pre-match event that can go into a parlay, with a `legId`
* for each and whether each bookmaker can combine it. `bookmakers` in the
* response says, per requested bookmaker, whether its legs could be checked:
* when its `status` is not `ok`, every leg reads `eligible: false` there.
*
* @example
* ```typescript
* const { legs } = await client.getSgpLegs({ eventId: 61234567, bookmakers: ['DraftKings'], markets: ['ML', 'Totals'] });
* ```
*/
async getSgpLegs(params: GetSgpLegsParams): Promise<SgpLegsResponse> {
return this.get<SgpLegsResponse>('sgp/legs', {
...params,
bookmakers: joinList(params.bookmakers),
markets: joinList(params.markets),
});
}

/**
* Quote 2 to 10 legs as a same game parlay at each bookmaker. Every requested
* bookmaker gets one entry in `quotes`, in request order. Branch on `status`
* and `nextAction`; `reason` is a sentence for display. A quote can take up to
* 8 seconds, and at most 2 run at once per account (a third gets a 429).
*
* @example
* ```typescript
* const { quotes } = await client.quoteSgp({
* eventId: 61234567,
* bookmakers: ['DraftKings'],
* legs: [{ legId: '61234567|ML|||home' }, { legId: '61234567|Totals|221.5||over' }],
* });
* ```
*/
async quoteSgp(params: QuoteSgpParams): Promise<SgpQuoteResponse> {
const { data } = await this.send<SgpQuoteResponse>('sgp/quote', {
method: 'POST',
body: { ...params, bookmakers: joinList(params.bookmakers) },
});
return data;
}

// ============================================================================
// OUTRIGHTS (paid add-on; a key without it gets ForbiddenError)
// ============================================================================
Expand Down
17 changes: 17 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ export type {
GradeReason,
Grade,
GradesResponse,
SgpBookmakerStatus,
SgpBookmaker,
GetSgpLegsParams,
SgpSide,
SgpLegBook,
SgpLeg,
SgpLegsBookmakerStatus,
SgpLegsBookmaker,
SgpLegsResponse,
SgpQuoteLeg,
QuoteSgpParams,
SgpQuoteLegResult,
SgpQuoteLinks,
SgpQuoteStatus,
SgpNextAction,
SgpBookQuote,
SgpQuoteResponse,
OutrightMarketName,
Outright,
OutrightPriceRunner,
Expand Down
167 changes: 167 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,173 @@ export interface GradesResponse {
grades: Grade[];
}

// ============================================================================
// SAME GAME PARLAYS
// ============================================================================

export type SgpBookmakerStatus = 'live' | 'paused' | 'degraded';

export interface SgpBookmaker {
name: string;
sports: string[];
maxLegs: number;
/** The region the parlay price applies to, e.g. `US-NJ` or `AT`. */
jurisdiction: string;
/** `paused`: quotes are switched off for now. `degraded`: the status cannot be checked right now. */
status: SgpBookmakerStatus;
}

export interface GetSgpLegsParams {
eventId: number | string;
/** Max 8 per request, from the key's bookmaker selection. */
bookmakers: CommaList;
/** Max 40, case-insensitive. */
markets?: CommaList;
/** Default 200, max 1000. */
limit?: number;
skip?: number;
}

export type SgpSide = 'home' | 'away' | 'draw' | 'over' | 'under' | 'yes' | 'no';

export interface SgpLegBook {
/** The bookmaker can combine this leg into a same game parlay. */
eligible: boolean;
/** Current single price, a decimal string. Left out when the bookmaker does not price the leg. */
price?: string;
updatedAt?: string;
}

export interface SgpLeg {
/** Copy into `quoteSgp`; do not build by hand. */
legId: string;
market: string;
hdp?: number;
label?: string;
side: SgpSide;
bookmakers: Record<string, SgpLegBook>;
}

export type SgpLegsBookmakerStatus = 'ok' | 'leg_unavailable' | 'unsupported' | 'temporarily_unavailable';

/**
* Whether a requested bookmaker's legs could be checked. When `status` is not
* `ok`, every leg reads `eligible: false` at that bookmaker.
*/
export interface SgpLegsBookmaker {
bookmaker: string;
status: SgpLegsBookmakerStatus;
retryable?: boolean;
nextAction?: 'retry_later' | 'choose_other_bookmaker';
/** A readable sentence for display; its wording can change, so branch on `status` and `nextAction`. */
reason?: string;
/** Seconds to wait before calling `getSgpLegs` again. */
retryAfter?: number;
}

export interface SgpLegsResponse {
eventId: number;
status: string;
date: string;
/** One entry per requested bookmaker, in request order. */
bookmakers: SgpLegsBookmaker[];
legs: SgpLeg[];
/** Call again with a higher `skip` while true. */
hasMore: boolean;
}

/** Give either `legId`, or `market`, `hdp`, `label` and `side` as served on /odds. */
export interface SgpQuoteLeg {
legId?: string;
market?: MarketName;
/** At most 4 decimals. */
hdp?: number;
label?: string;
side?: SgpSide;
/** The single price you saw, as a decimal string; the leg is flagged `priceMoved` when it differs. */
expectedPrice?: string;
}

export interface QuoteSgpParams {
eventId: number | string;
/** Max 8 per request. */
bookmakers: CommaList;
/** 2 to 10 legs. */
legs: SgpQuoteLeg[];
}

export interface SgpQuoteLegResult {
legId: string;
/** Current single price at this bookmaker, a decimal string. */
price?: string;
hdp?: number;
priceMoved?: boolean;
}

export interface SgpQuoteLinks {
desktop: string | null;
mobile: string | null;
}

export type SgpQuoteStatus =
| 'ok'
| 'not_combinable'
| 'leg_unavailable'
| 'suspended'
| 'unsupported'
| 'timeout'
| 'temporarily_unavailable';

export type SgpNextAction =
| 'change_legs'
| 'remove_leg'
| 'refresh_legs'
| 'retry'
| 'retry_later'
| 'choose_other_bookmaker';

export interface SgpBookQuote {
bookmaker: string;
status: SgpQuoteStatus;
/** Parlay price, a decimal string. Only on `ok`. */
price?: string;
/** The current single prices multiplied together. Only on `ok`. */
legsMultiplied?: string;
/** How far `price` sits from `legsMultiplied`, in percent. Only on `ok`. */
priceAdjustmentPct?: string;
legs: SgpQuoteLegResult[];
/**
* 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 reason `redundant_leg` the legs the bookmaker ignored as implied by the others.
*/
legIds?: string[];
/** Betslip links. Only on `ok`. */
links?: SgpQuoteLinks;
jurisdiction?: string;
retryable?: boolean;
/** Set on every status but `ok`: what to do next. */
nextAction?: SgpNextAction;
/**
* A readable sentence for display. Its wording can change, so branch on
* `status` and `nextAction`. On `ok` the only reason is the code `redundant_leg`.
*/
reason?: string;
/** Seconds to wait before trying again. */
retryAfter?: number;
durationMs: number;
quotedAt?: string;
/** True when the price comes from an identical quote made in the last 10 seconds. */
cached: boolean;
cacheExpiresAt?: string;
}

export interface SgpQuoteResponse {
eventId: number;
/** One entry per requested bookmaker, in request order. */
quotes: SgpBookQuote[];
}

// ============================================================================
// OUTRIGHTS
// ============================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '1.5.4';
export const VERSION = '1.6.0';
25 changes: 25 additions & 0 deletions test/client.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,31 @@ describe('settlement', () => {
});
});

describe('same game parlays', () => {
test('getSgpBookmakers and getSgpLegs send GET queries', async () => {
const { client, calls, q } = setup([[{ name: 'DraftKings', sports: ['basketball'], maxLegs: 10, jurisdiction: 'US-WV', status: 'live' }], { 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: 'x', retryAfter: 2 }], legs: [], hasMore: false }]);
const books = await client.getSgpBookmakers('basketball');
assert.equal(books[0].maxLegs, 10);
assert.equal(calls[0].url.pathname, '/v3/sgp/bookmakers');
assert.deepEqual(q(0), { sport: 'basketball', apiKey: 'secret' });
const listed = await client.getSgpLegs({ eventId: 1, bookmakers: ['DraftKings', 'Hard Rock'], markets: ['ML', 'Totals'], limit: 50, skip: 10 });
assert.deepEqual(listed.bookmakers.map((b) => [b.bookmaker, b.status, b.nextAction]), [['DraftKings', 'ok', undefined], ['Hard Rock', 'temporarily_unavailable', 'retry_later']]);
assert.equal(calls[1].url.pathname, '/v3/sgp/legs');
assert.deepEqual(q(1), { eventId: '1', bookmakers: 'DraftKings,Hard Rock', markets: 'ML,Totals', limit: '50', skip: '10', apiKey: 'secret' });
});

test('quoteSgp POSTs a JSON body with the key in the query', async () => {
const quote = { bookmaker: 'DraftKings', status: 'ok', price: '3.38', legsMultiplied: '3.50' };
const { client, calls } = setup([{ eventId: 1, quotes: [quote] }]);
const res = await client.quoteSgp({ eventId: 1, bookmakers: ['DraftKings'], legs: [{ legId: '1|ML|||home' }, { legId: '1|Totals|221.5||over', expectedPrice: '1.95' }] });
assert.equal(res.quotes[0].price, '3.38');
assert.equal(calls[0].init.method, 'POST');
assert.equal(calls[0].url.pathname, '/v3/sgp/quote');
assert.equal(calls[0].url.searchParams.get('apiKey'), 'secret');
assert.deepEqual(JSON.parse(calls[0].init.body), { eventId: 1, bookmakers: 'DraftKings', legs: [{ legId: '1|ML|||home' }, { legId: '1|Totals|221.5||over', expectedPrice: '1.95' }] });
});
});

describe('outrights', () => {
test('getOutrights, getOutrightOdds, getOutrightResults', async () => {
const odds = {
Expand Down
Loading