mls-js-sdk

2.1.2 • Public • Published

MLS API SDK for JavaScript

Develop and deploy applications, mobile and web, with popular JavaScript Frameworks using MLS API SDK for JavaScript.

Install

npm i mls-js-sdk

# or

yarn add mls-js-sdk

Example of Usage

import {
  login, getAllHistoricalData, getHistoricalDataById,
  getAllRealTimeData, getRealTimeDataById, getAllPlayers,
  getPlayerById, getAllAssists, getAssistById, getAllOffence,
  getOffenceById, getAllTopScorers, getTopScorerById, getAllTeams,
  getTeamById, getAllFixtures, getFixtureById, getAllStandings,
  getStandingById, getAllNews, getNewsById,
} from 'mls-js-sdk';

(async () => {
    try {
        const credentials = {
            username: "your_username",
            password: "your_password"
        };

        const loginResponseData = await login(credentials);
        console.log("Login response data:", loginResponseData);

        const token = loginResponseData.Document;

        const allHistoricalData = await getAllHistoricalData(token);
        console.log("All historical data:", allHistoricalData);

        const id = "uuid";
        const historicalDataById = await getHistoricalDataById(id, token);
        console.log(`Historical data by id (${id}):`, historicalDataById);

        const allRealTimeData = await getAllRealTimeData(token);
        console.log("All real-time data:", allRealTimeData);

        const realTimeId = "uuid";
        const realTimeDataById = await getRealTimeDataById(realTimeId, token);
        console.log(`Real-time data by id (${realTimeId}):`, realTimeDataById);

        const playersQueryParams: PlayersQueryParams = {
            limit: 5,
            offset: 0
        };
        const allPlayers = await getAllPlayers(token, playersQueryParams);
        console.log("All players:", allPlayers);

        const playerId = "uuid";
        const playerDataById = await getPlayerById(playerId, token);
        console.log(`Player data by id (${playerId}):`, playerDataById);

        const allAssists = await getAllAssists(token);
        console.log("All assists:", allAssists);

        const assistId = "uuid";
        const assistDataById = await getAssistById(assistId, token);
        console.log(`Assist data by id (${assistId}):`, assistDataById);

        const allOffence = await getAllOffence(token);
        console.log("All offence:", allOffence);
    
        const offenceId = "uuid";
        const offenceDataById = await getOffenceById(offenceId, token);
        console.log(`Offence data by id (${offenceId}):`, offenceDataById);

        const allTopScorers = await getAllTopScorers(token);
        console.log("All top scorers:", allTopScorers);
    
        const topScorerId = "uuid";
        const topScorerDataById = await getTopScorerById(topScorerId, token);
        console.log(`Top scorer data by id (${topScorerId}):`, topScorerDataById);

        const allTeams = await getAllTeams(token);
        console.log("All teams:", allTeams);
    
        const teamId = "uuid";
        const teamDataById = await getTeamById(teamId, token);
        console.log(`Team data by id (${teamId}):`, teamDataById);

        const allFixtures = await getAllFixtures(token);
        console.log("All fixtures:", allFixtures);
    
        const fixtureId = "uuid";
        const fixtureDataById = await getFixtureById(fixtureId, token);
        console.log(`Fixture data by id (${fixtureId}):`, fixtureDataById);

        const allStandings = await getAllStandings(token);
        console.log("All standings:", allStandings);
    
        const standingId = "uuid";
        const standingDataById = await getStandingById(standingId, token);
        console.log(`Standing data by id (${standingId}):`, standingDataById);

        const allNews = await getAllNews(token);
        console.log("All news:", allNews);
    
        const newsId = "uuid";
        const newsDataById = await getNewsById(newsId, token);
        console.log(`News data by id (${newsId}):`, newsDataById);

    } catch (error) {
        console.error("Error during fetching data:", error);
    }
})();

The MLS API documentation is available here. If you need further assistance, don't hesitate to contact us.

License

This project is licensed under the BSD 3-Clause License.

Copyright

(c) 2020 - 2024 Hori Systems Limited.

Package Sidebar

Install

npm i mls-js-sdk

Weekly Downloads

0

Version

2.1.2

License

BSD-3-Clause

Unpacked Size

23.1 kB

Total Files

20

Last publish

Collaborators

  • 0xnu