Skip to content

Official Python SDK for Odds-API.io - Real-time sports betting odds from 250+ bookmakers

License

Notifications You must be signed in to change notification settings

odds-api-io/odds-api-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Odds-API.io Python SDK

PyPI version Python versions License: MIT Documentation

Official Python SDK for Odds-API.io - Real-time sports betting odds from 250+ bookmakers.

πŸš€ Features

  • ⚑ Fast & Reliable - Built on requests and aiohttp for both sync and async workflows
  • πŸ€ 20+ Sports - Basketball, football, tennis, baseball, and more
  • πŸ“Š 250+ Bookmakers - Comprehensive odds coverage from major sportsbooks worldwide
  • πŸ’° Arbitrage Detection - Find risk-free betting opportunities across bookmakers
  • πŸ“ˆ Value Bets - Identify positive expected value betting opportunities
  • πŸ”΄ Live Events - Real-time in-play event tracking and odds
  • πŸ” Advanced Search - Search events, participants, and leagues
  • ✨ Type Hints - Full type annotations for better IDE support
  • 🐍 Modern Python - Supports Python 3.8+

πŸ“¦ Installation

pip install odds-api-io

πŸ”‘ Get Your API Key

Get your free API key here β†’

Sign up at odds-api.io to get started. Free tier includes:

  • 5,000 requests/hour
  • Access to all endpoints
  • No credit card required

πŸ“š Documentation

Full API documentation is available at docs.odds-api.io

πŸƒ Quick Start

Synchronous Client

from odds_api import OddsAPIClient

# Initialize the client
client = OddsAPIClient(api_key="your_api_key_here")

# Get available sports
sports = client.get_sports()
print(f"Found {len(sports)} sports")

# Get upcoming NBA events
events = client.get_events(sport="basketball", league="usa-nba")

# Search for specific games
lakers_games = client.search_events(query="Lakers")

# Get live basketball events
live = client.get_live_events(sport="basketball")

# Find arbitrage opportunities
arb_bets = client.get_arbitrage_bets(
    bookmakers="pinnacle,bet365",
    limit=10,
    include_event_details=True
)

# Close the client when done
client.close()

Asynchronous Client

import asyncio
from odds_api import AsyncOddsAPIClient

async def main():
    # Use async context manager
    async with AsyncOddsAPIClient(api_key="your_api_key_here") as client:
        # Get sports
        sports = await client.get_sports()
        
        # Get upcoming events
        events = await client.get_events(sport="basketball", league="usa-nba")
        
        # Find value bets
        value_bets = await client.get_value_bets(
            bookmaker="pinnacle",
            include_event_details=True
        )
        
        print(f"Found {len(value_bets)} value betting opportunities")

# Run async code
asyncio.run(main())

Context Manager (Recommended)

# Sync
with OddsAPIClient(api_key="your_api_key") as client:
    sports = client.get_sports()

# Async
async with AsyncOddsAPIClient(api_key="your_api_key") as client:
    sports = await client.get_sports()

πŸ“– Examples

Check out the examples/ directory for more detailed examples:

πŸ”§ API Reference

Sports & Leagues

Method Description Docs
get_sports() Get all available sports πŸ“–
get_leagues(sport) Get leagues for a sport πŸ“–

Events

Method Description Docs
get_events(sport, **filters) Get events with filters πŸ“–
get_event_by_id(event_id) Get specific event details πŸ“–
get_live_events(sport) Get currently live events πŸ“–
search_events(query) Search events by keyword πŸ“–

Odds

Method Description Docs
get_event_odds(event_id, bookmakers) Get odds for an event πŸ“–
get_odds_movement(event_id, bookmaker, market) Track odds changes πŸ“–
get_odds_for_multiple_events(event_ids, bookmakers) Get odds for multiple events πŸ“–
get_updated_odds_since_timestamp(since, bookmaker, sport) Get recently updated odds πŸ“–

Participants

Method Description Docs
get_participants(sport, search=None) Get teams/players πŸ“–
get_participant_by_id(participant_id) Get participant by ID πŸ“–

Bookmakers

Method Description Docs
get_bookmakers() Get all available bookmakers πŸ“–
get_selected_bookmakers() Get your selected bookmakers πŸ“–
select_bookmakers(bookmakers) Select bookmakers πŸ“–
clear_selected_bookmakers() Clear selection πŸ“–

Betting Analysis

Method Description Docs
get_arbitrage_bets(bookmakers, **options) Find arbitrage opportunities πŸ“–
get_value_bets(bookmaker, **options) Find value bets πŸ“–

⚠️ Error Handling

The SDK provides custom exceptions for different error scenarios:

from odds_api import (
    OddsAPIClient,
    OddsAPIError,
    InvalidAPIKeyError,
    RateLimitExceededError,
    NotFoundError,
    ValidationError
)

client = OddsAPIClient(api_key="your_api_key")

try:
    events = client.get_events(sport="basketball")
except InvalidAPIKeyError:
    print("Your API key is invalid")
except RateLimitExceededError:
    print("Rate limit exceeded - wait before retrying")
except NotFoundError:
    print("Resource not found")
except ValidationError as e:
    print(f"Invalid parameters: {e}")
except OddsAPIError as e:
    print(f"API error: {e}")

🌟 Why Odds-API.io?

  • βœ… Most Comprehensive Coverage - 250+ bookmakers across 20+ sports
  • βœ… Near-Zero Latency - Real-time odds updates with minimal delay
  • βœ… Direct Bet Links - Deep links directly to bookmaker bet slips
  • βœ… Value Bet Detection - Automatically calculated expected value
  • βœ… Historical Data - Access to past odds and results
  • βœ… Developer Friendly - Clean API design with excellent documentation

πŸ’‘ Use Cases

Build powerful betting tools and analytics:

  • 🎯 Arbitrage betting platforms
  • πŸ“Š Odds comparison sites
  • πŸ“ˆ Value betting calculators
  • πŸ€– Automated betting systems
  • πŸ“‰ Sports analytics dashboards
  • πŸ”” Odds movement alerts

πŸ†“ Free Tier Limitations

  • Limited to 2 bookmakers selected at once
  • 5,000 requests per hour (shared across all plans)
  • No WebSocket access on free tier

Upgrade for more features β†’

πŸ“‹ Requirements

  • Python 3.8 or higher
  • requests library (for sync client)
  • aiohttp library (for async client)

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Links

πŸ’¬ Support

Need help? We're here for you:

⚑ Quick Links


Built with ❀️ by the Odds-API.io team

About

Official Python SDK for Odds-API.io - Real-time sports betting odds from 250+ bookmakers

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages