Skip to content

Instantly share code, notes, and snippets.

@aj-r
Forked from themasch/doc.md
Last active June 7, 2018 11:25
Show Gist options
  • Save aj-r/788b9abcde6afdf527c1 to your computer and use it in GitHub Desktop.
Save aj-r/788b9abcde6afdf527c1 to your computer and use it in GitHub Desktop.

REST Service for LoL spectators

This is an unofficial, uncomplete and (pretty sure) wrong documentation of the RESTful service which powers the League of Legends spectator mode.

This documentation is desgined to be community driven and should be extended by everyone. If you find things missing, add them please!

How it works

Riot's spectator mode works by requesting replay data via HTTP form a service. The data is split in chunks which usually contain about 30 seconds of gameplay. Additionally there are key frames which seem to contain more information then a single chunk. They seem to be used to support skipping back in time or for spectators that join the game later. This means that the key frames should contain every information about the state of a game at a given point in time. On the other hand, chunks may only contain changes to this state.

This leads to the following process for replaying a series of chunks:

  1. Read key frame thats prior to the targeted point in time
  2. Read chunk following this key frame
  3. apply the changes described in the chunk
  4. read next chunk
  5. repeat 3 + 4 until end of game or skip

The same procedure is known to work in many video and audio formats. It provides a fast and bandwidth saving way of deliviering all information fast while it also gives a good way to jump quickly to any point in time without the need to replay every chunk from the start to that moment.

Cryptography

Chunks and Keyframes are encrypted and compressed. The algorithm used for cryptography seems to be Blowfish in ECB mode. Compression is done using zip BEFORE the encryption. So to read a chunks data one needs to first decrypt then uncompress the data.

API Docs

URL Template

Most of the REST URLs look like this:

http://<REST host:port>/observer-mode/rest/consumer/<method>/<platformId>/<gameID>/<parameter>/token'

Parameters

  • host:port: there are currently 9 REST services running for the different regions. A list of these servers exists at the end of this document.
  • method: Name of the method you want to call. See "Methods".
  • platformId/gameID: Every game is uniquely identified by the short name of its region and a numeric game ID.
  • parameter: The methods first and single parameter (aside of gameid/platformId). If a method doesn't require an additional parameter this value is '1'

Methods

featured() > JSON

URL .../featured

Lists the featured games for the regions supported by this server.

version() > text/plain

URL: .../consumer/version

Contains the current version for this Region.

getGameMetaData(platformId, gameId) > JSON

URL: .../consumer/getGameMetaData/<platformId>/<gameID>/1/token

Returns information about the given game. This contains the games type and map, summoners involved, champions picked & banned, start time of the game and the encryption key required to read the replay data.

getLastChunkInfo(platformId, gameId) > JSON

URL: .../consumer/getLastChunkInfo/<platformId>/<gameID>/1/token

Return some information about the last avaiable chunk:

  • chunkId: ID of the last available chunk,
  • availableSince: Number of ms this chunk is available (?),
  • nextAvailableChunk: Number of ms until the next chunk is available (?),
  • keyFrameId: key frame that belongs to this chunk,
  • nextChunkId: chunk that directly follows this key frame,
  • endStartupChunkId: chunk that determinates the end of pick&ban phase,
  • startGameChunkId: fist chunk of the actual game,
  • endGameChunkId: last chunk of the actual game (or 0 if game still running),
  • duration: Number of ms this chunks information represents

endOfGameStats(platformId, gameId) > AMF encoded Data

URL: .../consumer/endOfGameStats/<platformId>/<gameID>/null (!)

Contains data used for the statistics screen after a game.

Example Content: http://pastebin.com/KB4TUPhs (thanks to Divi)

getGameDataChunk(platformId, gameId, chunkId) > ? Encrypted, Compressed

URL: .../consumer/getGameDataChunk/<platformId>/<gameID>/<chunkId>/token

Retrieves a chunk of data for the given game.

getKeyFrame(platformId, gameId, keyFrameId) > ? Encrypted, Compressed

URL: .../consumer/getKeyFrame/<platformId>/<gameID>/<keyFrameId>/token

Retrieves a key frame for the given game.

Servers

Note: The time zones indicate which time zone that server will send date properties in. I determined them from my own tests; they may have changed since my tests.

Name PlatformID URL Time Zone
North America NA1 spectator.na1.lol.riotgames.com:80 Pacific
Europe West EUW1 spectator.euw1.lol.riotgames.com:8088 UTC
Eurpoe Nordic & East EUN1 spectator.eu.lol.riotgames.com:8088 Pacific
Brazil BR1 spectator.br.lol.riotgames.com:80 Pacific
Latin America North LA1 spectator.br.lol.riotgames.com:80 Pacific
Latin America South LA2 spectator.br.lol.riotgames.com:80 Pacific
Russia RU spectator.tr.lol.riotgames.com:80 Pacific
Turkey TR1 spectator.tr.lol.riotgames.com:80 Pacific
Korea KR QFKR1PROXY.kassad.in:8088 Pacific
Taiwan TW QFTW1PROXY.kassad.in:8088 China
Oceania OC1 qfsea1proxy.kassad.in:8088 China
Singapore SG qfsea1proxy.kassad.in:8088 China
Public Beta Env. PBE1 spectator.pbe1.lol.riotgames.com:8088 Pacific

Sources

@MicahZoltu
Copy link

FYI: I copied your platform info over to the wiki found here: https://github.com/loldevs/leaguespec/wiki/REST-Service

@Disturbing
Copy link

Featured games are not working anymore. Any update on this would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment