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!
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 than 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:
- Get server version
- Get metadata of the game
- Get all the Startup Chunks (until the endStartupChunkId)
- Read the last available key frame
- Read chunk following this key frame
- Read next chunk
- Repeat 4, 5, 6 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.
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.
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 8 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'
URL .../observer-mode/rest/featured
Lists the 10 featured games for the regions supported by this server.
URL: .../observer-mode/rest/consumer/version
Contains the current version for this Region.
URL: .../observer-mode/rest/consumer/getGameMetaData/<platformId>/<gameID>/1/token
Returns information about the given game :
- gameKey
- gameId: The unique game ID
- platformId: The ID of the current server (EUW1, ...)
- gameServerAddress: Empty field
- port: equal to 0
- encryptionKey: Empty field
- chunkTimeInterval: The average time that a chunk represents, usually equal to 30000 (ms)
- startTime: The game start time as a string object (ex: "Apr 21, 2016 1:38:10 PM")
- gameEnded: Set to true if the game ended
- lastChunkId: Id of the last available chunk
- lastKeyFrameId: Id of the last available key frame
- endStartupChunkId: Id of the last startup chunks
- delayTime: Unknown (?) Usually set to 150000
- pendingAvailableChunkInfo: Contains an array of the available chunks
- pendingAvailableKeyFrameInfo: Contains an array of the available key frames
- keyFrameTimeInterval: The average time between two key frames, usually set to 60000 (ms), 1 keyframe every 2 chunks
- decodedEncryptionKey: Empty field
- startGameChunkId: Id of the first chunk since the game really start
- gameLength: The game length in s (?), set to 0 if the game is in progress
- clientAddedLag: Lag added by the client, usually set to 30000 (ms)
- clientBackFetchingEnabled: Unknown (?), usually set to false
- clientBackFetchingFreq: Unknown (?), usually set to 1000
- interestScore: Unknown (?), usually near 2000
- featuredGame: Set to true if the current game is a featured one
- createTime: The game creation time as a string object (ex: "Apr 21, 2016 1:38:10 PM")
- endGameChunkId: Id of the last chunk of the game. Set to -1 if the game is still in progress
- endGameKeyFrameId: Id of the last key frame of the game. Set to -1 if the game is still in progress
URL: .../observer-mode/rest/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: first 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
URL: .../observer-mode/rest/consumer/endOfGameStats/<platformId>/<gameID>/null
Contains data used for the statistics screen after a game.
Example Content: http://pastebin.com/KB4TUPhs (thanks to Divi)
URL: .../observer-mode/rest/consumer/getGameDataChunk/<platformId>/<gameID>/<chunkId>/token
Retrieves a chunk of data for the given game.
URL: .../observer-mode/rest/consumer/getKeyFrame/<platformId>/<gameID>/<keyFrameId>/token
Retrieves a key frame for the given game.
Region | PlatformId | Domain | Port |
---|---|---|---|
NA | NA1 | spectator.na.lol.riotgames.com | 80 |
EUW | EUW1 | spectator.euw1.lol.riotgames.com | 80 |
EUNE | EUN1 | spectator.eu.lol.riotgames.com | 8088 |
JP | JP1 | spectator.jp1.lol.riotgames.com | 80 |
KR | KR | spectator.kr.lol.riotgames.com | 80 |
OCE | OC1 | spectator.oc1.lol.riotgames.com | 80 |
BR | BR1 | spectator.br.lol.riotgames.com | 80 |
LAN | LA1 | spectator.la1.lol.riotgames.com | 80 |
LAS | LA2 | spectator.la2.lol.riotgames.com | 80 |
RU | RU | spectator.ru.lol.riotgames.com | 80 |
TR | TR1 | spectator.tr.lol.riotgames.com | 80 |
PBE | PBE1 | spectator.pbe1.lol.riotgames.com | 8088 |