Unlocking Hockey Insights: A Developer's Guide to API-HOCKEY Cognitive Actions

24 Apr 2025
Unlocking Hockey Insights: A Developer's Guide to API-HOCKEY Cognitive Actions

Introduction

In the realm of sports analytics, understanding game dynamics and team performance can set your application apart. The API-HOCKEY spec offers a rich set of Cognitive Actions designed to help developers integrate various hockey-related data into their applications seamlessly. These pre-built actions allow you to fetch statistics, retrieve league data, and analyze game events, delivering valuable insights to your users. In this guide, we will explore the capabilities of these actions and provide examples to aid in their integration.

Prerequisites

Before diving into the Cognitive Actions, ensure you have:

  • An API key for accessing the API-HOCKEY platform.
  • Basic knowledge of making HTTP requests and handling JSON data in your application.

Authentication typically involves passing your API key in the request headers. Here’s a conceptual overview of how this might look:

headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

Cognitive Actions Overview

Fetch Hockey Team Statistics

Description: Retrieve comprehensive statistics for a specific hockey team within a league and season, including historical data, standings, and odds.

  • Category: sports

Input

The input schema requires the following fields:

  • league (number): The unique identifier for the league. Default is 3.
  • season (number): The year representing the season. Default is 2019.
  • team (number): The unique identifier for the team. Default is 17.

Example Input:

{
  "team": 17,
  "league": 3,
  "season": 2019
}

Output

The output provides various statistics, including team details, games won, lost, goals for, and against.

Example Output:

{
  "team": {
    "id": 17,
    "logo": "https://media.api-sports.io/hockey/teams/17.png",
    "name": "Barrie Colts"
  },
  "games": {
    "wins": {
      "all": {
        "total": 33,
        "percentage": 0.478
      },
      ...
    },
    ...
  },
  ...
}

Conceptual Usage Example (Python)

import requests
import json

COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "07732ac7-c490-442d-b945-a2c9a172db74"  # Action ID for Fetch Hockey Team Statistics

payload = {
    "team": 17,
    "league": 3,
    "season": 2019
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Retrieve Hockey Leagues Data

Description: Retrieve information about hockey leagues including livescores, odds, standings, and statistics using a search query.

  • Category: sports

Input

The input schema requires:

  • search (string): The search term to query. Defaults to "NHL".

Example Input:

{
  "search": "NHL"
}

Output

The output includes details about the leagues, such as their names, IDs, and logos.

Example Output:

{
  "response": [
    {
      "id": 57,
      "name": "NHL",
      ...
    },
    ...
  ]
}

Conceptual Usage Example (Python)

action_id = "089e4035-fc9b-4d25-a03a-e0f6f89567f1"  # Action ID for Retrieve Hockey Leagues Data

payload = {
    "search": "NHL"
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Search Hockey Bets

Description: Perform searches on hockey bets across various leagues, providing live scores, odds, and statistics.

  • Category: sports

Input

The input schema can include:

  • search (string): A string for searching bets. Defaults to "way".
  • identifier (number): A numerical identifier for query purposes.

Example Input:

{
  "search": "way"
}

Output

The output provides a list of bet types available for hockey matches.

Example Output:

{
  "response": [
    {
      "id": 1,
      "name": "3Way Result"
    },
    ...
  ]
}

Conceptual Usage Example (Python)

action_id = "153bf373-a036-4937-9e53-6b94d297a662"  # Action ID for Search Hockey Bets

payload = {
    "search": "way"
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Search Bookmakers For Hockey Leagues

Description: Search for bookmakers related to hockey leagues, providing access to live scores, odds, and historical data.

  • Category: sports

Input

The input schema requires:

  • search (string): The search term for query. Defaults to "bwin".

Example Input:

{
  "search": "bwin"
}

Output

The output includes the details of the bookmakers found.

Example Output:

{
  "response": [
    {
      "id": 1,
      "name": "bwin"
    }
  ]
}

Conceptual Usage Example (Python)

action_id = "28a58db0-3de6-43a2-8ee7-3d92c273dd7b"  # Action ID for Search Bookmakers For Hockey Leagues

payload = {
    "search": "bwin"
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Retrieve Hockey Games by Timezone

Description: Retrieve a list of hockey games updated every 15 seconds for a specified timezone.

  • Category: sports

Input

The input schema requires:

  • queryDate (string): The date for the query in YYYY-MM-DD format. Defaults to "2020-10-02".
  • Optional fields like teamId, leagueId, etc.

Example Input:

{
  "queryDate": "2020-10-02"
}

Output

The output provides details of the games scheduled for the specified date.

Example Output:

{
  "response": [
    {
      "id": 8279,
      "date": "2020-10-02T09:00:00+00:00",
      ...
    }
  ]
}

Conceptual Usage Example (Python)

action_id = "2f67cca1-a62e-4e2f-8272-c121eb1ecc19"  # Action ID for Retrieve Hockey Games by Timezone

payload = {
    "queryDate": "2020-10-02"
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Fetch Available Timezones

Description: Retrieve a list of available timezones for integration with the games endpoint.

  • Category: sports

Input

No specific input is required for this action.

Example Input:

{}

Output

The output provides a list of available timezones.

Example Output:

{
  "response": [
    "America/New_York",
    "Europe/London",
    ...
  ]
}

Conceptual Usage Example (Python)

action_id = "806d4dc0-2924-4c94-a68f-9024233ef5b7"  # Action ID for Fetch Available Timezones

payload = {}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Search Countries in Hockey Data

Description: Perform a country search within a dataset of hockey leagues and cups.

  • Category: sports

Input

The input schema requires:

  • search (string): The search term for querying countries. Defaults to "cana".

Example Input:

{
  "search": "cana"
}

Output

The output provides the details of the countries found.

Example Output:

{
  "response": [
    {
      "id": 4,
      "code": "CA",
      "name": "Canada"
    }
  ]
}

Conceptual Usage Example (Python)

action_id = "875c1034-ad51-4daa-817d-d5a2c0edc891"  # Action ID for Search Countries in Hockey Data

payload = {
    "search": "cana"
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Retrieve League Stages

Description: Obtain a list of available stages for a specified hockey league.

  • Category: sports

Input

The input schema requires:

  • league (number): The unique identifier for the league.
  • season (number): The year representing the sports season.

Example Input:

{
  "league": 3,
  "season": 2019
}

Output

The output returns the stages available for the specified league.

Example Output:

{
  "response": [
    "OHL"
  ]
}

Conceptual Usage Example (Python)

action_id = "87a6bcb9-51a9-473c-8dd2-38e8f01c83b9"  # Action ID for Retrieve League Stages

payload = {
    "league": 3,
    "season": 2019
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Get League Standings

Description: Retrieve current standings for a specified hockey league or cup.

  • Category: sports

Input

The input schema requires:

  • league (number): The unique identifier for the league.
  • season (number): The year of the season.

Example Input:

{
  "league": 3,
  "season": 2019
}

Output

The output provides the current standings including team rankings and statistics.

Example Output:

{
  "response": [
    {
      "team": {
        "id": 25,
        "name": "London Knights",
        ...
      },
      "points": 92,
      "position": 1
    },
    ...
  ]
}

Conceptual Usage Example (Python)

action_id = "b47da834-46dd-46b7-af7c-6fcb52095434"  # Action ID for Get League Standings

payload = {
    "league": 3,
    "season": 2019
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Get Available League Groups

Description: Retrieve the list of available groups for a specified hockey league.

  • Category: sports

Input

The input schema requires:

  • league (number): The identifier for the league.
  • season (number): The year of the season.

Example Input:

{
  "league": 3,
  "season": 2019
}

Output

The output returns the available groups for the league.

Example Output:

{
  "response": [
    "Western Conference",
    "Eastern Conference",
    ...
  ]
}

Conceptual Usage Example (Python)

action_id = "b6399ad8-08ed-4e93-9604-cf938c889bf8"  # Action ID for Get Available League Groups

payload = {
    "league": 3,
    "season": 2019
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Retrieve Game Events

Description: Fetch all events associated with a specific hockey game using its unique game identifier.

  • Category: sports

Input

The input schema requires:

  • gameId (number): The unique numeric identifier for the game.

Example Input:

{
  "gameId": 8279
}

Output

The output includes details of events such as goals scored, penalties, and assists.

Example Output:

{
  "response": [
    {
      "team": {
        "id": 382,
        ...
      },
      "type": "goal",
      ...
    },
    ...
  ]
}

Conceptual Usage Example (Python)

action_id = "c4031de3-4e1c-4434-a70c-ee99bd462dba"  # Action ID for Retrieve Game Events

payload = {
    "gameId": 8279
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Get Teams Head To Head

Description: Retrieve the head-to-head comparison between two specified hockey teams.

  • Category: sports

Input

The input schema requires:

  • headToHead (string): A string representing the matchup. Defaults to "17-18".

Example Input:

{
  "headToHead": "17-18"
}

Output

The output provides details of past matches between the two teams.

Example Output:

{
  "response": [
    {
      "id": 218539,
      "date": "2012-12-30T00:30:00+00:00",
      ...
    },
    ...
  ]
}

Conceptual Usage Example (Python)

action_id = "c4520106-92b4-480c-aebc-c843f47003c7"  # Action ID for Get Teams Head To Head

payload = {
    "headToHead": "17-18"
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

RetrieveSeasonKeys

Description: Retrieve 4-digit season keys for various hockey leagues.

  • Category: sports

Input

No parameters are required for this action.

Example Input:

{}

Output

The output provides a list of season keys.

Example Output:

{
  "response": [
    2008,
    2009,
    ...
  ]
}

Conceptual Usage Example (Python)

action_id = "c7b0b080-fde1-4d51-b48a-7d525a392796"  # Action ID for RetrieveSeasonKeys

payload = {}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Retrieve Game Odds

Description: Access pre-match odds for hockey games.

  • Category: sports

Input

The input schema can include:

  • game (number): The unique identifier for the game. Defaults to 11590.
  • bet (number): The amount to bet. Must be a non-negative number.
  • Other optional fields like league, season, and bookmaker.

Example Input:

{
  "game": 11590
}

Output

The output provides the odds for the specified game.

Example Output:

{
  "response": [],
  "results": 0
}

Conceptual Usage Example (Python)

action_id = "c833c90b-dc21-4440-999a-43137b0dac0c"  # Action ID for Retrieve Game Odds

payload = {
    "game": 11590
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Description: Search for hockey teams across various leagues.

  • Category: sports

Input

The input schema requires:

  • searchTerm (string): A keyword used to perform a search. Defaults to "London Knights".

Example Input:

{
  "searchTerm": "London Knights"
}

Output

The output provides details about the teams matching the search term.

Example Output:

{
  "response": [
    {
      "id": 25,
      "name": "London Knights",
      ...
    }
  ]
}

Conceptual Usage Example (Python)

action_id = "f83ff652-9c30-4dd5-b31b-fa266ef7a2e5"  # Action ID for Perform Team Search

payload = {
    "searchTerm": "London Knights"
}

response = requests.post(
    COGNITIVE_ACTIONS_EXECUTE_URL,
    headers=headers,
    json={"action_id": action_id, "inputs": payload}
)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))

Conclusion

The API-HOCKEY Cognitive Actions provide a robust framework for developers to access a wealth of hockey data. By leveraging these actions, you can enhance your applications with rich insights into team performance, league standings, betting options, and more. Whether you're building a sports analytics platform or a gaming application, these tools can elevate the user experience dramatically. Start integrating these actions today to keep your users informed and engaged with the world of hockey!