misaki-valo-wrapper
v1.0.1
Published
A strongly typed wrapper for `valorant-api.com`.
Downloads
3
Maintainers
Readme
Misaki Valo Wrapper
A strongly typed wrapper for valorant-api.com.
Table of Contents
Installation
You may use npm, yarn or bun to install:
npm
npm install misaki-valo-wrapperyarn
yarn add misaki-valo-wrapperbun
bun add misaki-valo-wrapperUsage
Example 1: Getting Weapons
import { getWeapons, getWeaponByUuid, type ApiResponse, type Weapon } = "misaki-valo-wrapper";
// Fetch all weapons (Defaults to English ["en-US"]) //
const weapons: ApiResponse<Weapon> = await getWeapons();
console.log(weapons);
// Fetch all weapons in Japanese locale //
// const weaponsInJapanese: ApiResponse<Weapon> = await getWeapons("ja-JP");
// console.log(weapoonsInJapanese);
// Get weapon data by UUID, example: Vandal //
const vandalResult = await getWeaponByUuid("9c82e19d-4575-0200-1a81-3eacf00cf872");
console.log(vandalResult);
// Fetch weapon data by UUID, example: Vandal (But in Japanese this time) :)
// const vandalResultInJapanese = await getWeaponByUuid("9c82e19d-4575-0200-1a81-3eacf00cf872", "ja-JP");
// console.log(vandalResultInJapanese);Example 2: Handling status codes
import { getWeaponByUuid } = "misaki-valo-wrapper";
const phantomResult = await getWeaponByUuid("ee8e8d15-496b-07ac-e5f6-8fae5d4c7b1a"); // Type would either be ApiResponse<Weapon> or ErrorResponse
if (phantomResult.status === 200) {
console.log(phantomResult.data); // Should output the Phantom's weapon data :) Success!!
} else if (phantomResult.status === 400) {
console.error(phantomResult.error); // Bad request error....
} else if (phantomResult.status === 404) {
console.error(phantomResult.error); // Unable to find the data, you probably used an invalid uuid ¯_(ツ)_/¯
}Configuration
Default Language
By default, the language is set to "en-US". You can override this by passing the language parameter when calling the API functions. Most of the API functions have the language parameter, except for getVersion().
Contributing
You are more than welcome to contribute! When contributing, please follow the steps below:
- Fork the repository.
- Create a new branch for your feature, refactor or fix.
- Make your changes, then commit with clear and concise messages (Please use semantic commit messages).
- Push your changes to your forked repo and create a pull request.
Testing
Tests can only be run when cloning the project repository. Use bun test to run tests.
Disclaimer
This package is NOT associated with Valorant, Riot Games, or Valorant-API.com. This package only interacts with valorant-api.com to retrieve the data.
Contact (Feel free to contact me for enquiries)
- Email: [email protected]
- Discord: byue
- Valorant: Ryumin#ELI ( Sneaking my Valorant here in case you want to play with me, or have a spare Riot gun buddy :3 )
