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

node-valorant-api

v0.5.0

Published

A NodeJS wrapper for the VALORANT API

Downloads

13

Readme

node-valorant-api

A NodeJs wrapper for the Riot VALORANT API [Active Development]

NPM Version

Disclaimer:

As of 2020/08/13, the VAL-MATCH-V1 API is not yet released to the public. Since I don't have the key to test the API, the functionality of this API wrapper is not yet confirmed. You are welcome to open issues regarding problems/bugs/improvements of this wrapper.

However, I have tested the VAL-CONTENT-V1 API which works fine :D

Installation

npm:

npm i node-valorant-api

yarn:

yarn add node-valorant-api

Supported APIs:

All API methods will return a promise containing the return data. For detailed information about the Promise API, please refer to https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Promise

ACCOUNT-V1

| Method | Description | --------- | -------- | getAccountByPuuid(puuid) | Get account by puuid getAccountByRiotID(gameName, tagLine) | Get account by riot id getActiveShardByPuuid(puuid) | Get active shard for a player


VAL-CONTENT-V1

| Method | Description | --------- | -------- | getContent(locale?) | Get content optionally filtered by locale


VAL-MATCH-V1

| Method | Description | --------- | -------- | getMatchById(matchid) | Get match by id getMatchesByPuuid(puuid) | Get matchlist for games played by puuid getRecentMatches(queue) | Get recent matches


VAL-RANKED-V1

| Method | Description | --------- | -------- | getLeaderboardsByAct(actId, size?, startIndex?) | Get leaderboard for the competitive queue

Supported regions:

Valorant API:

| Region | Endpoint | | --------- | -------- | | APAC | ap.api.riotgames.com | | BR | br.api.riotgames.com | | EU | eu.api.riotgames.com | | KR | kr.api.riotgames.com | | LATAM | latam.api.riotgames.com | | NA | na.api.riotgames.com | | PBE1 | pbe1.api.riotgames.com |

Account API:

| Region | Endpoint | | --------- | -------- | | ASIA | asia.api.riotgames.com | | AMERICAS | americas.api.riotgames.com | | EUROPE | europe.api.riotgames.com |

Usage

CommonJs:
const { API, Regions, Locales, Queue } = require("node-valorant-api");

const APIKey = "RGAPI-5aca53b4-d92b-11ea-87d0-0242ac130003"; // Your API Key

// The third parameter is the Region for the Account API
// choose the one that is the closest to you
const valorant = new API(Regions.NA, APIKey, Regions.AMERICAS); // An API instance for Valorant query

// Example usage of the VAL-CONTENT-V1 API
valorant.ContentV1.getContent(Locales["en-US"]).then(content => {
    console.log(content.characters.map(char => { return char.name }));
});

// Example usage of the ACCOUNT-V1 and VAL-MATCH-V1 API !!! The MatchV1 API requires a Production API Key
valorant.AccountV1.getAccountByRiotID("SoLo", "HK1").then(account => {
    valorant.MatchV1.getMatchesByPuuid(account.puuid).then(matches => {
        console.log(matches);
    })
});

/**
 * Example usage of the VAL-STATUS-V1 API
 * https://developer.riotgames.com/apis#val-status-v1/GET_getPlatformData
 */
valorant.StatusV1.getPlatformData().then(data => {
    console.log(data);
});

/**
 * Example usage of the VAL-MATCH-V1 API
 * Queue: "competitive", "unranked", "spikerush"
 * https://developer.riotgames.com/apis#val-status-v1/GET_getPlatformData
 */
valorant.MatchV1.getRecentMatches(Queue.Competitive).then(data => {
    console.log(data);
})
Typescript:
import { API, Regions, Locales, Queue, RiotAPIError } from "node-valorant-api";

const APIKey = "RGAPI-5aca53b4-d92b-11ea-87d0-0242ac130003"; // Your API Key

// The third parameter is the Region for the Account API
// choose the one that is the closest to you
const valorant = new API(Regions.NA, APIKey, Regions.AMERICAS); // An API instance for Valorant query

// Example usage of the VAL-CONTENT-V1 API
valorant.ContentV1.getContent(Locales["en-US"]).then(content => {
    console.log(content.characters.map(char => { return char.name }));
}).catch((error: RiotAPIError) => {
    // Error handling
    console.log(error.status_code);
})

// Example usage of the ACCOUNT-V1 and VAL-MATCH-V1 API !!! The MatchV1 API requires a Production API Key
valorant.AccountV1.getAccountByRiotID("SoLo", "HK1").then(account => {
    valorant.MatchV1.getMatchesByPuuid(account.puuid).then(matches => {
        console.log(matches);
    })
});

/**
 * Example usage of the VAL-STATUS-V1 API
 * https://developer.riotgames.com/apis#val-status-v1/GET_getPlatformData
 */
valorant.StatusV1.getPlatformData().then(data => {
    console.log(data);
});

/**
 * Example usage of the VAL-MATCH-V1 API
 * Queue: "competitive", "unranked", "spikerush"
 * https://developer.riotgames.com/apis#val-status-v1/GET_getPlatformData
 */
valorant.MatchV1.getRecentMatches(Queue.Competitive).then(data => {
    console.log(data);
})

Error Handling

The wrapper will return a Promise rejection with RiotAPIError which can be used to handle Rate Limiting (HTTP Status 429),etc. Every request should include a catch block for handling error.

RiotAPIError has following properties:

interface RiotAPIError {
    request: {
        method: string; // Request Method
        path: string; // Request path
        header: string; // Request headers
        url: string; // Full Request URL
    },
    status_code: number; // Status Code, see https://developer.riotgames.com/docs/portal#web-apis_response-codes
    message: string; // Error message from Riot API
}