Source code for nhl.statsapi.api

import requests

from .endpoints import BASE
from . import parse
from ..list import List


[docs]def conference(id): json = requests.get("{}/conferences/{}".format(BASE, id)).json() return parse.parse_conference(json["conferences"][0])
[docs]def conferences(): json = requests.get("{}/conferences/{}".format(BASE, "")).json() return List(parse.parse_conference(item) for item in json["conferences"])
[docs]def division(id): json = requests.get("{}/divisions/{}".format(BASE, id)).json() return parse.parse_division(json["divisions"][0])
[docs]def divisions(): json = requests.get("{}/divisions/{}".format(BASE, "")).json() return List(parse.parse_division(item) for item in json["divisions"])
[docs]def franchise(id): json = requests.get("{}/franchises/{}".format(BASE, id)).json() return parse.parse_franchise(json["franchises"][0])
[docs]def franchises(): json = requests.get("{}/franchises/{}".format(BASE, "")).json() return List(parse.parse_franchise(item) for item in json["franchises"])
[docs]def game(id): json = requests.get("{}/game/{}/feed/live".format(BASE, id)).json() return parse.parse_game(json)
[docs]def player(id): json = requests.get("{}/people/{}".format(BASE, id)).json() return parse.parse_player(json["people"][0])
[docs]def players(ids): return List([player(id) for id in ids])
[docs]def team(id): json = requests.get("{}/teams/{}".format(BASE, id)).json() return parse.parse_team(json["teams"][0])
[docs]def teams(ids=None): if isinstance(ids, list): suffix = ",".join(map(str, ids)) json = requests.get("{}/teams/?teamId={}".format(BASE, suffix)).json() return List(parse.parse_team(item) for item in json["teams"]) else: json = requests.get("{}/teams/{}".format(BASE, "")).json() return List(parse.parse_team(item) for item in json["teams"])
[docs]def venue(id): json = requests.get("{}/venues/{}".format(BASE, id)).json() return parse.parse_venue(json["venues"][0])
[docs]def venues(): json = requests.get("{}/venues/{}".format(BASE, "")).json() return List(parse.parse_venue(item) for item in json["venues"])