Comments (6)
You can fetch the unformatted data the same way statsapi.roster()
does, using statsapi.get("team_roster", <params>)
. Here is the function in the source code.
from mlb-statsapi.
Thank you so much @toddrob99. I much appreciated your response!
So the exercise I am working on is to find the team Id / team name based on the pitcher Id (from every pitch) to analyze the pitcher performance. Since I can't find any function to get team Id from pitcher Id, the path I am going is to use the pitcher Id from a specific game -> pitcher first name, last name -> look up the name from team roster of all time (lots of data to aggregate) -> find the team(s) has this pitch name or pitcher Id. Is there any better way to do this?
from mlb-statsapi.
Where are you getting the pitch data from? If it's from the game endpoint, the team information is in there too.
If you truly have pitch data with a pitcher id but no team info, you can look up the player from the pitcher id using the person endpoint and statsapi.get().
If I were analyzing all pitches from all games in a given season, I would start with the schedule endpoint to get a list of gamePks, then loop through the game endpoint for each gamePk and collect the team, pitcher, and pitch data from there.
from mlb-statsapi.
Thanks again @toddrob99. I tried the team_roster but couldn't get the right data yet. Still working on it. For example,
roster_list = statsapi.get("team_roster", params= { "teamId": 4104, "rosterType": "fullRoster", "season" : 2018})
It returns without the actual roster. I am not sure if I am using it the correct way:
{'copyright': 'Copyright 2024 MLB Advanced Media, L.P. Use of any content on this page acknowledges agreement to the terms posted here http://gdx.mlb.com/components/copyright.txt',
'link': '/api/v1/teams/4104/roster',
'teamId': 4104,
'rosterType': 'fullSeason'}
from mlb-statsapi.
By the way, for your question about pitch data, I got it from https://github.com/jldbc/pybaseball. It contains detail pitching data around every pitch since 2018. I thought analyzing the pitching style/speed by team over time could be valuable information.
This pybaseball data does have gamePk.
from mlb-statsapi.
It seems like the API doesn't have roster data for minor league teams, because if I change the teamId to 143 (Philadelphia Phillies) it does return the roster data.
https://statsapi.mlb.com/api/v1/teams/4104/roster?rosterType=fullRoster&season=2018
https://statsapi.mlb.com/api/v1/teams/143/roster?rosterType=fullRoster&season=2018
from mlb-statsapi.
Related Issues (20)
- Standings_data division parameter should accept divisionId instead of only abbreviation HOT 5
- Past 7 Day stats for player id HOT 1
- Get request for 'team_stats' returning 404 HOT 1
- Return line score when using schedule end point HOT 2
- dataclass() got an unexpected keyword argument 'kw_only' HOT 2
- TypeError: Teamrecords.__init__() got an unexpected keyword argument 'eliminationnumbersport' HOT 2
- Determining a list of teams that a player played on HOT 1
- SSL: SSLV3_ALERT_HANDSHAKE_FAILURE HOT 1
- game_contextMetrics 404 Not Found for url HOT 6
- Unexpected behavior in lookup_player() when season is not specified HOT 1
- Incorrect seasons endpoint documentation HOT 2
- boxscore_data function returns incorrect and incomplete batting notes. HOT 2
- Player Stats Error HOT 10
- Typos HOT 5
- Get Team Mark HOT 2
- Extra Games in Schedule HOT 2
- Normalize diacritics in player lookup HOT 6
- The divisions endpoint allows 'season' as an optional endpoint.
- Thanks Todd! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlb-statsapi.