Skip to content

Scraping the NHL REST endpoint and loading into CRM for no reason

Notifications You must be signed in to change notification settings

tcorcor1/NhlStatsCrm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NhlStatsCrm

🚧 🚧 DISCLAIMER 🚧 🚧

11/14/2023 - Unfortunately as of November 2023 the NHL API has moved to https://api-web.nhle.com/. It has also undergone a lot of changes so this project will no longer work in it's current state. This is a pretty new development so documentation is catching up but if you would like to learn more about the new API please see this: https://api-web.nhle.com/application.wadl

Summary

The purpose of this project is to take all players and stats from the NHL REST endpoint and load into Dynamics 365 on a daily basis.

There are scheduled Azure functions that will run overnight and upsert players/stats using the NHL API's id's as an alternate/foreign key.

The API supports some GET requests although this API isn't intended for use by end-users since data should be observed in Dynamics 365.

Demo

Technologies

  • .NET 6
  • Mediatr
  • Automapper
  • Microsoft Identity Platform
  • CD with Github Actions
  • Power Platform Dataverse Client
  • Azure
    • App Service
    • Functions

Network

Local Development

If you haven't already, I highly recommend joining the Microsoft Developer Program. You will receive your own Microsoft 365 tenant which will include a Dynamics instance among many other things. So long as you continue to use this environment for development, your license will be renewed each 90 days. Check out sign-up info HERE.

Initial project setup

  • Create your appsettings.Production.json and appsettings.Development.json files. There is an example appsettings.json in the project
  • Set up Azure app registration
  • Create app role NhlStatsCrm.Contributor and assign to app user
  • Replace values in AzureAd prop of appsettings with those from app registration
  • Create your Dataverse connection string replacing default values below
  • Recommend using Azure Key Vault as mechanism for passing secrets to your App Service / Function app
  • Install Dynamics solution HERE.
{
	"AzureAd": {
		"Instance": "https://login.microsoftonline.com/",
		"Domain": "yourdomain.onmicrosoft.com",
		"TenantId": "00000000-0000-0000-0000-000000000000",
		"ClientId": "00000000-0000-0000-0000-000000000000",
		"Audience": "api://00000000-0000-0000-0000-000000000000",
		"CallbackPath": "/signin-oidc"
	},
	"ConnectionStrings": {
		"DATAVERSE": "AuthType=ClientSecret;ClientId=00000000-0000-0000-0000-000000000000;ClientSecret=gg;URL=https://yourdomain.crm.dynamics.com/;"
	},
	"Logging": {
		"LogLevel": {
			"Default": "Information",
			"Microsoft.AspNetCore": "Warning"
		}
	},
	"AllowedHosts": "*"
}

NHL REST API Docs

Big thanks to the legends below. Without you all paving the way, starting projects like this would be much harder. Thank you! 🙏

About

Scraping the NHL REST endpoint and loading into CRM for no reason

Topics

Resources

Stars

Watchers

Forks

Languages