Leaguepedia | League of Legends Esports Wiki
Advertisement

Introduction[]

After Riot deprecated web match history, we archived all of the ACS jsons whose corresponding web MH URLs were in our system. We are also acting as a public proxy for the non-public API for post-game JSONs moving forward. This means that even after ACS deprecation, you will be able to retrieve new JSONs via our API.

This page documents how to retrieve JSONs, both from ACS and our post-ACS proxy.

Parameter names[]

We already have internal IDs for every game that we refer to as GameId in our database tables. Therefore, we refer to ACS/v4 IDs as "Riot Platform Game IDs" to ensure there's no ambiguity at all. If you're using our API, you will encounter the following fields:

  • MatchId - Leaguepedia's key for a unique match (BO1, BO2, BO3, BO5)
  • GameId - Leaguepedia's key for a unique game
  • RiotPlatformGameId - the ID you have been using to interact with ACS, the v4 API, etc

What about gameHash?[]

While this string was needed to access ACS, it's not required in order to uniquely identify a game. Therefore, we DID import it, and you CAN still find it in our [MatchScheduleGame] table as RiotGameHash, in case you want to use the wiki to find ACS urls until ACS is sunset. However, it's NOT part of our naming scheme.

Json locations[]

Files are titled based on their API version, either V4 or V5. You can determine the proper title from [PostgameJsonMetadata].StatsPage. This table can be joined to from [MatchScheduleGame] on the field RiotPlatformGameId. You can also determine the title based on the following rules:

  • Anything from live server prior to October 2021 is on V4
  • Anything from ACS is on V4
  • Everything else is on V5

You can find jsons at the following locations:

  • V4 data:<RiotPlatformGameId> or V5 data:<RiotPlatformGameId>
  • V4 data:<RiotPlatformGameId>/Timeline or V5 data:<RiotPlatformGameId>/Timeline

For example:

Note that the wiki is space/underscore agnostic (for page titles!!! not for Cargo!!!), so the following is also valid:

Accessing the Leaguepedia API[]

Main article: Help:Leaguepedia API

The endpoint is https://lol.fandom.com/api.php, so an example action looks like https://lol.fandom.com/api.php?action=cargoquery (plus the extra params), and to sandbox you can visit Special:ApiSandbox. Please note, all queries executed there are actually executed; if you have write permissions to this wiki, please do not use the edit - or delete - actions lightly!

Locating a Riot Platform Game Id[]

As mentioned before, you can query [MatchScheduleGame] to locate a RiotPlatformGameId (from now on referred to as RPGId) and join on that field to [PostgameJsonMetadata] to locate a StatsPage. For more information about querying our Cargo tables, see Help:Leaguepedia API. Here's an example query:

https://lol.fandom.com/api.php?action=cargoquery&format=json&limit=max&tables=MatchScheduleGame%3DMSG%2C%20MatchSchedule%3DMS&fields=RiotPlatformGameId%2C%20Blue%2C%20Red&where=MSG.OverviewPage%3D'LCS%2F2021%20Season%2FChampionship'&join_on=MSG.MatchId%3DMS.MatchId&order_by=MS.DateTime_UTC%20ASC

{
	"action": "cargoquery",
	"limit": "max",
	"tables": "MatchScheduleGame=MSG, MatchSchedule=MS",
	"fields": "RiotPlatformGameId, Blue, Red",
	"where": "MSG.OverviewPage='LCS/2021 Season/Championship'",
	"join_on": "MSG.MatchId=MS.MatchId",
	"order_by": "MS.DateTime_UTC ASC"
}

And here's a snippet of the response you would get:

{
    "limits": {
        "cargoquery": 500
    },
    "cargoquery": [
        {
            "title": {
                "RiotPlatformGameId": "ESPORTSTMNT03_2055040",
                "Blue": "Dignitas",
                "Red": "Evil Geniuses.NA"
            }
        },
        {
            "title": {
                "RiotPlatformGameId": "ESPORTSTMNT03_2054997",
                "Blue": "Evil Geniuses.NA",
                "Red": "Dignitas"
            }
        },
    ]
}

Note that the format is slightly weird - each item of the response is wrapped in this "title" container. That's not something I have control over, we're piggybacking on the built-in Cargo API (not the Rust package manager) and it's just formatted this way.

Getting game data from RPGId & StatsPage[]

Once you have the StatsPage, you will want to fetch game data from it. This is NOT done via a Cargo query, instead you use the query method of the MediaWiki API. Here's an example query:

https://lol.fandom.com/api.php?action=query&format=json&prop=revisions&titles=V4%20data%3ABR1%201926164473%2FTimeline%7CV4%20data%3ABR1%201926164473&rvprop=content&rvslots=main

{
	"action": "query",
	"format": "json",
	"prop": "revisions",
	"titles": "V4 data:BR1 1926164473/Timeline|V4 data:BR1 1926164473",
	"rvprop": "content",
	"rvslots": "main"
}

And here's a curtailed snippet of the response, you can see that the page content is available as the ["*"] parameter, and also the jsons have a lot of escaping:

{
    "batchcomplete": "",
    "query": {
        "pages": {
            "592455": {
                "pageid": 592455,
                "ns": 10028,
                "title": "V4 data:BR1 1926164473",
                "revisions": [
                    {
                        "slots": {
                            "main": {
                                "contentmodel": "json",
                                "contentformat": "application/json",
                                "*": "{\n    \"gameId\": 1926164473,\n"
                            }
                        }
                    }
                ]
            },
            "592456": {
                "pageid": 592456,
                "ns": 10028,
                "title": "V4 data:BR1 1926164473/Timeline",
                "revisions": [
                    {
                        "slots": {
                            "main": {
                                "contentmodel": "json",
                                "contentformat": "application/json",
                                "*": "{\n    \"gameId\": 1926164473,\n    \"platformId\": \"BR1\",\n"
                            }
                        }
                    }
                ]
            }
        }
    }
}

The response is keyed by page id, which is not a value that you will know at the time of querying; therefore, you will have to iterate through all keys and compare title to what you are looking for and see if it happens to match. Again, sorry, I didn't design this thing.

Library support[]

River's library mwrogue (docs) provides a few methods get_data_and_timeline (supply an RPGId and version (default 4) and get_data_and_timeline_from_gameid on an EsportsClient that will return the data & timeline of a game. If you want to query multiple RPGIds at once (which is supported by the API, separate them with a | in your request), that's also up to you; however, for simple use cases this is equivalent to being able to query ACS for a single game.

Advertisement