NFLGames

NFLGames datasource lets you create subscriptions for the next NFL games and results. With Hooks Query Language you can customize what data and when you want to receive:

Input Output Credits Freshness
NFLGame 5 seconds

What you can get from this API

  • Get an update when a team starts or ends a game with a score and other NFLGame data.
  • Get an update when a team wins a game or ends a game with a score.
  • Get all the games for an NFL team.

How to Use

As every datasource at Hooks, you can choose to pull the data in your preferred format or to set up a webhook to receive the data when something happens.  

As we offer many datasources, we have developed a custom SQL-Like language (Hooks Query Language) to be able to query each datasource in the same format. To create a subscription the first thing you need to do is to define an HQL query and then send this query to create subscription endpoint.

NFLGames datasource has no mandatory parameters and you can use an optional WHERE clause to filter the output data (NFLGame) in order to receive just what you need. Hooks will then call your webhook once new data is available for your query. 

Step 1: Customize subscription

Hooks provide an elegant mechanism for creating subscriptions using Hooks Query Language. It has a similar notation to SQL and lets you define each subscription with a simple HQL query.

The following query will create a subscription to “Send me updates for all future New England Patriots games 1 hour before the start”:

SELECT * FROM NFLGames 
WHERE status = 'FUTURE' and
away_team.team_name = 'New England Patriots' OR
home_team.team_name = 'New England Patriots' AND
start_datetime.countdown = 3600

Once this HQL query has new results – 1-hour before New England Patriots play a new game – Hooks will send NFLGame object to your webhook:

{
    "matches_count": 1,
    "results": [
        {
            "_entity_type": "NFLGame",
            "_id": "NFLGame_400999173",
            "away_score": null,
            "away_team": {
                "_entity_type": "NFLTeam",
                "_id": "NFLTeam_NE",
                "acronym": "NE",
                "division": "AFC East",
                "id": "NFLTeam_NE",
                "team_name": "New England Patriots"
            },
            "game_id": "400999173",
            "home_score": null,
            "home_team": {
                "_entity_type": "NFLTeam",
                "_id": "NFLTeam_PHI",
                "acronym": "PHI",
                "division": "NFC East",
                "id": "NFLTeam_PHI",
                "team_name": "Philadelphia Eagles"
            },
            "link": "http://espn.go.com/nfl/game?gameId=400999173",
            "start_datetime": null,
            "status": "FUTURE"
        }
    ]
}

Please take a look at the above object. You can use WHERE clause to filter all the properties of NFLGame object and only get updates for what you need. 

Optional: Pull the data

You can use fetch endpoint to request the data currently available for your HQL query. Hooks will return the latest data available for HQL query. The result may be empty if we currently don’t have any data available for your query. NFLGames datasource has data for today, tomorrow and yesterday games.

To pull the data for “All future New England Patriots games” you can use.

SELECT * FROM NFLGames 
WHERE away_team.team_name = 'New England Patriots' OR 
home_team.team_name = 'New England Patriots'

This query will return all soccer games planned for yesterday, today and tomorrow:

{
    "matches_count": 1,
    "results": [
        {
            "_entity_type": "NFLGame",
            "_id": "NFLGame_400999173",
            "away_score": null,
            "away_team": {
                "_entity_type": "NFLTeam",
                "_id": "NFLTeam_NE",
                "acronym": "NE",
                "division": "AFC East",
                "id": "NFLTeam_NE",
                "team_name": "New England Patriots"
            },
            "game_id": "400999173",
            "home_score": null,
            "home_team": {
                "_entity_type": "NFLTeam",
                "_id": "NFLTeam_PHI",
                "acronym": "PHI",
                "division": "NFC East",
                "id": "NFLTeam_PHI",
                "team_name": "Philadelphia Eagles"
            },
            "link": "http://espn.go.com/nfl/game?gameId=400999173",
            "start_datetime": null,
            "status": "FUTURE"
        }
    ]
}

Step 2: Create subscription

To create a subscription you just need to send an HQL query and a title of your choice to subscriptions endpoint:

curl -H "Content-type: application/json" -d '{
	"query": "SELECT * FROM NFLGames WHERE status=\'FUTURE\' AND away_team.team_name=\'New England Patriots\' or home_team.team_name=\'New England Patriots\' and start_datetime.countdown = 3600"
}' 'http://api.hooksdata.io/v1/subscriptions'

Hooks will then create a subscription on our servers and call your webhook once new data is available for your query.

Examples

Using HQL you can customize what data you want to select from a datasource and also filter the output using a WHERE clause. The following examples show how you can use HQL to choose just the data you need:

New England Patriots are going to play a game in 1 hour.

SELECT * FROM NFLGames 
WHERE status = 'FUTURE'
AND away_team.team_name = 'New England Patriots'
OR home_team.team_name = 'New England Patriots'
AND start_datetime.countdown = 3600

New England Patriots won Philadelphia Eagles with a score 42:27.

SELECT * FROM NFLGames
WHERE status = 'FINISHED'
AND away_team.team_name = 'Philadelphia Eagles'
AND home_team.team_name = 'New England Patriots') AND home_score = 42 AND away_score = 27

NFL game ended with a score 27:42 or 42:27.

SELECT * FROM NFLGames 
WHERE status = 'FINISHED' 
AND ((away_score = 27 AND home_score = 42) OR (home_score = 27 AND away_score = 42))