Git Product home page Git Product logo

Comments (6)

toddrob99 avatar toddrob99 commented on July 25, 2024 2

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.

WillMusing avatar WillMusing commented on July 25, 2024

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.

toddrob99 avatar toddrob99 commented on July 25, 2024

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.

WillMusing avatar WillMusing commented on July 25, 2024

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.

WillMusing avatar WillMusing commented on July 25, 2024

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.

toddrob99 avatar toddrob99 commented on July 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.