Valpi

A dart library to interact with the Riot Valorant Rest API.

Getting Started

The Valpi library is a pretty simple one since it is still in an early phase of development. The implementation of it to recieve data from the Riot API is simple too.

Obtaining a development API Key

An API Key is required for accessing the API which is provided by Riot and can be obtained at the Riot Developer Portal.

For testing the API a Developer API Key is recommended. The use of a production or personal API key has nit been implemented as of yet because of the huge time interval required to obtain one.

Basic stuff to know before usuage

The final URL generated by the API is always as follows:

https://SERVER_ID.api.riotgames.com/UNENCODED_PATH?locale=LOCALE&api_key=API_KEY

Here,

  • The SERVER_ID is the server id that represents the server you are trying to access. The valid values for server IDs can be found in the Initialisation section.

  • The UNENCODED_PATH is a mandatory value that referrers to the path to which function must navigate to get the desired data. For example:

/val/status/v1/platform-data.

  • The LOCALE here is an optional value use to specify the locale (or the language of the data in simple terms) in which the data is received.

  • The API_KEY is another mandatory value that is required by the API to allow access to the data.

Initialisation

Start by adding the library to your pubspec.yaml file.


dependicies:

- vapi: ^0.0.2

Next is to import your library at the start of your dart file:

import 'package:valpi/valpi.dart';

The initialization here is pretty simple, all you need to do is create an instance of the Valpi class.


Valpi instance = Valpi("API_KEY", "SERVER_ID", {"LOCALE", "VERBOSE"});

Here,

  • API_KEY is a String value which is supposed to be replaced by your API Key. This argument is mandatory

  • SERVER_ID is a String value which is the server ID that represents the id of the server you are requesting data from, these are basically the region code of the server. This argument is mandatory, SERVER_ID can have the following valid values:

    ap, br, eu, kr, latam, na

  • the LOCALE here holds the same meaning as explained in basic stuff. It is a String value. This argument is optional.

  • the VERBOSE here is an integer value which accepts an integer as input. The value can be any integer in range of 1 to 3, it is used to set the amount of debug data to display. This is by default set to 1 which means that no debug data is shown by the library. This argument is optional.

Available Functions:

The following functions can be called by the instance of the Valpi class created in Initialization.

FunctionDescriptionReturn type
getServerName()returns the name of the serverFuture<String>
getServerId()returns the ID of the serverFuture<String>
getAvailableLocales()returns a list of all available localesFuture<List<String>>
valStatus()returns all the data from '/val/status/v1/platform-data'Future<http.Response>
getValLeaderBoardDataByActId(String)returns a list of all the players on the leaderboard of the given Act IDFuture<List<Players>>
getValLeaderBoardPlayerData(int)returns the same as getValLeaderBoardDataByActId(String) but takes an int instead to get the act ID from an array of all act IDs available.Future<List<Players>>
getValActId()returns the Act ID of the act on the index of the supplied integer.Future<String>
valContent()returns all the data from '/val/content/v1/contents'Future<http.Response>

The Players Class

As you can see, the getValLeaderBoardDataByActId() and the getValLeaderBoardPlayerData() return a Future<List<Players>> value. The Players class holds the PUUID, In game name, Tag Line, Leaderboard Rank, Ranked Rating, Number of Wins and Competitive Tier property of each player returned by the above functions. Therefore, to use the getValLeaderBoardDataByActId() and the getValLeaderBoardPlayerData()function, the Players Class must be imported. It can be done easily with the following:

import 'package:valpi/players.dart';

Now, when we obtain a list of players, the data of each player can be accessed by getting the data of player on the desired index of the list. For example, the following sample code prints PUUID, In game name, Tag Line, Leaderboard Rank, Ranked Rating, Number of Wins and Competitive Tier of the top 200 players in Episode 1, Act 1:

 List<Players> playerData = await getValLeaderBoardPlayerData(6); 
 for (int i = 0; i < 200; i++) {
	print("Valorant leaderboard player data for the given act ID.");
	print("PUUID: " + valorantLeaderBoard[i].puuid);
	print("In Game Name: " + valorantLeaderBoard[i].gameName);
	print("Player Tag Line: " + valorantLeaderBoard[i].tagLine);
	print("Leaderboard Rank: " +valorantLeaderBoard[i].leaderboardRank.toString());
	print("Ranked Rating" + valorantLeaderBoard[i].rankedRating.toString());
	print("Number of Wins: " + valorantLeaderBoard[i].numberOfWins.toString());
	print("Competitive Tier: " +valorantLeaderBoard[i].competitiveTier.toString());
 }

This project is a starting point for a Dart

package,

a library module containing code that can be shared easily across

multiple Flutter or Dart projects.

For help getting started with Flutter, view our

online documentation, which offers tutorials,

samples, guidance on mobile development, and a full API reference.

Libraries

actId
characters
maps
players
valpi