Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player Snap % #15

Open
smcnulty1 opened this issue Nov 21, 2019 · 6 comments
Open

Player Snap % #15

smcnulty1 opened this issue Nov 21, 2019 · 6 comments

Comments

@smcnulty1
Copy link

Is there a way to return player snap % by week?

@SwapnikKatkoori
Copy link
Owner

I think so. The documentation is not 100% clear on what data is available, but looking at the actual JSON there seems to be data for tm_off_snp, tm_def_snap, tm_st_snp as well as off_snp and def_snp for some players.

https://api.sleeper.app/v1/stats/nfl/regular/2019/1

@BenHarten
Copy link

I just tried that, but it doesn't work. Do you know if they changed their API? It seems like the "stats" call is not available anymore...

@SwapnikKatkoori
Copy link
Owner

@BenHarten Yeah it looks like the stats endpoint is not publicly available anymore :(

@albertlyu
Copy link

Just stumbled upon this repo. This is my first year playing in a Sleeper league, and it appears that they are sourcing leagues, teams, stats, and projections from a GraphQL endpoint now. Whether or not that was the same for the Sleeper app last season or not, I am not sure, but it does appear you can get player-level weekly stats and projections by providing player IDs without authentication.

Figured I'd pass along the example cURL below in case anyone has time to take a look. Either way, thanks for open-sourcing this Sleeper API wrapper @SwapnikKatkoori.

curl 'https://sleeper.app/graphql' \
  -H 'accept: application/json' \
  -H 'content-type: application/json' \
  --data-binary '{"operationName":"get_player_score_and_projections_batch","variables":{},"query":"query get_player_score_and_projections_batch {\n        \n        nfl__regular__2020__1__stat: stats_for_players_in_week(sport: \"nfl\",season: \"2020\",category: \"stat\",season_type: \"regular\",week: 1,player_ids: [\"4017\",\"4098\",\"4666\"]){\n          game_id\nopponent\nplayer_id\nstats\nteam\nweek\nseason\n        }\n      \n\n        nfl__regular__2020__1__proj: stats_for_players_in_week(sport: \"nfl\",season: \"2020\",category: \"proj\",season_type: \"regular\",week: 1,player_ids: [\"4017\",\"4098\",\"4666\"]){\n          game_id\nopponent\nplayer_id\nstats\nteam\nweek\nseason\n        }\n      \n      }"}' \
  --compressed

Response:

{
  "data": {
    "nfl__regular__2020__1__stat": [],
    "nfl__regular__2020__1__proj": [
      {
        "week": 1,
        "team": "HOU",
        "stats": {
          "rush_yd": 29.64,
          "rush_td": 0.28,
          "rush_fd": 2.96,
          "rush_att": 6.5,
          "rush_40p": 0.07,
          "rush_2pt": 0.07,
          "pts_std": 24.96,
          "pts_ppr": 24.96,
          "pts_half_ppr": 24.96,
          "pass_yd": 280.15,
          "pass_td_40p": 0.32,
          "pass_td": 1.94,
          "pass_sack": 3.76,
          "pass_inc": 15.52,
          "pass_fd": 28.01,
          "pass_cmp_40p": 1.06,
          "pass_cmp": 24.08,
          "pass_att": 39.6,
          "pass_2pt": 0.21,
          "idp_int": 0.99,
          "gp": 1,
          "fum_lost": 0.29,
          "fum": 0.65,
          "cmp_pct": 60.81
        },
        "season": "2020",
        "player_id": "4017",
        "opponent": "KC",
        "game_id": "202010116"
      },
      {
        "week": 1,
        "team": "CLE",
        "stats": {
          "rush_yd": 22.96,
          "rush_td": 0.29,
          "rush_fd": 2.3,
          "rush_att": 6,
          "rush_2pt": 0.05,
          "rec_yd": 30.56,
          "rec_tgt": 4.5,
          "rec_td": 0.14,
          "rec_fd": 3.06,
          "rec_5_9": 0.7,
          "rec_40p": 0.35,
          "rec_30_39": 0.35,
          "rec_20_29": 0.7,
          "rec_10_19": 1.05,
          "rec_0_4": 0.7,
          "rec": 3.5,
          "pts_std": 7.79,
          "pts_ppr": 11.29,
          "pts_half_ppr": 9.54,
          "gp": 1,
          "fum_lost": 0.06,
          "fum": 0.13,
          "bonus_rec_rb": 3.5
        },
        "season": "2020",
        "player_id": "4098",
        "opponent": "BAL",
        "game_id": "202010103"
      },
      {
        "week": 1,
        "team": "ATL",
        "stats": {
          "xpmiss": 0.26,
          "xpm": 2.67,
          "xpa": 2.94,
          "pts_std": 8.41,
          "pts_ppr": 8.41,
          "pts_half_ppr": 8.41,
          "gp": 1,
          "fgmiss_50p": 0.13,
          "fgmiss_40_49": 0.19,
          "fgmiss_30_39": 0.06,
          "fgm_50p": 0.2,
          "fgm_40_49": 0.52,
          "fgm_30_39": 0.52,
          "fgm_20_29": 0.46,
          "fgm": 1.7,
          "fga": 2.09
        },
        "season": "2020",
        "player_id": "4666",
        "opponent": "SEA",
        "game_id": "202010102"
      }
    ]
  }
}

@SwapnikKatkoori
Copy link
Owner

@albertlyu Oh wow, that's a great find. Thanks for passing this along.

@oliverclark15
Copy link

@albertlyu How'd you figure that out? Curious what else may or may not be available w/o auth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants