League of Legends API Usage

I’ve been trying to figure out how to use the League of Legends live API. I’ve had success using the endpoints like this: /lol/summoner/v4/summoners/by-name/{summonerName}

but when it comes to using endpoints like this (for live game data): GET https://127.0.0.1:2999/liveclientdata/allgamedata

I get the error “Cannot connect to destination host”

Here is sample code I’ve been trying:

private IEnumerator Test()
    {
        string url = "https://127.0.0.1:2999/liveclientdata/activeplayername";

        using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
        {
            yield return webRequest.SendWebRequest();

            string error = webRequest.error;

            if (error != null)
            {
                Debug.LogError("[LoLAPI] - " + error);
            }
            else
            {
                Debug.Log(webRequest.downloadHandler.text);
            }
        }
    }

Am I missing something?

Thanks

The first one looks like an API running on the internet on Riot’s servers.

The second one looks like a local server that I guess the LOL game client runs while you’re playing. Do you have the LOL game client running when you’re making this request? There also seem to be some extra requirements like installing/trusting the TLS root cert for the game client. Seems to be documented here: Riot Developer Portal

Thanks for the reply.

How do I go about running a TLS root cert for the game client? That is documented there but it’s not very helpful at all. Any clues on where to start? Thanks

Something like this Unity answer is in order: How to accept self signed certificate - Questions & Answers - Unity Discussions

While running this code:

private IEnumerator Test()
        {
            string url = "https://127.0.0.1:2999/liveclientdata/activeplayername";

            using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
            {
                webRequest.certificateHandler = new BypassCertificate();

                yield return webRequest.SendWebRequest();

                string error = webRequest.error;

                if (error != null)
                {
                    Debug.LogError("[LoLAPI] - " + error);
                }
                else
                {
                    Debug.Log(webRequest.downloadHandler.text);
                }
            }
        }
using UnityEngine.Networking;

public class BypassCertificate : CertificateHandler
{
    protected override bool ValidateCertificate(byte[] certificateData)
    {
        //Simply return true no matter what
        return true;
    }
}

and being in an active game in LOL, it still returned the same error as original post.

Any ideas?

I suggest trying the curl command from the docs to make sure the game is actually listening before doing more work in Unity: curl --insecure https://127.0.0.1:2999/swagger/v3/openapi.json

Do I run that in terminal or something?