mrivals
v3.1.0
Published
Wrapper/Scrapper for Marvel Rival stats.
Maintainers
Readme
Instalation
npm i mrivalsUsage:
Note: This module can use many strategies to fetch data: fetch, curl and flaresolverr
- For browser envoriments:
- Default
fetchshould be ok, can use aflaresolverrif available
- Default
- For server enviroments:
- You can try your luck with
fetch(node v16+), switch tocurlif it fails flaresolverris recommended (the default docker image is ok)
- You can try your luck with
You can pass additional options:
| Option | Type | Description | Default |
| --------------- | ------- | ------------------------------------ | ----------- |
| useCurl | boolean | Whether to use curl instead of fetch | false |
| flaresolverrUrl | string | The url of the flaresolverr instance | undefined |
await API.fetchUser(username, {
flaresolverrUrl: 'https://some.flaresolverr.domain:8191', // will use flaresolverr instance
useCurl: true, // will use curl instead of fetch (ommited when flaresolverrUrl is provided)
});Example
There is only one static function that takes an username.
// this returns an API instance with the data already fetched
await API.fetchUser(username); // user#tagYou must call API.fetchUser before using any other method.
| Methods | Description | | ----------- | ------------------- | | info | user and mmr info | | overview | overview stats | | heroes | heroes stats | | roles | roles stats | | peakRank | peak rank | | raw | return raw response |
Example code
Feel free to use my riot username for testing
const { API } = require('mrivals');
try {
const user = await API.fetchUser('ifraan');
console.log('User:', user.info());
console.log('Overview:', user.overview());
console.log('Heroes:', user.heroes());
console.log('Roles:', user.roles());
console.log('Peak MMR:', user.peakRank());
console.log('Raw:', user.raw());
} catch (e) {
console.log(e);
/* Error: We could not find the player [player]. */
}Disclaimer
This project is fully for educational purposes and if you want to use the marvel rivals api in a production/commertial enviroment you should ask or email the guys at TRNetwork.
