odds-api-io 1.0.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.
- package/LICENSE +21 -0
- package/README.md +329 -0
- package/dist/cjs/client.js +426 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/errors.js +73 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +6 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/client.js +422 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.js +64 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/client.d.ts +275 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/errors.d.ts +40 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +180 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Odds-API.io
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# Odds-API.io Node.js SDK
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/odds-api-io)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
|
|
8
|
+
Official Node.js SDK for [**Odds-API.io**](https://odds-api.io) - Real-time sports betting odds from 250+ bookmakers.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- 🏀 **20+ Sports** - Basketball, football, tennis, and more
|
|
13
|
+
- 📊 **Comprehensive Odds Data** - Real-time odds from 250+ bookmakers
|
|
14
|
+
- 💰 **Arbitrage Detection** - Find risk-free betting opportunities
|
|
15
|
+
- 📈 **Value Bets** - Identify positive expected value bets
|
|
16
|
+
- 🔴 **Live Events** - Track in-play events and odds
|
|
17
|
+
- 🔍 **Advanced Search** - Search events, participants, and leagues
|
|
18
|
+
- ⚡ **TypeScript First** - Full type safety with TypeScript
|
|
19
|
+
- 📦 **Dual Package** - Works with both ESM and CommonJS
|
|
20
|
+
- 🛡️ **Error Handling** - Custom error classes for better debugging
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install odds-api-io
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Get Your API Key
|
|
29
|
+
|
|
30
|
+
Visit [**odds-api.io/#pricing**](https://odds-api.io/#pricing) to get your API key.
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### TypeScript
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { OddsAPIClient } from 'odds-api-io';
|
|
38
|
+
|
|
39
|
+
const client = new OddsAPIClient({
|
|
40
|
+
apiKey: 'your-api-key-here'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Get all available sports
|
|
44
|
+
const sports = await client.getSports();
|
|
45
|
+
console.log(`Found ${sports.length} sports`);
|
|
46
|
+
|
|
47
|
+
// Get upcoming NBA events
|
|
48
|
+
const events = await client.getEvents({
|
|
49
|
+
sport: 'basketball',
|
|
50
|
+
league: 'usa-nba'
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Search for specific games
|
|
54
|
+
const lakersGames = await client.searchEvents('Lakers');
|
|
55
|
+
|
|
56
|
+
// Get live events
|
|
57
|
+
const liveEvents = await client.getLiveEvents('basketball');
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### JavaScript (CommonJS)
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
const { OddsAPIClient } = require('odds-api-io');
|
|
64
|
+
|
|
65
|
+
const client = new OddsAPIClient({
|
|
66
|
+
apiKey: 'your-api-key-here'
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
async function getOdds() {
|
|
70
|
+
const events = await client.getEvents({
|
|
71
|
+
sport: 'basketball',
|
|
72
|
+
league: 'usa-nba'
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const odds = await client.getEventOdds({
|
|
76
|
+
eventId: events[0].id,
|
|
77
|
+
bookmakers: 'pinnacle,bet365'
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
console.log(odds);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getOdds();
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### JavaScript (ESM)
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
import { OddsAPIClient } from 'odds-api-io';
|
|
90
|
+
|
|
91
|
+
const client = new OddsAPIClient({
|
|
92
|
+
apiKey: 'your-api-key-here'
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const sports = await client.getSports();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
### Finding Arbitrage Opportunities
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { OddsAPIClient } from 'odds-api-io';
|
|
104
|
+
|
|
105
|
+
const client = new OddsAPIClient({ apiKey: 'your-api-key' });
|
|
106
|
+
|
|
107
|
+
const arbs = await client.getArbitrageBets({
|
|
108
|
+
bookmakers: 'pinnacle,bet365',
|
|
109
|
+
limit: 10,
|
|
110
|
+
includeEventDetails: true
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
arbs.forEach(arb => {
|
|
114
|
+
console.log(`Profit: ${arb.profitPercentage}%`);
|
|
115
|
+
console.log('Legs:', arb.legs);
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Tracking Odds Movements
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// Get odds for a specific event
|
|
123
|
+
const odds = await client.getEventOdds({
|
|
124
|
+
eventId: '62924717',
|
|
125
|
+
bookmakers: 'pinnacle,bet365'
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Track how odds change over time
|
|
129
|
+
const movements = await client.getOddsMovement({
|
|
130
|
+
eventId: '62924717',
|
|
131
|
+
bookmaker: 'pinnacle',
|
|
132
|
+
market: 'moneyline'
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Getting Value Bets
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
// Find value betting opportunities
|
|
140
|
+
const valueBets = await client.getValueBets({
|
|
141
|
+
bookmaker: 'pinnacle',
|
|
142
|
+
includeEventDetails: true
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
valueBets.forEach(bet => {
|
|
146
|
+
console.log(`Value: ${bet.valuePercentage}%`);
|
|
147
|
+
console.log(`Odds: ${bet.odds} (Fair: ${bet.fairOdds})`);
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Working with Participants
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// Search for teams/players
|
|
155
|
+
const warriors = await client.getParticipants({
|
|
156
|
+
sport: 'basketball',
|
|
157
|
+
search: 'Warriors'
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// Get participant details by ID
|
|
161
|
+
const participant = await client.getParticipantById(3428);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Managing Bookmakers
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
// Get all available bookmakers
|
|
168
|
+
const bookmakers = await client.getBookmakers();
|
|
169
|
+
|
|
170
|
+
// Select specific bookmakers for your account
|
|
171
|
+
await client.selectBookmakers('pinnacle,bet365');
|
|
172
|
+
|
|
173
|
+
// Check which bookmakers you've selected
|
|
174
|
+
const selected = await client.getSelectedBookmakers();
|
|
175
|
+
|
|
176
|
+
// Clear selected bookmakers
|
|
177
|
+
await client.clearSelectedBookmakers();
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## API Reference
|
|
181
|
+
|
|
182
|
+
### Sports & Leagues
|
|
183
|
+
|
|
184
|
+
| Method | Description | Docs |
|
|
185
|
+
|--------|-------------|------|
|
|
186
|
+
| `getSports()` | Get all available sports | [Docs](https://docs.odds-api.io/api-reference/sports/get-sports) |
|
|
187
|
+
| `getLeagues(sport)` | Get leagues for a sport | [Docs](https://docs.odds-api.io/api-reference/leagues/get-leagues) |
|
|
188
|
+
|
|
189
|
+
### Events
|
|
190
|
+
|
|
191
|
+
| Method | Description | Docs |
|
|
192
|
+
|--------|-------------|------|
|
|
193
|
+
| `getEvents(params)` | Get events with filters | [Docs](https://docs.odds-api.io/api-reference/events/get-events) |
|
|
194
|
+
| `getEventById(eventId)` | Get specific event details | [Docs](https://docs.odds-api.io/api-reference/events/get-event-by-id) |
|
|
195
|
+
| `getLiveEvents(sport)` | Get currently live events | [Docs](https://docs.odds-api.io/api-reference/events/get-live-events) |
|
|
196
|
+
| `searchEvents(query)` | Search for events by keyword | [Docs](https://docs.odds-api.io/api-reference/events/search-events) |
|
|
197
|
+
|
|
198
|
+
### Odds
|
|
199
|
+
|
|
200
|
+
| Method | Description | Docs |
|
|
201
|
+
|--------|-------------|------|
|
|
202
|
+
| `getEventOdds(params)` | Get odds for an event | [Docs](https://docs.odds-api.io/api-reference/odds/get-event-odds) |
|
|
203
|
+
| `getOddsMovement(params)` | Track odds changes | [Docs](https://docs.odds-api.io/api-reference/odds/get-odds-movements) |
|
|
204
|
+
| `getOddsForMultipleEvents(params)` | Get odds for multiple events | [Docs](https://docs.odds-api.io/api-reference/odds/get-odds-for-multiple-events) |
|
|
205
|
+
| `getUpdatedOddsSince(params)` | Get odds updated since timestamp | [Docs](https://docs.odds-api.io/api-reference/odds/get-updated-event-odds-since-a-given-timestamp) |
|
|
206
|
+
|
|
207
|
+
### Participants
|
|
208
|
+
|
|
209
|
+
| Method | Description | Docs |
|
|
210
|
+
|--------|-------------|------|
|
|
211
|
+
| `getParticipants(params)` | Get participants/teams | [Docs](https://docs.odds-api.io/api-reference/participants/get-participants) |
|
|
212
|
+
| `getParticipantById(id)` | Get participant by ID | [Docs](https://docs.odds-api.io/api-reference/participants/get-participant-by-id) |
|
|
213
|
+
|
|
214
|
+
### Bookmakers
|
|
215
|
+
|
|
216
|
+
| Method | Description | Docs |
|
|
217
|
+
|--------|-------------|------|
|
|
218
|
+
| `getBookmakers()` | Get all available bookmakers | [Docs](https://docs.odds-api.io/api-reference/bookmakers/get-bookmakers) |
|
|
219
|
+
| `getSelectedBookmakers()` | Get your selected bookmakers | [Docs](https://docs.odds-api.io/api-reference/bookmakers/get-selected-bookmakers) |
|
|
220
|
+
| `selectBookmakers(bookmakers)` | Select bookmakers for your account | [Docs](https://docs.odds-api.io/api-reference/bookmakers/select-bookmakers) |
|
|
221
|
+
| `clearSelectedBookmakers()` | Clear bookmaker selection | [Docs](https://docs.odds-api.io/api-reference/bookmakers/clear-selected-bookmakers) |
|
|
222
|
+
|
|
223
|
+
### Betting Analysis
|
|
224
|
+
|
|
225
|
+
| Method | Description | Docs |
|
|
226
|
+
|--------|-------------|------|
|
|
227
|
+
| `getArbitrageBets(params)` | Find arbitrage opportunities | [Docs](https://docs.odds-api.io/api-reference/arbitrage-bets/get-arbitrage-betting-opportunities) |
|
|
228
|
+
| `getValueBets(params)` | Find value bets | [Docs](https://docs.odds-api.io/api-reference/value-bets/get-value-bets) |
|
|
229
|
+
|
|
230
|
+
## Error Handling
|
|
231
|
+
|
|
232
|
+
The SDK includes custom error classes for better error handling:
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
import {
|
|
236
|
+
OddsAPIClient,
|
|
237
|
+
OddsAPIError,
|
|
238
|
+
InvalidAPIKeyError,
|
|
239
|
+
RateLimitExceededError,
|
|
240
|
+
NotFoundError,
|
|
241
|
+
TimeoutError,
|
|
242
|
+
NetworkError
|
|
243
|
+
} from 'odds-api-io';
|
|
244
|
+
|
|
245
|
+
const client = new OddsAPIClient({ apiKey: 'your-api-key' });
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
const events = await client.getEvents({ sport: 'basketball' });
|
|
249
|
+
} catch (error) {
|
|
250
|
+
if (error instanceof InvalidAPIKeyError) {
|
|
251
|
+
console.error('Your API key is invalid');
|
|
252
|
+
} else if (error instanceof RateLimitExceededError) {
|
|
253
|
+
console.error('Rate limit exceeded - wait before retrying');
|
|
254
|
+
} else if (error instanceof NotFoundError) {
|
|
255
|
+
console.error('Resource not found');
|
|
256
|
+
} else if (error instanceof TimeoutError) {
|
|
257
|
+
console.error('Request timeout');
|
|
258
|
+
} else if (error instanceof NetworkError) {
|
|
259
|
+
console.error('Network error');
|
|
260
|
+
} else if (error instanceof OddsAPIError) {
|
|
261
|
+
console.error('API error:', error.message);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Configuration
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
const client = new OddsAPIClient({
|
|
270
|
+
apiKey: 'your-api-key',
|
|
271
|
+
baseUrl: 'https://api2.odds-api.io/v3', // Optional, default shown
|
|
272
|
+
timeout: 10000 // Optional, default 10 seconds
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## TypeScript Support
|
|
277
|
+
|
|
278
|
+
This SDK is written in TypeScript and includes complete type definitions:
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
import type {
|
|
282
|
+
Sport,
|
|
283
|
+
League,
|
|
284
|
+
Event,
|
|
285
|
+
Participant,
|
|
286
|
+
Bookmaker,
|
|
287
|
+
EventOdds,
|
|
288
|
+
ArbitrageBet,
|
|
289
|
+
ValueBet,
|
|
290
|
+
GetEventsParams
|
|
291
|
+
} from 'odds-api-io';
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Free Tier Limitations
|
|
295
|
+
|
|
296
|
+
The free API tier has some restrictions:
|
|
297
|
+
|
|
298
|
+
- **Limited bookmakers** - Only 2 bookmakers can be selected at once
|
|
299
|
+
- **Rate limits** - Check the [API documentation](https://docs.odds-api.io/) for current limits
|
|
300
|
+
- **No WebSocket** - Free tier uses HTTP requests only
|
|
301
|
+
|
|
302
|
+
[**Upgrade your plan**](https://odds-api.io/#pricing) for full access.
|
|
303
|
+
|
|
304
|
+
## Resources
|
|
305
|
+
|
|
306
|
+
- 📘 [**API Documentation**](https://docs.odds-api.io/)
|
|
307
|
+
- 🌐 [**Odds-API.io Website**](https://odds-api.io)
|
|
308
|
+
- 💳 [**Get Your API Key**](https://odds-api.io/#pricing)
|
|
309
|
+
- 🐛 [**Report Issues**](https://github.com/odds-api-io/odds-api-node/issues)
|
|
310
|
+
|
|
311
|
+
## Examples Directory
|
|
312
|
+
|
|
313
|
+
Check the [`examples/`](./examples) directory for more comprehensive examples:
|
|
314
|
+
|
|
315
|
+
- `basic-usage.ts` / `basic-usage.js` - Getting started
|
|
316
|
+
- `arbitrage-betting.ts` - Finding arbitrage opportunities
|
|
317
|
+
- `odds-tracking.ts` - Monitoring odds movements
|
|
318
|
+
|
|
319
|
+
## License
|
|
320
|
+
|
|
321
|
+
[MIT](LICENSE) © Odds-API.io
|
|
322
|
+
|
|
323
|
+
## Disclaimer
|
|
324
|
+
|
|
325
|
+
This is the official SDK for Odds-API.io. This tool is for informational purposes only and should not be used as the sole basis for betting decisions.
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
Built with ❤️ for the sports betting and analytics community
|