Code Monkey home page Code Monkey logo

aws-step-functions-sports-data-polling's Introduction

Sports Data Polling

This project contains source code and supporting files for the serverless application which polls game data for your favorite NHL team and get notified when your team scores.

This application has been initally developed for the Lightning project of Pacific Science Center to honor the Seattle Kraken team using SportRadar.com API endpoints.

More information about this project can be found here. https://www.aboutamazon.com/news/aws/hockeys-newest-superfan-lights-up-seattle

You can change the team alias for your favorite NHL team according to documentation. https://developer.sportradar.com/docs/read/hockey/NHL_v7#nhl-api-overview

The project has been developed as an AWS CDK application using Typescript.

Note: This repository is slightly different than the initial project so that the application can be used for individual interests while keeping the core functionalities and features the same.

Prerequisites

  • You will need an AWS Account and IAM User created as well as configured in your development environment for CDK Development

    • More details how to create an AWS Account can be found here.
    • More details how to create an IAM User here.
    • More details how to get started with AWS CDK v2 here.
  • You will need to create a developer account for sportradar.com here.

    • Once registered, you will need to create an application.
    • Make sure that Issue a new key for NHL Trial option has been selected while creating your application.
    • You will be given a trial API key once you have created your application.

    There are two endpoints that the application is using.

Getting Started

git clone https://github.com/aws-samples/aws-step-functions-sports-data-polling
cd aws-step-functions-sports-data-polling
npm install
cdk bootstrap
cdk deploy --parameters teamId="sr:team:794340" --parameters emailAddress="your email address"

The parameter teamId is the id for your favorite NHL team used by sportradar.com. The default id is for Seattle Kraken but if you wanna change it for your favorite team, have a look at teams.json file for your team's id.

Once the application is deployed, it will automatically subscribe the email address that you provide as a parameter to the Scores topic.

Therefore, you will get a confirmation email similar to the following and you should confirm your subscription by clicking the "Confirm subscription" link to get scores in your email.

confirmation

Note: This email address doesn't have to be the same email address you used for sportradar.com registration.

The last step is updating the API key called SportradarApiKey in AWS Systems Manager Parameter Store using your trial key from sportradar.com.

More info how to update a parameter can be found here

Application Lifycycle

lifecycle

  • The application will deploy the following main resources.

    • An EventBridge Rule to trigger check-games-lambda function
    • A Lambda function with the file check-games-lambda
    • A Lambda function with the file game-data-lambda
    • A Step Functions State Machine
    • An SNS Topic with email subscription
  • The EventBridge rule will invoke check-games-lambda function once a day at 8 AM PT. The lambda function will check the games scheduled for the day of invokation.

  • If there is an NHL game for Seattle Kraken then the lambda function will create another EventBridge rule that will start an execution of the State Machine.

  • The State Machine invokes the game-data-lambda function every minute. (This is intentionally high due to trial key limitations.)

  • The game-data-lambda function checks the game data for scores.

  • If there is a new score, the lambda function publishes this new score to the SNS topic.

  • SNS topic notifies the subscribed email address automatically as below.

    lifecycle

  • When the game is over, the State Machine will stop the execution.

aws-step-functions-sports-data-polling's People

Contributors

amazon-auto avatar dependabot[bot] avatar simsek97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.