Twisted
League of Legends API Wrapper

Simple example
RIOT:
import { RiotApi, Constants } from 'twisted'
const api = new RiotApi()
export async function getAccount () {
// Recommended to use the nearest routing value to your server: americas, asia, europe
return (await api.Account.getByRiotId("Hide on bush", "KR1", Constants.RegionGroups.AMERICAS)).response
}LOL:
import { LolApi, Constants } from 'twisted'
const api = new LolApi()
export async function getSummoner () {
const user = await getAccount()
return await api.Summoner.getByPUUID(user.puuid, Constants.Regions.KOREA)
}TFT:
import { TftApi, Constants } from 'twisted'
const api = new TftApi()
export async function matchListTft () {
const user = await getAccount()
return api.Match.list(user.puuid, Constants.RegionGroups.KOREA)
}
Automatic rate limits reattempts
import { LolApi } from 'twisted'
const api = new LolApi({
/**
* If api response is 429 (rate limits) try reattempt after needed time (default true)
*/
rateLimitRetry: true
/**
* Number of time to retry after rate limit response (default 1)
*/
rateLimitRetryAttempts: 1
/**
* Concurrency calls to riot (default infinity)
* Concurrency per method (example: summoner api, match api, etc)
*/
concurrency: undefined,
/**
* Riot games api key
*/
key: '',
/**
* BaseURL for a rate limiting proxy (default: "https://$(region).api.riotgames.com/:game")
* Using this field is for a very advanced use case and in most cases not necessary
* ${region} and :game are expected but not required variables
*/
baseURL: "http://localhost:8080/${region}/:game",
/**
* Debug methods
*/
debug: {
/**
* Log methods execution time (default false)
*/
logTime: false
/**
* Log urls (default false)
*/
logUrls: false
/**
* Log when is waiting for rate limits (default false)
*/
logRatelimit?: false
}
})Endpoints
Everything should be in the same order as in the official docs.
Riot Endpoints
ACCOUNT-V1
- <input checked="" disabled="" type="checkbox">
Get account by puuid - <input disabled="" type="checkbox">
Get account by puuid - ESPORTS - <input checked="" disabled="" type="checkbox">
Get account by riot id - <input disabled="" type="checkbox">
Get account by riot id - ESPORTS - <input disabled="" type="checkbox">
Get active shard for a player - <input checked="" disabled="" type="checkbox">
Get active region (lol and tft) - <input disabled="" type="checkbox">
Get account by access token - <input disabled="" type="checkbox">
Get account by access token - ESPORTS
LOL Endpoints
CHAMPION-MASTERY-V4
- <input checked="" disabled="" type="checkbox">
Get all champion mastery entries sorted by number of champion points descending. - <input checked="" disabled="" type="checkbox">
Get a champion mastery by player ID and champion ID. - <input checked="" disabled="" type="checkbox">
Get a player's total champion mastery score, which is the sum of individual champion mastery levels.CHAMPION-V3
- <input checked="" disabled="" type="checkbox">
Retrieve all champions. - <input checked="" disabled="" type="checkbox">
Retrieve champion by ID.CLASH
- <input checked="" disabled="" type="checkbox">
Get players by summoner id - <input checked="" disabled="" type="checkbox">
Get team - <input checked="" disabled="" type="checkbox">
Get tournaments - <input checked="" disabled="" type="checkbox">
Get tournaments by team id - <input checked="" disabled="" type="checkbox">
Get tournament by idMATCH-V5
- <input checked="" disabled="" type="checkbox">
Get match by id - <input checked="" disabled="" type="checkbox">
Get matches by summoner id - <input checked="" disabled="" type="checkbox">
Get match timeline by idMATCH-V4 (deprecated)
- <input checked="" disabled="" type="checkbox">
Get matches id by tournament code - <input checked="" disabled="" type="checkbox">
Get match by id - <input checked="" disabled="" type="checkbox">
Get match by tournament code - <input checked="" disabled="" type="checkbox">
Get matches by summoner id - <input checked="" disabled="" type="checkbox">
Get match timeline by idLEAGUE-V4
- <input checked="" disabled="" type="checkbox">
Get the challenger league for given queue. - <input checked="" disabled="" type="checkbox">
Get league entries in all queues by PUUID. - <input checked="" disabled="" type="checkbox">
Get league entries in all queues for a given summoner ID. - <input checked="" disabled="" type="checkbox">
Get all the league entries. - <input checked="" disabled="" type="checkbox">
Get the grandmaster league of a specific queue. - <input checked="" disabled="" type="checkbox">
Get league with given ID, including inactive entries. - <input checked="" disabled="" type="checkbox">
Get the master league for given queue. - <input checked="" disabled="" type="checkbox">
Get the queues that have positional ranks enabled.(deprecated June 17th and inv0.9.10) - <input checked="" disabled="" type="checkbox">
Get league positions in all queues for a given summoner ID.(deprecated June 17th and inv0.9.10) - <input checked="" disabled="" type="checkbox">
Get all the positional league entries.(deprecated June 17th and inv0.9.10)LOL-CHALLENGES-V1
- <input checked="" disabled="" type="checkbox">
Get all challenge configurations. - <input checked="" disabled="" type="checkbox">
Get all challenge percentile distributions. - <input checked="" disabled="" type="checkbox">
Get a challenge configuration. - <input checked="" disabled="" type="checkbox">
Get Leaderboards for a challenge (Chall, GM, Masters). - <input checked="" disabled="" type="checkbox">
Get a challenge percentile distribution. - <input checked="" disabled="" type="checkbox">
Get player challenge information.LOL-STATUS-V3
- <input checked="" disabled="" type="checkbox">
Get League of Legends status for the given shard. - <input checked="" disabled="" type="checkbox">
Get matchlist for games played on given account ID and platform ID and filtered using given filter parameters, if any. - <input checked="" disabled="" type="checkbox">
Get match timeline by match ID. - <input checked="" disabled="" type="checkbox">
Get match IDs by tournament code. - <input checked="" disabled="" type="checkbox">
Get match by match ID and tournament code.LOL-STATUS-V4
- <input checked="" disabled="" type="checkbox">
Get League of Legends status for the given platform.SPECTATOR-V5
- <input checked="" disabled="" type="checkbox">
Get current game information for the given summoner ID. - <input checked="" disabled="" type="checkbox">
Get list of featured games.SPECTATOR-V4 (deprecated April 5)
- <input checked="" disabled="" type="checkbox">
Get current game information for the given summoner ID. - <input checked="" disabled="" type="checkbox">
Get list of featured games.SUMMONER-V4
- <input checked="" disabled="" type="checkbox">
Get a summoner by account ID. - <input checked="" disabled="" type="checkbox">
Get a summoner by summoner name.(deprecated Oct 16th, 2023) - <input checked="" disabled="" type="checkbox">
Get a summoner by PUUID. - <input checked="" disabled="" type="checkbox">
Get a summoner by summoner ID.TOURNAMENT-STUB-V4
- <input disabled="" type="checkbox">
Create a mock tournament code for the given tournament. - <input disabled="" type="checkbox">
Gets a mock list of lobby events by tournament code. - <input disabled="" type="checkbox">
Creates a mock tournament provider and returns its ID. - <input disabled="" type="checkbox">
Creates a mock tournament and returns its ID.TOURNAMENT-V4
- <input disabled="" type="checkbox">
Create a tournament code for the given tournament. - <input disabled="" type="checkbox">
Returns the tournament code DTO associated with a tournament code string. - <input disabled="" type="checkbox">
Update the pick type, map, spectator type, or allowed summoners for a code. - <input disabled="" type="checkbox">
Gets a list of lobby events by tournament code. - <input disabled="" type="checkbox">
Creates a tournament provider and returns its ID. - <input disabled="" type="checkbox">
Creates a tournament and returns its ID.
TFT Endpoints
TFT-SPECTATOR-V5
- <input checked="" disabled="" type="checkbox">
Get current game information for the given puuid. - <input checked="" disabled="" type="checkbox">
Get list of featured games.TFT-SUMMONER-V1
- <input checked="" disabled="" type="checkbox">
Get a summoner by account ID. - <input checked="" disabled="" type="checkbox">
Get a summoner by summoner name.(deprecated Oct 16th, 2023) - <input checked="" disabled="" type="checkbox">
Get a summoner by PUUID. - <input checked="" disabled="" type="checkbox">
Get a summoner by summoner ID.TFT-MATCH-V1
- <input checked="" disabled="" type="checkbox">
Get match list by summoner PUUID. - <input checked="" disabled="" type="checkbox">
Get match list details.TFT-LEAGUE-V1
- <input checked="" disabled="" type="checkbox">
Get the challenger league for given queue. - <input checked="" disabled="" type="checkbox">
Get the grandmaster league for given queue. - <input checked="" disabled="" type="checkbox">
Get the master league for given queue. - <input checked="" disabled="" type="checkbox">
Get league entries in all queues for a given summoner ID. - <input disabled="" type="checkbox">
Get all the league entries. - <input disabled="" type="checkbox">
Get league with given ID, including inactive entries.
Run all examples
Download code from git and:
Simple
$ RIOT_API_KEY={YOUR_KEY} yarn example
Specific examples
$ RIOT_API_KEY={YOUR_KEY} yarn example {exampleFunctionName}
With docker
Edit docker-compose.yml with your api key and:
$ docker-compose up
Real project
We did a project based on a "twisted" package, this project is not finished but it is a very good example
Github: https://github.com/twisted-gg
Options
The following environment variables can be set either in the .env file or as shown in the examples:
RIOT_API_KEY
Obtained from the Riot Games developer page(https://developer.riotgames.com/) Necessary to use this library.
UPDATE_CHAMPION_IDS
This library has an option to fetch an actual version of champion IDs regularly. This is useful in case a new champion gets added, while the application runs. E.g. data crawlers, or services which aren't supposed to be restarted regularly.
Set the value to true or 1 to enable this feature.