bttmly / nba

Node.js client for nba.com API endpoints
MIT License
710 stars 180 forks source link

Is it still possible to get shot chart detail? #107

Open ghost opened 3 years ago

ghost commented 3 years ago

Hello, I tried to fetch data about shot chart details, but it seems like stats.nba.com no longer has the servlet to handle this request. Can I still get shot chart details? Thank you!!

nba.stats.shots({
            PlayerID: this.props.playerId
        }).then((response) => {
            const final_shots = response.shot_Chart_Detail.map(shot => ({
                x: (shot.locX + 250) / 10,
                y: (shot.locY + 50) / 10,
                action_type: shot.actionType,
                shot_distance: shot.shotDistance,
                shot_made_flag: shot.shotMadeFlag,
            }));

            const courtSelection = d3.select("#shot-chart");
            const chart_court = court().width(500);
            const chart_shots = shots().shotRenderThreshold(2).displayToolTips(true).displayType("hexbin");
            courtSelection.call(chart_court);
            courtSelection.datum(final_shots).call(chart_shots);
        });
JDhilon commented 3 years ago
NBA.stats.shots({PlayerID: 201939}).then(data => {
        const final_shots = data.shot_Chart_Detail.map(shot => ({
            x: (shot.locX + 250) / 10,
            y: (shot.locY + 50) / 10,
            action_type: shot.actionType,
            shot_distance: shot.shotDistance,
            shot_made_flag: shot.shotMadeFlag,
        }));

        console.log(final_shots[0]);
    });

This works for me and will log

{
  x: 13,
  y: 29,
  action_type: 'Pullup Jump shot',
  shot_distance: 26,
  shot_made_flag: 0
}

Are you getting a specific error?