@mediaplatform/sportal365-multisport-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.2.5 • Public • Published

JavaScript Multisport SDK

Installation

Install Multisport SDK dependency

npm install @mediaplatform/sportal365-multisport-sdk --save

or

yarn add @mediaplatform/sportal365-multisport-sdk

Usage

Import Multisport SDK dependency

import Core from "@mediaplatform/sportal365-multisport-sdk"

Initialize Multisport SDK

const SDK = new Core(config);

The config argument is an object with the following properties:

  • dataConfigApiUrl - API URL (required)
  • dataConfigApiKey - API KEY (required)
  • dataConfigLang - example: 'en'
  • dataConfigProject - Project name (required)
  • dataConfigOddClient - default value: 'sportal' (optional)
  • dataConfigTimezone - example: 'Europe/Sofia' (required)
  • dataConfigCompetitionList - example: 'default' (required)

Competitions Module

Initialize module

const competitionsModule = SDK.competitions();

Usage

competitionsModule
  .getDate(date: string)
  .get();

Corresponding output should be:

{
 	 competitions: CompetitionsМоdule
};

Module methods

  • getDate(date: string)

    • date - the argument is a string. Format for date is - yyyy-mm-dd. - is required
  • get() - the method is mandatory - Based on called methods, it returns the built object with all requested competitions information and filtered depending on the passed sport and date.

Events Module

Initialize module

const eventsModule = SDK.events();

Usage

eventsModule
  .getDate(date: string)
  .getSport(sport?: SportTypes)
  .withOdds({ bettingId: 'string', market: 'string', oddFormat: 'string', preEventOddsOnly: 'boolean' })
  .getCompetitionIds(competitionIds: string)
  .get();

Corresponding output should be:

{
 	 events: EventsМоdule
};

Module methods

  • getSport(sport: SportTypes) - Use this method to get competitions only for a specific sport.

    • sport example: "tennis". - is optional
  • getDate(date: string)

    • date - the argument is a string. Format for date is - yyyy-mm-dd. - is required
  • getCompetitionIds(competitionIds: string)

    • competitionIds - the argument is a string. Pass the id's of the competitions you want to get the events for by concatenating the id's with a comma and passing them as a single string. - is optional
  • withOdds({ bettingId: string, market: string, oddFormat: string, preEventOddsOnly: boolean })

    • bettingId - the argument is a string. If no bettingId is provided, the result will be filtered by the first provider from the response
    • market - the argument is a string. Example: "1x2"- will return only "1x2" markets data (if there is one).
    • oddFormat - the argument is a string ( FRACTIONAL, DECIMAL, MONEYLINE ). Default value: "DECIMAL". You could pass an odds format to format odds values.
    • preEventOddsOnly - the argument is a boolean which shows odds only when the game has not started yet. The default value of the argument is false.
  • get() - the method is mandatory - Based on called methods, it returns the built object with all requested events information and filtered depending on the passed sport, date and competitionIds.

Handlers

Note 1: Status text is handled on the front end because different sports have different status finished texts - this status which comes from the API is used only for business logic and not as a text, but as a type instead

Note 2: Results is ignored if the event hasn’t started

Note 3: Because of the different types of sports different name prop is being returned - some sports require three_letter_code and if no three_letter_code is available the name of the same is being returned (basketball and football for example)

Note 4: Placeholders are handled on the front end. Reason for this is because there are different placeholders depending of the sport being displayed

Readme

Keywords

none

Package Sidebar

Install

npm i @mediaplatform/sportal365-multisport-sdk

Weekly Downloads

53

Version

1.2.5

License

MIT

Unpacked Size

1.3 MB

Total Files

40

Last publish

Collaborators

  • mediaplatform