Zmalski / NHL-API-Reference

Unofficial reference for the NHL API endpoints.
MIT License
221 stars 16 forks source link

Giveaways and takeaways #10

Open camarguin opened 8 months ago

camarguin commented 8 months ago

in the old api we had Giveaways and takeaways from each player per game. It seems I can't see it anymore through the box score or other place other than play-by-play. is it still a working progress to be easier to get the giveaways and takeaways like?

{
            "playerId": 8479996,
            "sweaterNumber": 8,
            "name": {
              "default": "C. Glass"
            },
            "position": "C",
            "goals": 0,
            "assists": 0,
            "points": 0,
            "plusMinus": 0,
            "pim": 0,
            "hits": 1,
            "giveaways": 1, <-- this
            "takeaways": 0, <-- this
            ...
}

Thank you

timo-eloranta commented 8 months ago

Interesting. Odd that those fields have been left out. The boxscore endpoint does however include gameReports section, from where one can find a link to eventSummary, e.g. https://www.nhl.com/scores/htmlreports/20232024/ES020601.HTM. As you can see, this file is unfortunately in HTML (instead of JSON), but it DOES include the giveaways (GV) and the takeaways (TK).

minter commented 8 months ago

They're available at the team level on the landing URL (in-game and postgame) if that's helpful

URL: https://api-web.nhle.com/v1/gamecenter/2023020763/landing

Data:

    "teamGameStats": [
      {
        "category": "sog",
        "awayValue": "33",
        "homeValue": "31"
      },
      {
        "category": "faceoffPctg",
        "awayValue": "49.1",
        "homeValue": "50.9"
      },
      {
        "category": "powerPlay",
        "awayValue": "0/1",
        "homeValue": "1/6"
      },
      {
        "category": "pim",
        "awayValue": "12",
        "homeValue": "2"
      },
      {
        "category": "hits",
        "awayValue": "20",
        "homeValue": "24"
      },
      {
        "category": "blockedShots",
        "awayValue": "13",
        "homeValue": "9"
      },
      {
        "category": "giveaways",
        "awayValue": "3",
        "homeValue": "4"
      },
      {
        "category": "takeaways",
        "awayValue": "10",
        "homeValue": "10"
      }
    ],
camarguin commented 8 months ago

Interesting. Odd that those fields have been left out. The boxscore endpoint does however include gameReports section, from where one can find a link to eventSummary, e.g. https://www.nhl.com/scores/htmlreports/20232024/ES020601.HTM. As you can see, this file is unfortunately in HTML (instead of JSON), but it DOES include the giveaways (GV) and the takeaways (TK).

Yes, I was hoping they could bring those fields in JSON instead HTML. Let's see if they bring some updates in the future. Thanks for mentioning about the report tho. I did not see it clear before your mention

camarguin commented 8 months ago

They're available at the team level on the landing URL (in-game and postgame) if that's helpful

URL: https://api-web.nhle.com/v1/gamecenter/2023020763/landing

Data:

    "teamGameStats": [
      {
        "category": "sog",
        "awayValue": "33",
        "homeValue": "31"
      },
      {
        "category": "faceoffPctg",
        "awayValue": "49.1",
        "homeValue": "50.9"
      },
      {
        "category": "powerPlay",
        "awayValue": "0/1",
        "homeValue": "1/6"
      },
      {
        "category": "pim",
        "awayValue": "12",
        "homeValue": "2"
      },
      {
        "category": "hits",
        "awayValue": "20",
        "homeValue": "24"
      },
      {
        "category": "blockedShots",
        "awayValue": "13",
        "homeValue": "9"
      },
      {
        "category": "giveaways",
        "awayValue": "3",
        "homeValue": "4"
      },
      {
        "category": "takeaways",
        "awayValue": "10",
        "homeValue": "10"
      }
    ],

I was actually looking for those data being available for each player instead of the whole team like the old api. But Thanks for commenting about the /landing url.