Skip to content

Instantly share code, notes, and snippets.

@themasch
Last active October 31, 2023 05:41
Show Gist options
  • Star 79 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save themasch/8375971 to your computer and use it in GitHub Desktop.
Save themasch/8375971 to your computer and use it in GitHub Desktop.
unofficial docs of the LoL Spectator API

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 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'

Methods

featured() > JSON

URL .../featured

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

version() > text/plain

URL: .../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) > base64 encoded AMF Data

URL: .../consumer/getLastChunkInfo/<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.

Plattforms

  • NA
  • EUW1
  • EUN1

Server Names & Ports

  • NA: spectator.na.lol.riotgames.com:8088
  • EUW: spectator.eu.lol.riotgames.com:8088
  • EUNE: spectator.eu.lol.riotgames.com:8088
  • BR: spectator.br.lol.riotgames.com:80
  • LAN: spectator.br.lol.riotgames.com:80
  • RUS: spectator.tr.lol.riotgames.com:80
  • TUR: spectator.tr.lol.riotgames.com:80
  • PBE: spectator.pbe1.lol.riotgames.com:8088
  • SK: QFKR1PROXY.kassad.in:8088
  • TW: QFTW1PROXY.kassad.in:8088
  • SEA: qfsea1proxy.kassad.in:8088

Sources

@ssteuteville
Copy link

Any idea how to retrieve a gameid with a summoner name?

@ryanadean
Copy link

I am trying to get gameID's for any current games in session being played ON THE SYSTEM the user is accessing a site from. The best solution I have been able to come up with is look through the r3d log files and parse the file for the gameID. This is a workable solution, but will require writing (and hence, users DOWNLOADING) an external program to monitor the log files, as a new file is created for each game, and server-side solutions in-browser are (rightfully) going to block access to files without user approval.

Has anyone found another way to check to see if a user is in a game?

@Sieu
Copy link

Sieu commented Jul 18, 2014

@radean0909 I found a way to get gameID, use the league of legend's API on mashape.

@MaxiBoether
Copy link

I don't wanna depend on external apis :/ There must be a way to get the gameID, somehow. But I can't find it X)

@SerialVelocity
Copy link

Yeah, there is a way. You need to login to the League servers with a valid username and password and use their private APIs. It's how all the online services do it afaik.

@SerialVelocity
Copy link

@themasch: Can you update endOfGameStats to the correct url? Currently it points to getLastChunkInfo! Thanks!

@BlackFoxController
Copy link

Hi did anyone find out how to get the gameId of a summoner? Is there like a League of Legends console you can use to type "getGameId" for when im in a game or something?

Just need easy way to either know for player in what gameId they are, or for some other player (not ingame) to know in what gameId their friends are..

@aj-r
Copy link

aj-r commented Dec 17, 2014

I noticed some errors and missing info, so I forked this gist (https://gist.github.com/aj-r/788b9abcde6afdf527c1). Feel free to update your version with my changes (unfortunately I can't do pull requests with Gist).

@im4dbr0
Copy link

im4dbr0 commented Dec 27, 2014

You can get your current game id just before the match is about to start using packet sniffers. it is sent in a reponse in json. there are special programs that trigger functions upon receiving certain requests such as fiddler (http://www.telerik.com/fiddler).

@im4dbr0
Copy link

im4dbr0 commented Dec 27, 2014

@JasperNL
Copy link

The Riot Games API now has a 'current game' library. Using this method is still allowed until somewhere next month.

@rllin
Copy link

rllin commented Feb 19, 2015

Can someone confirm the following steps for decrypting and decompression a data chunk?

decrypt encryptionKey with gameId -> decrypt data chunk with that new cipher obtained in first step -> decompress decrypted data chunk via gzip

Thanks!

@shrx
Copy link

shrx commented Feb 28, 2015

@JasperNL Riot API does not provide real time data of a game in progress. Data is only available after the game has ended.

@JasperNL
Copy link

JasperNL commented Mar 8, 2015

@shrx that's not right, please take a look at current-game-v1.0 at their API site: https://developer.riotgames.com/api/methods#!/956 .

Also look at https://developer.riotgames.com/docs/app-guidelines at the "please don't"-part, in which they state the following: "Scrape data from undocumented endpoints or any other sources outside of the provided Riot API Endpoints and other documented Third Party Developer Tools. (Except where otherwise noted in any official exceptions, if any.)"

@shrx
Copy link

shrx commented Feb 3, 2016

@JasperNL I meant real time data. Like when does stuff like kills, wards, barons happen. Not just general info of the current game.

@maovv
Copy link

maovv commented Feb 26, 2016

@shrx Would it be possible to make software that would run with the spectate API and pull this data? Since spectating let's you see all the data.

@BBoyBreaker
Copy link

so is there anyway to get a readable data from the chunk or it must run on the client ?

@AlexTroshkin
Copy link

@themasch
Copy link
Author

themasch commented Mar 8, 2021

@AlexTroshkin I have not looked into this in the last six (i guess?) years. So I would guess that no, it is not relevant today. I'd expect most, if not all, of this information to be outdated.

@AlexTroshkin
Copy link

AlexTroshkin commented Mar 8, 2021

@themasch, It's a pity, I wanted to receive data from LoL bypassing their API, since the project is related to cryptocurrency, and riot prohibits it.
Thanks for the answer

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