bttmly / nba

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

player movement API #14

Closed bttmly closed 8 years ago

bttmly commented 9 years ago

There is a JSON endpoint serving the player movement data that gets visualized in the stats.nba.com play-by-play area. To see what I'm talking about go here, then click on one of the plays and select "movement" (not "video").

I've done some initial work (on the movement branch) to pull the data for an entire game from the NBA's api, but as usual, the data is in unlabeled tuples to reduce data size, making it unclear what the data actually means. There is some example JSON in the /src/apis/movement directory, any help understanding this scheme would be much appreciated!

brandly commented 9 years ago

quoting from http://savvastjortjoglou.com/nba-play-by-play-movements.html

[3,
 1431486313010,
 715.32,
 19.0,
 None,
 [[-1, -1, 43.51745, 10.76997, 1.11823],
  [1610612745, 1891, 43.21625, 12.9461, 0.0],
  [1610612745, 2772, 90.84496, 7.79534, 0.0],
  [1610612745, 2730, 77.19964, 34.36718, 0.0],
  [1610612745, 2746, 46.24382, 21.14748, 0.0],
  [1610612745, 201935, 81.0992, 48.10742, 0.0],
  [1610612746, 2440, 88.12605, 11.23036, 0.0],
  [1610612746, 200755, 84.41011, 43.47075, 0.0],
  [1610612746, 101108, 46.18569, 16.49072, 0.0],
  [1610612746, 201599, 78.64683, 31.87798, 0.0],
  [1610612746, 201933, 65.89714, 25.57281, 0.0]]]
  1. The 1st item in moments[0] is the period or quarter that this moment occurred in.
  2. 2nd item is unix time.
  3. The 3rd item is the time left in the game clock.
  4. The 4th item is the time left on the shot clock.
  5. I don't know what the 5th item represents.
  6. The 6th item is a list of 11 lists, each containing the coordinates for a player on the court or the coordinates of the ball.
    1. The first of these 11 lists contains information on the ball.
      1. The first 2 items represnt the teamid and playerid values that identify this list as the ball.
      2. The next 2 items are the x and y values that represent the location of the ball on the court.
      3. And the 5th and final item represents the radius of the ball. This value changes throughout the animation depending on the elevation of the ball. The greater the radius, the higher up the ball is. So if a player shoots the ball, the ball will increase in size, reach its maximum size at the apex of the shooting arch and then decrease in size as it falls down.
    2. The next 10 lists within this 6th item represent the 10 players on the court. The information within each of these lists is the same as it is for the ball.
      1. The first 2 items are the teamid and playerid that identify this list as a specific player.
      2. The next 2 items represent the x and y coordinates for the player's location on the court.
      3. And the last item is the radius of the player, which is irrelevant.
bttmly commented 9 years ago

@brandly beautiful, thanks! Next up I'll be working on methods that will identify plays where a given player touches the ball, passes, shoots, turns it over, etc.

Any help or suggestions on API design or desired functionality much encouraged

bttmly commented 8 years ago

I split this out into it's own package https://github.com/nickb1080/nba-movement