Russ Goldstein • about 1 year ago
MLB API data question
Hello - I'm running into some issues using the documentation provided by MLB for some of their API endpoints.
For example, the endpoint https://statsapi.mlb.com/api/v1/people/657077/stats?stats=season&daysBack=150&season=2024 should return statistics for this player from the last 150 days, but it's returning their full season stats. Here is the swagger JSON for the endpoint (removed some optional data for brevity):
"/api/v1/people/{personId}/stats": {
"get": {
"tags": [
"Person"
],
"summary": "View a players stats",
"operationId": "stats_3",
"parameters": [
{
"name": "personId",
"in": "path",
"description": "Unique Player Identifier. Format: 434538, 429665, etc",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "stats",
"in": "query",
"description": "Type of statistics. Format: Individual, Team, Career, etc. Available types in /api/v1/statTypes",
"required": true,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/StatType"
}
}
},
{
"name": "season",
"in": "query",
"description": "Season of play",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "daysBack",
"in": "query",
"description": "Returns results from the last 'X' days (Starting from yesterday).",
"required": false,
"schema": {
"type": "integer",
"format": "int32"
}
},
Another simple example is the league leaders endpoint: https://statsapi.mlb.com/api/v1/stats/leaders?season=2024&statType=season
This returns no data at all. I'm not sure if I'm misunderstanding the documentation? Any help would be greatly appreciated. Thank you.
Comments are closed.

4 comments
Michelle Brain Manager • about 1 year ago
Thanks for sending this over! I've asked the team and hope to hear back soon
Aayush Garg • about 1 year ago
Hi Michelle, I need your help accessing the APIs from the statsAPI.mlb.com website. Please help
Michelle Brain Manager • about 1 year ago
Hello Aayush, Thanks for joining the hackathon! Be sure to check out the resources (https://next2025challenge.devpost.com/resources) and the MLB™ Provided Datasets Colab notebook (https://colab.research.google.com/drive/1QcZD-_VK-Fa9ZC_iNy6Cth0n67KF2dSC?usp=sharing). The MLB Stats API (see documentation here:https://console.cloud.google.com/storage/browser/gcp-mlb-hackathon-2025/datasets/mlb-statsapi-docs) provides access to various MLB historical and present day data feeds, without authentication.
Michelle Brain Manager • about 1 year ago
Sorry for the slow response! The team tried to troubleshoot this but came to the conclusion to assume those endpoints don't work as intended and try to only work off ones that are returning the expected data. Thank you for this feedback and best of luck with your project!