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.
npm install --save gatsby-source-nhl
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.
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: 'gatsby-source-nhl',
options: {},
},
],
};
You can query team nodes using the following:
{
allNhlTeam {
edges {
node {
teamName
shortName
name
}
}
}
}
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.