Afischbacher / Nhl.Api

The Official Unofficial .NET NHL API
MIT License
25 stars 3 forks source link

Include on-ice players with live feed data #21

Closed andersme closed 2 years ago

andersme commented 2 years ago

It would be really excellent if the plays from the live feed included the players that were on the ice at the time of the play. This can be determined by pulling in data from:

https://api.nhle.com/stats/rest/en/shiftcharts?cayenneExp=gameId=${gamePk}

Having the team strength (5v5, 5v4, etc.) could also be gleamed from this data.

Afischbacher commented 2 years ago

Hey @andersme

Thanks for opening this issue, I appreciate it, I love idea 💡 and will get it in for 1.7.0

I may ask you for some clarification on exactly what you are looking for.

Thanks again

andersme commented 2 years ago

Probably just an array of player ids on the ice for each event. This is useful for calculating Corsi numbers or expected goals stats.

Afischbacher commented 2 years ago

Hey @andersme,

Just looking for clarification on your request, to confirm, you are just looking to add a simple array of player identifiers like this, playersOnIce is the added key value pair

{
        "players" : [ {
          "player" : {
            "id" : 8479353,
            "fullName" : "Brett Howden",
            "link" : "/api/v1/people/8479353"
          },
          "playerType" : "Winner"
        }, {
          "player" : {
            "id" : 8470638,
            "fullName" : "Patrice Bergeron",
            "link" : "/api/v1/people/8470638"
          },
          "playerType" : "Loser"
        } ],
        "result" : {
          "event" : "Faceoff",
          "eventCode" : "BOS279",
          "eventTypeId" : "FACEOFF",
          "description" : "Brett Howden faceoff won against Patrice Bergeron"
        },
        "about" : {
          "eventIdx" : 148,
          "eventId" : 279,
          "period" : 2,
          "periodType" : "REGULAR",
          "ordinalNum" : "2nd",
          "periodTime" : "09:05",
          "periodTimeRemaining" : "10:55",
          "dateTime" : "2021-12-15T01:20:23Z",
          "goals" : {
            "away" : 4,
            "home" : 0
          }
        },
        "coordinates" : {
          "x" : -69.0,
          "y" : 22.0
        },
        "team" : {
          "id" : 54,
          "name" : "Vegas Golden Knights",
          "link" : "/api/v1/teams/54",
          "triCode" : "VGK"
        },
        "playersOnIce" : [ 8474157, 8474565, 8475215, 8475913, 8476905, 8477447 ]
      }
andersme commented 2 years ago

That would be good. But it would be better if they were split into to arrays, one for the offensive players for that play and one for the defensive players.

Keep in mind for blocked shots, the team id is actually the defensive team not the offensive team, so there would have to be some logic there. Perhaps adding another property to a play that is OffensiveTeam or DefensiveTeam could be useful.

Afischbacher commented 2 years ago

Yeah that would be something to consider for that as well, good point @andersme I will probably get you to look at the pull request once I have it ready

andersme commented 2 years ago

Sounds good. I appreciate all your hard work on this.

Afischbacher commented 2 years ago

Hey @andersme,

I don't want to hold up the 1.7.0 release, so for now I will just implement the players on ice and split them by home and away teams for now in 2 separate arrays, such as this and then you can open up another issue for specifically determining which team is the offensive or defensive team.

Thanks again!

Best Regards

andersme commented 2 years ago

That sounds perfectly reasonable, thanks!

Afischbacher commented 2 years ago

https://github.com/Afischbacher/Nhl.Api/pull/24

Afischbacher commented 2 years ago

Released v1.70! So I will close this issue :) 👍