npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mediaplatform/basketball-sdk

v1.2.10

Published

### Installation

Downloads

199

Readme

JavaScript Basketball SDK

Installation

Install Basketball SDK dependency

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

or

yarn add @mediaplatform/sportal365-basketball-sdk

Usage

Import Basketball SDK dependency

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

Initialize Basketball SDK

const SDK = new Core(config);

The config argument is an object with the following properties:

  • dataConfigApiUrl - API URL (required)
  • dataConfigApiKey - API KEY (required)
  • dataConfigPlayoffApiUrl - API url for playoff data (required if you want to use .playoff module)
  • dataConfigLang - example: 'en'
  • dataConfigProject - Project name (required)
  • dataConfigOddClient - default value: 'sportal' (optional)
  • dataConfigTimezone - example: 'Europe/Sofia' (required)
  • dataConfigCompetitionList - example: 'default' (required)

Game Module

Initialize module

const gameModule = SDK.game(gameId);

gameId - the argument is required (gameId: string). It defines the required game.

Usage

gameModule
  .withDateConfig({ dateFormat: 'string'} )
  .withOdds({ bettingId: 'string', market: 'string', oddFormat: 'string', preEventOddsOnly: 'boolean' })
  .get();

Corresponding output should be:

{
 	 game: GameModel
};

Module methods

  • withDateConfig({ dateFormat: string }) - Use this method to format the date by specific dateFormat.

    • dateFormat - Default value "dd.MM".
  • 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 information for the game and filtered odds by the given providers id, markets and formated odds values.

Games Module

Initialize module

const gamesModule = SDK.games({
	competitionIds: string[];
	seasonIds: string[];
	stageIds: string[];
	sortDirection: string;
	limit: string;
	roundFilter: [ {roundId: string, stageId: string } ];
});

Usage 1

gamesModule
  .groupGamesByCompetition()
  .withDateConfig({ date: 'string', dateFormat: 'string'} )
  .withStatusFilter(statusType: 'string')
  .withOddsOnly(oddsOnly: 'boolean')
  .withOdds({ bettingId: 'string', market: 'string', oddFormat: 'string', preEventOddsOnly: 'boolean' })
  .get();

Corresponding output should be:

{
  games: [{
	 competition: CompetitionModel,
	 games: [{ game: GameModel  }]
	}]
};

Module methods

  • competitionIds(string[]) - (optional) Use this method to filter by competition.

  • seasonIds(string[]) - (optional) Use this method to filter by season.

  • stageIds(string[]) - (optional) Use this method to filter by stage.

  • roundFilter([ {roundId: string, stageId} ]) - (optional) Use this method to filter by roundIds.

  • limit(string) - (optional) Use this method to limit the number of matches.

  • sortDirection(string) - (optional) Use this method to set the direction in which the programme matches are sorted - 'asc'/'desc'.

  • groupGamesByCompetitions() - Use this method to group the games by competitions.

  • withStatusFilter(statusType: string) - Use this method to get games by specific statusType.

    • statusType -The argument should be a string ( 'LIVE', 'UPCOMING', 'FINISHED', 'INTERRUPTED', 'CANCELLED', 'UNKNOWN', 'DELETED')
  • withDateConfig({ date: string, dateFormat: string }) - Use this method to format the date by specific dateFormat.

    • date -The argument should be a string('yyyy.MM.dd'). Use this method to get games from specific start date.
    • dateFormat - Default value "dd.MM".
  • 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.
  • withOddsOnly(oddsOnly:boolean) - Use this method to filter out matches that don't have odds. The default value of the oddsOnly argument is false.

Usage 2

gamesModule
  .withDateConfig({ date: 'string', dateFormat: 'string'} )
  .withOdds({ bettingId: 'string', market: 'string', oddFormat: 'string', preEventOddsOnly: 'boolean' })
  .get();

Corresponding output should be:

{
  games: [
		{ game: GameModel  }
	]
};
  • get() - the method is mandatory - Based on called methods, it returns the built object with all requested information for the games from specific date, grouped by competitions and filtered odds by the given providers id, markets and formated odds values.

Standing Module

Initialize module

const standingModule = SDK.standing(competitionId);

competitionId - the argument is required (competitionId: string).

Usage 1

standingModule.get();

If the competition has response the output should be:

{
	seasons: [ SeasonModel ],
	stagesForActiveSeason: [ StageModel ],
	standingsGroupTypes: [StandingsGroupModel],
	standings: [StandingObjectModel]
};

Usage 2

standingModule
	.getSeason(seasonId)
	.get();

Corresponding output should be:

{
	seasons: [ SeasonModel ],
	stagesForActiveSeason: [ StageModel ],
	standingsGroupTypes: [StandingsGroupModel],
	standings: [StandingObjectModel]
};

Module methods:

  • getSeason(seasonId: string)
    • seasonId - The seasonId argument should be a string. The following example will return available stage and standing data (if there is one) for a given season.

Usage 3

standingModule
	.getSeason(seasonId)
	.withStageType(type)
	.get();

Corresponding output should be:

{
	seasons: [ SeasonModel ],
	stagesForActiveSeason: [ StageModel ],
	standingsGroupTypes: [StandingsGroupModel],
	standings: [StandingObjectModel]
};

Module methods:

  • withStageType(type: string)
    • type - The type argument should be a string. The following example will return all stages with this type (if there is one).

Usage 4

standingModule
	.getStage(stageId)
	.get();

Corresponding output should be:

{
	stagesForActiveSeason: [ StageModel ],
	standingsGroupTypes: [StandingsGroupModel],
	standings: [StandingObjectModel]
};

Module methods:

  • getStage(stageId: string)

    • stageId - The stageId argument should be a string. The following example will return available standing data (if there is one) for a given stage. The method cannot be called if the getSeason() has been called.
  • get() - the method is mandatory - Based on called methods, it returns the built object with seasons, stagesForActiveSeason and standings.

Stage Module

Initialize module

const stageModule = SDK.stage(stageId);

stageId - the argument is required (stageId: string).

Usage

stageModule
	.withRules()
	.get();

Corresponding output should be:

{
	standingsGroupTypes: [StandingsGroupModel],
	standings: [StandingObjectModel]
};

Module methods:

  • withRules() - Use this method to include extracted data of all existing rules in the standings.
  • get() - the method is mandatory - Based on called methods, it returns the built object with standingsGroupTypes and standings.

Stage list Module

Initialize module

const stageListModule = SDK.stageList(competitionId);

competitionId - the argument is required (competitionId: string).

Usage 1

stageListModule.get();

If the competition has response the output should be:

{
	stageList: [ StageModel ],
};

Usage 2

stageListModule
	.getSeason(seasonId)
	.get();

Corresponding output should be:

{
	stageList: [ StageModel ],
};

Module methods:

  • getSeason(seasonId: string)
    • seasonId - The seasonId argument should be a string. The following example will return available stage data (if there is one) for a given season.

Usage 3

stageListModule
	.getSeason(seasonId)
	.withStageType(type)
	.get();

Corresponding output should be:

{
	stageList: [ StageModel ],
};

Module methods:

  • withStageType(type: string)
    • type - The type argument should be a string. The following example will return all stages with this type (if there is one).

Competition module

Initialize module

const competitionModule = SDK.competition(competitionId);

competitionId - the argument is required (competitionId: string).

Usage

competitionModule
  .withSeasons([seasonIds])
  .get()

Corresponding output should be:

{
  competition: CompetitionModel
  seasons: SeasonModel[],
};

Module methods:

  • withSeason(seasonIds: string[]) - The seasonIds argument is optional and should be an array of strings. If no season ids were passed or are an empty array, the output should include all seasons. If there are passed seasons ids, the result should include only them.
  • The method Output is:
{ seasons: SeasonModel[] };

Playoff Module

Initialize module

const playoffModule = SDK.playoff({ stageId: 'string', competition: { id: 'string', status: 'string' } });

stageId - the argument is optional and it is nested in object property ({ stageId: string }). At least stageId or competition should be passed.

competition - the argument is optional and it is nested in object property as its own object ({ id: string, status: string }). At least stageId or competition should be passed.

Usage

playoffModule
  .playoff({ stageId: 'string', competition: { id: 'string', status: 'string' } })
  .get();

Corresponding output should be:

{
 	 playoff: PlayoffFormattedModel
};

Module methods

  • playoff({ stageId: 'string', competition: { id: 'string', status: 'string' } })

    • stageId - the argument is a string. If no stageId is provided, the request will be sent with competition.
    • competition - the argument is a object with properties 'id' and 'status' ({ id: 'string', status: 'string' }). If stageId is passed, the request will be sent with stageId, NOT competition data.
  • get() - the method is mandatory - Based on called methods, it returns the built object with all requested information for the playoff.

Tournament programme module

Initialize module

const tournamentProgrammeModule = SDK.tournamentProgramme({
	competitionId: string,
	seasonId: string,
	stageId: string,
	filterType: string,
	sortDirection: string,
	limit: string,
	roundFilter: [ {roundId: string, stageId: string} ],
});

Corresponding output should be:

{
	programme: [{
		stage: StageModel,
		games: [{ round: RoundModel, games: GameModel[] }] }],
	competition: CompetitionModel,
};

Module methods:

  • competitionId(string) - Use this method to filter by competition.

  • seasonId(string) - Use this method to filter by season.

  • stageId(string) - Use this method to filter by stage.

  • roundFilter([ {roundId: string, stageId} ]) - Use this method to filter by roundIds.

  • limit(string) - Use this method to limit the number of matches.

  • fiilterType(string) - Use this metod to filter upcoming games or games that were already played or postponed - 'fixtures'/'results'.

  • sortDirection(string) - Use this method to set the direction in which the programme matches are sorted - 'asc'/'desc'.

  • withOdds(options: { bettingId: string, preEventOddsOnly: boolean; oddFormat: string; }) - the argument is an object where:

    • bettingId property should be astring to filter odds result. Example: "43" - will return available odds data (if there is one) only for odds with the given provider.
    • market - the argument is a string. Example: "1x2"- will return only "1x2" markets data (if there is one).
    • preEventOddsOnly is a property which shows odds only when the match has not started yet. The default value of the argument is false.
    • oddFormat is a property which sets the type of the odds. The type argument is a string with one of the following string values: 'FRACTIONAL'/'MONEYLINE'/'DECIMAL'. The default value is set to 'DECIMAL'.
  • get() - the method is mandatory - Based on called methods, it returns the built object with programme information for specific competition.

Team programme module

Initialize module

const teamProgrammeModule = SDK.teamProgramme({
	teamId: string,
	seasonId: string,
	stageId: string,
	teamType: string,
	filterType: string,
	sortDirection: string,
	limit: string,
	roundFilter: [ {roundId: string, stageId: string} ],
});

Corresponding output should be:

{
	programme: [{
		competition: CompetitionModel,
		games: [{ round: RoundModel, games: GameModel[] }] }],
	team: TeamModel,
};

Module methods:

  • teamId(string) - Use this method to filter by team.

  • seasonId(string) - Use this method to filter by season.

  • stageId(string) - Use this method to filter by stage.

  • teamType(string) - Use this metod to filter by team type- 'home'/'away'.

  • roundFilter([ {roundId: string, stageId} ]) - Use this method to filter by roundIds.

  • limit(string) - Use this method to limit the number of matches.

  • fiilterType(string) - Use this metod to filter upcoming games or games that were already played or postponed - 'fixtures'/'results'.

  • sortDirection(string) - Use this method to set the direction in which the programme matches are sorted - 'asc'/'desc'.

  • withOdds(options: { bettingId: string, preEventOddsOnly: boolean; oddFormat: string; }) - the argument is an object where:

    • bettingId property should be astring to filter odds result. Example: "43" - will return available odds data (if there is one) only for odds with the given provider.
    • market - the argument is a string. Example: "1x2"- will return only "1x2" markets data (if there is one).
    • preEventOddsOnly is a property which shows odds only when the match has not started yet. The default value of the argument is false.
    • oddFormat is a property which sets the type of the odds. The type argument is a string with one of the following string values: 'FRACTIONAL'/'MONEYLINE'/'DECIMAL'. The default value is set to 'DECIMAL'.
  • get() - the method is mandatory - Based on called methods, it returns the built object with programme information for specific team.

Seasons module

Initialize module

const seasonsModule = SDK.seasons({ competitionId: string, teamId: string, limit: string, offset: string });

competitionId - the argument is optional (competitionId: string) teamId - the argument is optional (teamId: string). limit - the argument is optional (limit: string). offset - the argument is optional (offset: string).

Corresponding output should be:

{
  seasons: SeasonModel[],
};
  • get() - the method is mandatory - Based on called methods, it returns the built object with seasons.

Modules Errors

If some of the modules' requests were not successful, the corresponding module should return an error message.

Example:

{
   gamesError: "Request failed with status code 500",
   gameError: "Request failed with status code 500",
   standingsError: "Request failed with status code 500",
   ...
}

Module with no data

If the API response has no data, the module should not return anything.