Developer Tools

SDKs

Official client libraries to integrate the Baseball API in your language of choice.

Python SDK

Official Python client, zero runtime dependencies.

View on GitHub

A Python SDK for the Baseball API built on the standard library's urllib, with TypedDict response types and the same endpoints and error behavior as the TypeScript SDK.

Installation

pip install apibaseball

Requirements: Python 3.11+

Quick Usage

import os
from apibaseball import BaseballClient

client = BaseballClient(api_key=os.environ["APIBASEBALL_KEY"])

leagues = client.get_leagues(page=1)
games = client.get_games(from_="2026-07-01", to="2026-07-07")

Key Features

  • Authentication via header (X-Api-Key) or query parameter
  • Configurable request timeout (in seconds)
  • Pluggable transport for tests, proxies or logging
  • Built-in pagination with metadata
  • BaseballApiError with HTTP status and error codes
  • TypedDict response types for type checkers and IDEs

Supported Endpoints

  • Countries, leagues, and leagues by country
  • Teams by league and player data
  • Game schedules with date range filtering
  • Live game feeds
  • Team injuries and statistics
  • Odds data
  • League standings