1.60.0 • Published 29 days ago

twisted v1.60.0

Weekly downloads
303
License
ISC
Repository
github
Last release
29 days ago

Twisted

League of legends api wrapper https://www.npmjs.com/package/twisted

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)
}

More examples

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: '',
  /**
   * 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

  • Get account by puuid
  • Get account by riot id
  • Get active shard for a player
  • Get account by access token

LOL Endpoints

CHAMPION-MASTERY-V4

  • Get all champion mastery entries sorted by number of champion points descending.
  • Get a champion mastery by player ID and champion ID.
  • Get a player's total champion mastery score, which is the sum of individual champion mastery levels.

CHAMPION-V3

  • Retrieve all champions.
  • Retrieve champion by ID.

CLASH

  • Get players by summoner id
  • Get team
  • Get tournaments
  • Get tournaments by team id
  • Get tournament by id

MATCH-V5

  • Get match by id
  • Get matches by summoner id
  • Get match timeline by id

MATCH-V4 (deprecated)

  • Get matches id by tournament code
  • Get match by id
  • Get match by tournament code
  • Get matches by summoner id
  • Get match timeline by id

LEAGUE-V4

  • Get the challenger league for given queue.
  • Get league entries in all queues for a given summoner ID.
  • Get all the league entries.
  • Get the grandmaster league of a specific queue.
  • Get league with given ID, including inactive entries.
  • Get the master league for given queue.
  • Get the queues that have positional ranks enabled. (deprecated June 17th and in v0.9.10)
  • Get league positions in all queues for a given summoner ID. (deprecated June 17th and in v0.9.10)
  • Get all the positional league entries. (deprecated June 17th and in v0.9.10)

LOL-CHALLENGES-V1

  • Get all challenge configurations.
  • Get all challenge percentile distributions.
  • Get a challenge configuration.
  • Get Leaderboards for a challenge (Chall, GM, Masters).
  • Get a challenge percentile distribution.
  • Get player challenge information.

LOL-STATUS-V3

  • Get League of Legends status for the given shard.
  • Get matchlist for games played on given account ID and platform ID and filtered using given filter parameters, if any.
  • Get match timeline by match ID.
  • Get match IDs by tournament code.
  • Get match by match ID and tournament code.

LOL-STATUS-V4

  • Get League of Legends status for the given platform.

SPECTATOR-V5

  • Get current game information for the given summoner ID.
  • Get list of featured games.

SPECTATOR-V4 (deprecated April 5)

  • Get current game information for the given summoner ID.
  • Get list of featured games.

SUMMONER-V4

  • Get a summoner by account ID.
  • Get a summoner by summoner name. (deprecated Oct 16th, 2023)
  • Get a summoner by PUUID.
  • Get a summoner by summoner ID.

TOURNAMENT-STUB-V4

  • Create a mock tournament code for the given tournament.
  • Gets a mock list of lobby events by tournament code.
  • Creates a mock tournament provider and returns its ID.
  • Creates a mock tournament and returns its ID.

TOURNAMENT-V4

  • Create a tournament code for the given tournament.
  • Returns the tournament code DTO associated with a tournament code string.
  • Update the pick type, map, spectator type, or allowed summoners for a code.
  • Gets a list of lobby events by tournament code.
  • Creates a tournament provider and returns its ID.
  • Creates a tournament and returns its ID.

TFT Endpoints

TFT-SPECTATOR-V5

  • Get current game information for the given puuid.
  • Get list of featured games.

TFT-SUMMONER-V1

  • Get a summoner by account ID.
  • Get a summoner by summoner name. (deprecated Oct 16th, 2023)
  • Get a summoner by PUUID.
  • Get a summoner by summoner ID.

TFT-MATCH-V1

  • Get match list by summoner PUUID.
  • Get match list details.

TFT-LEAGUE-V1

  • Get the challenger league for given queue.
  • Get the grandmaster league for given queue.
  • Get the master league for given queue.
  • Get league entries in all queues for a given summoner ID.
  • Get all the league entries.
  • 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.

1.60.0

29 days ago

1.59.0

29 days ago

1.57.0

3 months ago

1.56.3

3 months ago

1.56.1

3 months ago

1.56.0

3 months ago

1.56.2

3 months ago

1.55.0

5 months ago

1.54.0

6 months ago

1.53.2

7 months ago

1.53.1

1 year ago

1.52.1

1 year ago

1.52.0

1 year ago

1.51.0

2 years ago

1.49.0

2 years ago

1.50.0

2 years ago

1.48.0

2 years ago

1.47.0

2 years ago

1.46.6

2 years ago

1.46.8

2 years ago

1.46.7

2 years ago

1.46.4

2 years ago

1.46.5

2 years ago

1.46.3

3 years ago

1.46.2

3 years ago

1.46.1

3 years ago

1.46.0

3 years ago

1.45.0

3 years ago

1.44.3

3 years ago

1.44.0

3 years ago

1.44.2

3 years ago

1.44.1

3 years ago

1.43.1

3 years ago

1.42.0

3 years ago

1.43.0

3 years ago

1.41.0

3 years ago

1.40.0

3 years ago

1.35.0

3 years ago

1.34.0

3 years ago

1.33.0

3 years ago

1.32.0

3 years ago

1.31.0

3 years ago

1.30.0

3 years ago

1.29.0

4 years ago

1.28.0

4 years ago

1.27.0

4 years ago

1.26.0

4 years ago

1.25.0

4 years ago

1.24.0

4 years ago

1.23.8

4 years ago

1.23.7

4 years ago

1.23.6

4 years ago

1.23.4

4 years ago

1.23.5

4 years ago

1.23.3

4 years ago

1.23.2

4 years ago

1.23.1

4 years ago

1.23.0

4 years ago

1.22.3

4 years ago

1.22.2

4 years ago

1.22.0

4 years ago

1.22.1

4 years ago

1.21.3

4 years ago

1.21.2

4 years ago

1.21.0

4 years ago

1.21.1

4 years ago

1.19.0

4 years ago

1.20.0

4 years ago

1.18.0

4 years ago

1.17.0

4 years ago

1.15.0

4 years ago

1.14.0

4 years ago

1.16.0

4 years ago

1.13.0

4 years ago

1.12.0

4 years ago

1.11.0

4 years ago

1.10.0

4 years ago

1.9.0

4 years ago

1.8.0

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago