Socket
Socket
Sign inDemoInstall

mlb-game-day

Package Overview
Dependencies
6
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mlb-game-day

MLB GameDay API


Version published
Maintainers
1
Install size
463 kB
Created

Readme

Source

mlb-game-day

A JavaScript wrapper around the MLB Game Day API that can be used on the server or browser.

Install

$ npm install mlb-game-day -S

Use with TypeScript

You can use this library with TypeScript. To do this, you'll also need to grab a couple external type definition dependencies (axios and es6-promise).

I use typings to handle TypeScript type definition dependencies.

$ npm install typings -g

then from the directory of your application

$ typings install axios es6-promise --ambient

typings will install the type definitions to a typings folder which contains a main.d.ts file which can referenced from your project's typescript config.

API

Methods

Methods

gameIds(date)

Retrieves a list of game id's for a given date. If no date is provided, the current date is used.

Arguments
  1. date (Date): A date for which game id's will be retrieved.
Returns

(Axios.IPromise<string[]>): A list of string id's.

Example
import { gameIds } from 'mlb-game-day';

const date = new Date('4/8/2016');

gameIds(date).then(console.log);

// ['2016_04_08_nyamlb_detmlb_1', ... ]

getGameBoxScoreById(id)

Retrieves the box score for the given game id.

Arguments
  1. id (String): The game id
Returns

(Promise): The box score for the given id.

Example
import { gameIds, getGameBoxScoreById } from 'mlb-game-day';

const date = new Date('4/8/2016');

gameIds(date).then(ids => {
  getGameBoxScoreById(ids[0]).then(console.log)
});

// { home_sname: 'San Francisco', ... }

getGameEventsById(id)

Retrieves the game events for the given game id.

Arguments
  1. id (String): The game id
Returns

(Promise): The events for the given id.

Example
import { gameIds, getGameEventsById } from 'mlb-game-day';

const date = new Date('4/8/2016');

gameIds(date).then(ids => {
  getGameEventsById(ids[0]).then(console.log)
});

// { inning: [ { num: 1, ... }, ... ], ... }

Use Locally

$ npm install && npm run typings

LICENSE

MIT

Keywords

FAQs

Last updated on 17 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc