Afischbacher / Nhl.Api

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

Add current datetime to game events #46

Open tyler-roper opened 9 months ago

tyler-roper commented 9 months ago

(We spoke on Reddit about this and you requested I open an issue)

The previous API endpoints for retrieving live game data included a datetime field for each event. The newest endpoints don't seem to provide this information anymore. Examples below.

This makes it impossible to chronologically sort events across several games, for example.

Thank you!

Example of old event shape:

{
  "result": {
    "eventCode": "ANA89",
    "eventTypeId": "HIT",
    "description": "Tomas Nosek hit Adam Henrique",
    "event": "Hit"
  },
  "players": [
    {
      "playerType": "Hitter",
      "player": {
        "link": "/api/v1/people/8477931",
        "fullName": "Tomas Nosek",
        "id": 8477931
      }
    },
    {
      "playerType": "Hittee",
      "player": {
        "link": "/api/v1/people/8474641",
        "fullName": "Adam Henrique",
        "id": 8474641
      }
    }
  ],
  "about": {
    "eventIdx": 123,
    "dateTime": "2023-01-09T02:42:01Z",   <------------------------------------------------
    "eventId": 89,
    "period": 2,
    "periodType": "REGULAR",
    "ordinalNum": "2nd",
    "periodTime": "04:13",
    "periodTimeRemaining": "15:47",
    "goals": {
      "away": 2,
      "home": 1
    }
  },
  "coordinates": {
    "x": 32,
    "y": -39
  },
  "team": {
    "name": "Boston Bruins",
    "link": "/api/v1/teams/6",
    "id": 6,
    "triCode": "BOS"
  }
}

Example of new event shape:

{
  "eventId": 57,
  "period": 1,
  "periodDescriptor": {
    "number": 1,
    "periodType": "REG"
  },
  "timeInPeriod": "00:25",
  "timeRemaining": "19:35",
  "situationCode": "1551",
  "homeTeamDefendingSide": "left",
  "typeCode": 509,
  "typeDescKey": "penalty",
  "sortOrder": 13,
  "details": {
    "xCoord": -94,
    "yCoord": 23,
    "zoneCode": "O",
    "typeCode": "MIN",
    "descKey": "tripping",
    "duration": 2,
    "committedByPlayerId": 8478493,
    "drawnByPlayerId": 8481564,
    "eventOwnerTeamId": 30
  }
}
Afischbacher commented 8 months ago

Hi Tyler,

I have ideas on how I would like to execute this, but I will need time to work through this problem, I will provide you with an update when I have one.

Thanks!

Afischbacher commented 5 days ago

Hey @tyler-roper,

Been a while, but I have found some time to get around to this and should be releasing it in v3.6.0! It will be far from a perfect solution, but may help you achieve your use case.

Thanks!