Skip to content

liamcottle/valorant.js

Repository files navigation

VALORANT.js

This is an unofficial NodeJS library for interacting with the VALORANT APIs used in game.

Install

To use this library in your own NodeJS app, you can install it via npm.

npm install @liamcottle/valorant.js

Usage

First, Create a new Valorant.API instance with the region associated with your player data.

const Valorant = require('@liamcottle/valorant.js');
const valorantApi = new Valorant.API(Valorant.Regions.AsiaPacific);

If your region is not available in the Valorant.Regions class, but you know your region code, you can pass it in directly:

const valorantApi = new Valorant.API('NA');

Once you have a Valorant.API instance, you need to obtain an access_token and entitlements_token which are used for authorization when making requests to the Valorant APIs.

valorantApi.authorize('username', 'password').then(() => {
    // auth was successful, go make some requests!
}).catch((error) => {
    console.log(error);
});

Note that the access_token and entitlements_token do expire after some time. So you will need to authorize again once they expire.

Alternatively, if you already have your access_token and entitlements_token you can set them like so:

// use saved authorization details
valorantApi.username = 'username';
valorantApi.user_id = 'uuid',
valorantApi.access_token = 'eyJ...';
valorantApi.entitlements_token = 'eyJ...';

Example

const Valorant = require('@liamcottle/valorant.js');
const valorantApi = new Valorant.API(Valorant.Regions.AsiaPacific);

// auth with valorant apis
valorantApi.authorize('username', 'password').then(() => {

    // log auth data
    console.log({
        username: valorantApi.username,
        user_id: valorantApi.user_id,
        access_token: valorantApi.access_token,
        entitlements_token: valorantApi.entitlements_token,
    });

    // log wallet balances
    valorantApi.getPlayerWallet(valorantApi.user_id).then((response) => {
        console.log(response.data);
    });

    // log competitive history
    valorantApi.getPlayerCompetitiveHistory(valorantApi.user_id).then((response) => {
        console.log(response.data);
    });

}).catch((error) => {
    console.log(error);
});

Implemented API Calls

Below is a list of API calls that are implemented in this library.

  • authorize(username, password)
  • getConfig(region)
  • getContent()
  • getMatch(matchId)
  • getParty(partyId)
  • getPartyByPlayer(playerId)
  • getPlayerLoadout(playerId)
  • getPlayerMMR(playerId)
  • getPlayerMatchHistory(playerId, startIndex, endIndex)
  • getPlayerCompetitiveHistory(playerId, startIndex, endIndex)
  • getPlayerWallet(playerId)
  • getPlayerStoreFront(playerId)
  • getPlayers(playerIds)
  • getStoryContractDefinitions()

License

MIT

Legal

Riot Games, VALORANT, and any associated logos are trademarks, service marks, and/or registered trademarks of Riot Games, Inc.

This project is in no way affiliated with, authorized, maintained, sponsored or endorsed by Riot Games, Inc or any of its affiliates or subsidiaries.

I, the project owner and creator, am not responsible for any legalities that may arise in the use of this project. Use at your own risk.