Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

ContactSign Up
Community Plugin
View plugin on GitHub

CI semantic-release

gatsby-source-nhl

A Gatsby source plugin for sourcing data into your Gatsby application from the NHL.

The plugin creates nodes from portions of the NHL API. It allows you to query data such as teams, players, stadiums and more.

Install

npm install --save gatsby-source-nhl

Disclaimer

This is an unofficial plugin and is using the publicly accessible parts of the NHL API. There is nothing stopping the NHL to restrict the API or to push out break changes.

How to use

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-nhl',
      options: {},
    },
  ],
};

How to query

You can query team nodes using the following:

{
  allNhlTeam {
    edges {
      node {
        teamName
        shortName
        name
      }
    }
  }
}

Querying dynamic information

You may run into cases where you want up to date information such as statistics on players and teams. To do this you would need to fetch data on the client, not at build time. You can read more about this here.

Most nodes have an attribute called externalId which you can query. This is the Id used by the NHL to identify records. You’ll need to use this Id when querying parts of their api.

© 2023 Gatsby, Inc.