{"id":27960,"library":"mlb-statsapi","title":"MLB Stats API","description":"A Python wrapper for the MLB Stats API, providing easy access to MLB data including schedules, standings, player stats, and more. Version 1.9.0 is the latest stable release. Updates are frequent, with several releases per year.","status":"active","version":"1.9.0","language":"python","source_language":"en","source_url":"https://github.com/toddrob99/MLB-StatsAPI","tags":["mlb","baseball","api-wrapper","sports"],"install":[{"cmd":"pip install mlb-statsapi","lang":"bash","label":"Stable release"}],"dependencies":[{"reason":"HTTP library for API calls","package":"requests","optional":false}],"imports":[{"note":"Package name uses hyphens, but import uses underscores implicitly. The top-level module is 'statsapi', not 'mlb_statsapi'.","wrong":"from mlb_statsapi import ...","symbol":"statsapi","correct":"import statsapi"}],"quickstart":{"code":"import statsapi\n\n# Get today's schedule\nschedule = statsapi.schedule()\nprint(schedule)\n\n# Get player info\nplayer = statsapi.lookup_player('Mike Trout')\nprint(player)\n\n# Get standings for a specific division\nstandings = statsapi.standings_data(divisionId=200)\nprint(standings.keys())","lang":"python","description":"Quick example of common operations: schedule, player lookup, and standings."},"warnings":[{"fix":"Use 'import statsapi' in your code.","message":"The module to import is 'statsapi', not 'mlb_statsapi'. The package name on PyPI is 'mlb-statsapi', but after installation, you use 'import statsapi'.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to v1.6.1+ or wrap in try/except.","message":"The schedule function may raise a KeyError if game data is missing (e.g., no team score or name). This is partially fixed in v1.6, but edge cases remain.","severity":"gotcha","affected_versions":"<1.6.1"},{"fix":"Upgrade to v1.8.1+ if you need date filtering for stats.","message":"The 'startDate' and 'endDate' parameters for stats endpoint were added in v1.8.1. Older versions do not support these parameters.","severity":"breaking","affected_versions":"<1.8.1"},{"fix":"Ensure you pass params as a dict or rely on new default.","message":"The 'get()' method's 'params' parameter now defaults to empty dict (v1.8+). Previously it required explicit passing. Code relying on old default may break.","severity":"deprecated","affected_versions":">=1.8"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Change import to 'import statsapi'.","cause":"Incorrect import path; using underscore instead of the correct module name 'statsapi'.","error":"ModuleNotFoundError: No module named 'mlb_statsapi'"},{"fix":"Check if game is complete before accessing team data, or upgrade to latest version.","cause":"Schedule function expects certain keys in the API response; missing data for unplayed games or incomplete schedule.","error":"KeyError: 'teams'"},{"fix":"Upgrade to mlb-statsapi>=1.9.0.","cause":"Attempting to use game_uniforms endpoint that was added in v1.9.0.","error":"AttributeError: module 'statsapi' has no attribute 'game_uniforms'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}