Skip to content

Latest commit

 

History

History
executable file
·
185 lines (146 loc) · 5.99 KB

README.md

File metadata and controls

executable file
·
185 lines (146 loc) · 5.99 KB

Strapi logo

Open-source Rocket League API written in TypeScript

The first open-source Rocket League API written in TypeScript, flexible and fully customizable with powerful features.


NPM Version NODEJS Version



Getting Started

Read this Getting Started tutorial to set up your project.

⏳ Installation

Install TSLeague:

npm install

Edit Proxies:

  • Edit src/proxy/ProxyManager.ts to setup http proxies.

Setup Steam API Key:

  • Edit src/steam/SteamAPI.ts to setup your Steam API.

Steam API Key is required if you want to check steam accounts

Enjoy, everything is done 🎉

Supported operating systems:

  • Ubuntu LTS/Debian 9.x
  • Windows 10/11

(Please note that TSLeague may work on other operating systems, but these are not tested nor officially supported at this time.)

Node:

TSLeague only supports maintenance and LTS versions of Node.js. Please refer to the Node.js release schedule for more information. NPM versions installed by default with Node.js are supported. Generally it's recommended to use yarn over npm where possible.

TSLeague Version Recommended Minimum
1.0 and up 20.x 18.x

License

See the LICENSE file for licensing information.

Example Usage

Here's a basic example of how to use the Rocket League API:

Specific Season:

// Example for a specific season
const api = new RocketLeagueAPI({
    season: Season.SEASON_28,
    accountType: AccountType.EPIC,
    username: 'SomePlayer',
})

async function getSeasonStats() {
    const data = await api.fetchData()
    if (!data) {
        this.logger.error('Error loading data.')
        return
    }

    try {
        // Season 28 Stats for Ranked Doubles 2v2
        const seasonStats = await api.getStats(Playlist.RANKED_DOUBLES_2V2)
        if (seasonStats) {
            this.logger.log(`Rank: ${seasonStats.getRank()}`)
            this.logger.log(`Division: ${currentSeasonStats.getDivision()}`)
            this.logger.log(`Division Up: ${currentSeasonStats.getDivisionUp()}`)
            this.logger.log(`Division Down: ${currentSeasonStats.getDivisionDown()}`)
            this.logger.log(`Rating: ${seasonStats.getMMR()}`)
            this.logger.log(`Peak Rating: ${seasonStats.getPeak()}`)
            this.logger.log(`Matches Played: ${seasonStats.getMatchesPlayed()}`)
            this.logger.log(`Win Streak: ${seasonStats.getStreak()}`)
        }
    } catch (error) {
        this.logger.error('Error fetching stats:', error)
    }
}

Current Season:

// Example for the current season
const api = new RocketLeagueAPI({
    accountType: AccountType.EPIC,
    username: 'SomePlayer',
})

async function getCurrentSeasonStats() {
    const data = await api.fetchData()
    if (!data) {
        this.logger.error('Error loading data.')
        return
    }

    try {
        // Current Season Stats for Ranked Doubles 2v2
        const currentSeasonStats = await api.getStats(Playlist.RANKED_DOUBLES_2V2)
        if (currentSeasonStats) {
            this.logger.log(`Rank: ${currentSeasonStats.getRank()}`)
            this.logger.log(`Division: ${currentSeasonStats.getDivision()}`)
            this.logger.log(`Division Up: ${currentSeasonStats.getDivisionUp()}`)
            this.logger.log(`Division Down: ${currentSeasonStats.getDivisionDown()}`)
            this.logger.log(`Rating: ${currentSeasonStats.getMMR()}`)
            this.logger.log(`Peak Rating: ${currentSeasonStats.getPeak()}`)
            this.logger.log(`Matches Played: ${currentSeasonStats.getMatchesPlayed()}`)
            this.logger.log(`Win Streak: ${currentSeasonStats.getStreak()}`)
        }
    } catch (error) {
        this.logger.error('Error fetching stats:', error)
    }
}

Global Stats: Here's a basic example of how to get the global stats:

Warning: use current season for fetch global stats

// Example for the global stats
const api = new RocketLeagueAPI({
    accountType: AccountType.EPIC,
    username: 'SomePlayer',
})

async function getGlobalStats() {
    const data = await api.fetchData()
    if (!data) {
        this.logger.error('Error loading data.')
        return
    }

    try {
        // Global Stats
        const globalStats = await api.getGlobalStats()
        if (globalStats) {
            this.logger.log(`Season Reward: ${globalStats.getSeasonReward()}`) //Rank name: Supersonic Legend
            this.logger.log(`Season Reward Icon: ${globalStats.getSeasonRewardIcon()}`) //Rank Icon
            this.logger.log(`Wins: ${globalStats.getTotalWins()}`)
            this.logger.log(`Shots: ${globalStats.getTotalShots()}`)
            this.logger.log(`Goals: ${globalStats.getTotalGoals()}`)
            this.logger.log(`Saves: ${globalStats.getTotalSaves()}`)
            this.logger.log(`Assists: ${globalStats.getTotalAssists()}`)
            this.logger.log(`MVPs: ${globalStats.getTotalMVPs()}`)
            this.logger.log(`Goal Shot Ratio: ${globalStats.getGoalShotRatio()}`)
        }
    } catch (error) {
        this.logger.error('Error fetching stats:', error)
    }
}