NightDev Community Forums

Valorant !leaderboard/!rank command

Sorry to bring this topic up again but I can no long reply/ask question at the previous topic created by Wulffy.
Here is the original post: Valorant ranked command?. Basically i am facing the same problem as Wulffy since i have little knowledge about coding and those stuff. After reading Emily’s replies and potatoeaterlove’s codes i still have no clue how to add this command to Nightbot :sweat: . Would appreciate if anyone can help me with this :pray:

1 Like

Hey @enfys18!

Thank you so much for linking to the original topic, so few people do this when they ask for help about an old topic, but this make our lives much easier, so I really appreciate it!

Where are you struggling exactly? Did you manage to get your actId? Or is it on the extracting data from the JSON part that you need help?

While you reply I’ll have to refresh my memory on their API. I’ll try to help as much as I can even tho’ I don’t have access to any Activision account/game, but reading an API is one field where I can help.

1 Like

Hi @Emily, thank you so much for replying to my post!

Since i barely know anything about API and coding stuffs, I don’t even know did I get my actId correctly or not :sweat_smile: Let alone extracting data from JSON :sweat:

Actually I did found some similar functions to this at kyroskoh’s [Valorant MMR Rank API v1] thread (i am new user so i cant put link sry :pray:) , the only downside of using that API is it won’t show my ranking on the leaderboard and it is not through Riot Developer Portal, I feel more safer using official Portal :grimacing:.

So ermm if you are free and willing to teach a complete newbie like me, then I would gladly learn how to do this from you. But if you have busy schedules, you can ignore this thread and move on because i am fine with using that custom API, its just that i would prefer the $(eval) variable if I can make it works. :grin:

1 Like

To get your actId you need to login with your Riot Games account, then go to the second link on the original topic, at the bottom you can make a request, select the right region and click on Execute Request.

In the response you should have your actID somewhere, which you’ll be able to use with the second link, that’s what you’ll have to put on Nightbot, however, it’ll give you a JSON response, which means we need to extract the info you want from that.

You can get the JSON response on the website, at the bottom of the page as well, if you want help to access specific parts of the data you’ll need to share the response here, make sure to censor your actId or any other sensible information if it comes out (replace it with DESCRIPTIVE_TEXT, don’t delete it), to post the response, put it between three backticks on each end:

```
the JSON response
```

If you’re unsure of what you’re going to post you can always send me a direct message, however, we should keep this topic active with all the help to guide other people in the future, since we didn’t have this opportunity the first time, let’s do it now.

You could use the other third party API and it would likely be fine, but if you want info that’s not available with it, you’ll need to use the Riot Games one directly.

1 Like

Below is the JSON response of the website:


{

    "actId": "DESCRIPTIVE_TEXT",

    "players": [

        {

            "leaderboardRank": 1,

            "rankedRating": 1009,

            "numberOfWins": 90,

            "competitiveTier": 24

        },

        {

            "puuid": "DESCRIPTIVE_TEXT,",

            "gameName": "DESCRIPTIVE_TEXT,",

            "tagLine": "DESCRIPTIVE_TEXT,",

            "leaderboardRank": 2,

            "rankedRating": 932,

            "numberOfWins": 86,

            "competitiveTier": 24

        },

So the next step is to extract the info from the JSON response and put it in Nightbot command? Is it something like potatoeaterlove’s reply at the original topic

$(eval a=$(urlfetch json Link);`Response here with stats ${a.stats}`)

So if i am the Rank 2 player, how would my commands looks like?

1 Like

Awesome!
And yes, it’s similar to what potatoeaterlove sent.
So, to reach the number 2 here (the second leaderboardRank), the solution is the following:

$(eval a=$(urlfetch json https://REGION.api.riotgames.com/val/ranked/v1/leaderboards/by-act/ACT_ID?api_key=API_KEY); `Leaderboard ranking: ${a.players[1].leaderboardRank}`)

If you wanted to reach the number 90 (the first numberOfWins), you’d do it like this:

$(eval a=$(urlfetch json https://REGION.api.riotgames.com/val/ranked/v1/leaderboards/by-act/ACT_ID?api_key=API_KEY); `Leaderboard ranking: ${a.players[0].numberOfWins}`)

You need to replace REGION with either of these values: ap, br, eu, kr, latam, na, whichever matches with your chat or account the best, but it doesn’t matter much.
Replace ACT_ID with your actId.
And replace API_KEY with you API key, which you can find here. The fact that you use an API key means that you shouldn’t add the command through the chat, but through the dashboard so you don’t leak it.


I have a concern tho’, are you the #2, and someone else is the number #1? What makes me wonder this is that you only have the gameName field for the #2. That would mean that if you reach #1, you’d need to update the command with players[0] instead of players[1], and if you ever drop bellow #200 you won’t appear in the JSON response.
Can you confirm this? If so I’ll have to figure out another way to fetch the correct data, in which case I’ll need to know if the gameName respect the capitalization set by you, and/or what is the puuid made of?

Also, the API key expires every 24h, I wonder if that’ll be an issue.

Sadly i am not the #1 or #2 in the leaderboard. As for why the JSON response only have gameName and tagLine for the #2 player because Valorant have the option to hide your identity on the leaderboard. So if i move up or down in leaderboard i will have the change the command players[what ever array im in] ?

This is the JSON response without any censor (I hope there is no sensible info here). Here you can see the format of puuid and gameName.

{
            "puuid": "YHLK-rLmuANMTZAhm5mdPkda8mP_AO--d-xYD3bzOis3rmjLbZRgoUG06wwRjxHDJ3rlZbHos_MTww",
            "gameName": "Tempz",
            "tagLine": "solo",
            "leaderboardRank": 199,
            "rankedRating": 439,
            "numberOfWins": 90,
            "competitiveTier": 24
        },

I hope my reply helps to alleviate some of your concerns.

I see, that’s an issue then…
I’m starting to wonder if that’s the reason why on the API you found there’s no leaderboard ranking.

I guess our last chance is in this API endpoint, do you mind running it again and posting the full JSON output here? As I said before, I don’t have access to any API response directly as I don’t have a Riot Game account (I barely game). Don’t forget to censor sensitive information, actId seems to be the biggest one. Or you could look yourself into it to see if you find your ranking position, that’ll work too.

This is the JSON output (i cant post the full output because it exceeded the character limit :joy:). I already shorten it by only posting the important part (i think), hopefully it helps

Response Code

200

Response Headers

{
    "Content-Encoding": "gzip",
    "Content-Type": "application/json;charset=utf-8",
    "Date": "Wed, 21 Jul 2021 09:36:15 GMT, Wed, 21 Jul 2021 09:36:15 GMT",
    "Vary": "Origin",
    "X-App-Rate-Limit": "20:1,100:120",
    "X-App-Rate-Limit-Count": "1:1,1:120",
    "X-Method-Rate-Limit": "60:60",
    "X-Method-Rate-Limit-Count": "1:60",
    "X-Riot-Edge-Trace-Id": "611f5239-a28e-4117-a7d0-756800c938f4",
    "transfer-encoding": "chunked",
    "Connection": "keep-alive"
}

Response Body

{
    "version": "release-03.01",
"acts": [
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "episode",
            "name": "Closed Beta",
            "localizedNames": {
                "ar-AE": "بيتا المغلق",
                "de-DE": "Geschlossene Beta",
                "en-US": "Closed Beta",
                "es-ES": "Beta cerrada",
                "es-MX": "Beta cerrada",
                "fr-FR": "Bêta fermée",
                "id-ID": "Beta Tertutup",
                "it-IT": "Beta chiusa",
                "ja-JP": "クローズドベータ",
                "ko-KR": "클로즈 베타",
                "pl-PL": "Zamknięta beta",
                "pt-BR": "Beta Fechado",
                "ru-RU": "Закрытая бета",
                "th-TH": "CLOSED BETA",
                "tr-TR": "Kapalı Beta",
                "vi-VN": "Closed Beta",
                "zh-CN": "封测版",
                "zh-TW": "封測"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "act",
            "name": "ACT 1",
            "localizedNames": {
                "ar-AE": "مشهد 1",
                "de-DE": "AKT 1",
                "en-US": "ACT 1",
                "es-ES": "ACTO 1",
                "es-MX": "ACTO I",
                "fr-FR": "ACTE 1",
                "id-ID": "ACT 1",
                "it-IT": "ATTO 1",
                "ja-JP": "ACT 1",
                "ko-KR": "액트 1",
                "pl-PL": "AKT 1",
                "pt-BR": "ATO 1",
                "ru-RU": "АКТ 1",
                "th-TH": "ACT 1",
                "tr-TR": "1. KISIM",
                "vi-VN": "PHẦN 1",
                "zh-CN": "第一幕",
                "zh-TW": "第一章"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "act",
            "name": "ACT 2",
            "localizedNames": {
                "ar-AE": "مشهد 2",
                "de-DE": "AKT 2",
                "en-US": "ACT 2",
                "es-ES": "ACTO 2",
                "es-MX": "ACTO II",
                "fr-FR": "ACTE 2",
                "id-ID": "ACT 2",
                "it-IT": "ATTO 2",
                "ja-JP": "ACT 2",
                "ko-KR": "액트 2",
                "pl-PL": "AKT 2",
                "pt-BR": "ATO 2",
                "ru-RU": "АКТ 2",
                "th-TH": "ACT 2",
                "tr-TR": "2. KISIM",
                "vi-VN": "PHẦN 2",
                "zh-CN": "第二幕",
                "zh-TW": "第二章"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "act",
            "name": "ACT 3",
            "localizedNames": {
                "ar-AE": "مشهد 3",
                "de-DE": "AKT 3",
                "en-US": "ACT 3",
                "es-ES": "ACTO 3",
                "es-MX": "ACTO III",
                "fr-FR": "ACTE 3",
                "id-ID": "ACT 3",
                "it-IT": "ATTO 3",
                "ja-JP": "ACT 3",
                "ko-KR": "액트 3",
                "pl-PL": "AKT 3",
                "pt-BR": "ATO 3",
                "ru-RU": "АКТ 3",
                "th-TH": "ACT 3",
                "tr-TR": "3. KISIM",
                "vi-VN": "PHẦN 3",
                "zh-CN": "第三幕",
                "zh-TW": "第三章"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "episode",
            "name": "EPISODE 1",
            "localizedNames": {
                "ar-AE": "حلقة 1",
                "de-DE": "EPISODE 1",
                "en-US": "EPISODE 1",
                "es-ES": "EPISODIO 1",
                "es-MX": "EPISODIO 1",
                "fr-FR": "ÉPISODE 1",
                "id-ID": "EPISODE 1",
                "it-IT": "EPISODIO 1",
                "ja-JP": "EPISODE 1",
                "ko-KR": "에피소드 1",
                "pl-PL": "ODCINEK 1",
                "pt-BR": "EPISÓDIO 1",
                "ru-RU": "ЭПИЗОД 1",
                "th-TH": "\nEPISODE 1",
                "tr-TR": "1. BÖLÜM",
                "vi-VN": "HỒI 1",
                "zh-CN": "第一场",
                "zh-TW": "第一幕"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "act",
            "name": "ACT 1",
            "localizedNames": {
                "ar-AE": "مشهد 1",
                "de-DE": "AKT 1",
                "en-US": "ACT 1",
                "es-ES": "ACTO 1",
                "es-MX": "ACTO I",
                "fr-FR": "ACTE 1",
                "id-ID": "ACT 1",
                "it-IT": "ATTO 1",
                "ja-JP": "ACT 1",
                "ko-KR": "액트 1",
                "pl-PL": "AKT 1",
                "pt-BR": "ATO 1",
                "ru-RU": "АКТ 1",
                "th-TH": "ACT 1",
                "tr-TR": "1. KISIM",
                "vi-VN": "PHẦN 1",
                "zh-CN": "第一幕",
                "zh-TW": "第一章"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "act",
            "name": "ACT 2",
            "localizedNames": {
                "ar-AE": "مشهد 2",
                "de-DE": "AKT 2",
                "en-US": "ACT 2",
                "es-ES": "ACTO 2",
                "es-MX": "ACTO II",
                "fr-FR": "ACTE 2",
                "id-ID": "ACT 2",
                "it-IT": "ATTO 2",
                "ja-JP": "ACT 2",
                "ko-KR": "액트 2",
                "pl-PL": "AKT 2",
                "pt-BR": "ATO 2",
                "ru-RU": "АКТ 2",
                "th-TH": "ACT 2",
                "tr-TR": "2. KISIM",
                "vi-VN": "PHẦN 2",
                "zh-CN": "第二幕",
                "zh-TW": "第二章"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "act",
            "name": "ACT 3",
            "localizedNames": {
                "ar-AE": "مشهد 3",
                "de-DE": "AKT 3",
                "en-US": "ACT 3",
                "es-ES": "ACTO 3",
                "es-MX": "ACTO III",
                "fr-FR": "ACTE 3",
                "id-ID": "ACT 3",
                "it-IT": "ATTO 3",
                "ja-JP": "ACT 3",
                "ko-KR": "액트 3",
                "pl-PL": "AKT 3",
                "pt-BR": "ATO 3",
                "ru-RU": "АКТ 3",
                "th-TH": "ACT 3",
                "tr-TR": "3. KISIM",
                "vi-VN": "PHẦN 3",
                "zh-CN": "第三幕",
                "zh-TW": "第三章"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "episode",
            "name": "EPISODE 2",
            "localizedNames": {
                "ar-AE": "الحلقة 2",
                "de-DE": "EPISODE 2",
                "en-US": "EPISODE 2",
                "es-ES": "EPISODIO 2",
                "es-MX": "EPISODIO 2",
                "fr-FR": "ÉPISODE 2",
                "id-ID": "EPISODE 2",
                "it-IT": "EPISODIO 2",
                "ja-JP": "EPISODE 2",
                "ko-KR": "에피소드 2",
                "pl-PL": "ODCINEK 2",
                "pt-BR": "EPISÓDIO 2",
                "ru-RU": "ЭПИЗОД 2",
                "th-TH": "\nEPISODE 2",
                "tr-TR": "2. BÖLÜM",
                "vi-VN": "HỒI 2",
                "zh-CN": "第二场",
                "zh-TW": "第二幕"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "act",
            "name": "ACT 1",
            "localizedNames": {
                "ar-AE": "مشهد 1",
                "de-DE": "AKT 1",
                "en-US": "ACT 1",
                "es-ES": "ACTO 1",
                "es-MX": "ACTO I",
                "fr-FR": "ACTE 1",
                "id-ID": "ACT 1",
                "it-IT": "ATTO 1",
                "ja-JP": "ACT 1",
                "ko-KR": "액트 1",
                "pl-PL": "AKT 1",
                "pt-BR": "ATO 1",
                "ru-RU": "АКТ 1",
                "th-TH": "ACT 1",
                "tr-TR": "1. KISIM",
                "vi-VN": "PHẦN 1",
                "zh-CN": "第一幕",
                "zh-TW": "第一章"
            },
            "isActive": true
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "act",
            "name": "ACT 2",
            "localizedNames": {
                "ar-AE": "مشهد 2",
                "de-DE": "AKT 2",
                "en-US": "ACT 2",
                "es-ES": "ACTO 2",
                "es-MX": "ACTO II",
                "fr-FR": "ACTE 2",
                "id-ID": "ACT 2",
                "it-IT": "ATTO 2",
                "ja-JP": "ACT 2",
                "ko-KR": "액트 2",
                "pl-PL": "AKT 2",
                "pt-BR": "ATO 2",
                "ru-RU": "АКТ 2",
                "th-TH": "ACT 2",
                "tr-TR": "2. KISIM",
                "vi-VN": "PHẦN 2",
                "zh-CN": "第二幕",
                "zh-TW": "第二章"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "act",
            "name": "ACT 3",
            "localizedNames": {
                "ar-AE": "مشهد 3",
                "de-DE": "AKT 3",
                "en-US": "ACT 3",
                "es-ES": "ACTO 3",
                "es-MX": "ACTO III",
                "fr-FR": "ACTE 3",
                "id-ID": "ACT 3",
                "it-IT": "ATTO 3",
                "ja-JP": "ACT 3",
                "ko-KR": "액트 3",
                "pl-PL": "AKT 3",
                "pt-BR": "ATO 3",
                "ru-RU": "АКТ 3",
                "th-TH": "ACT 3",
                "tr-TR": "3. KISIM",
                "vi-VN": "PHẦN 3",
                "zh-CN": "第三幕",
                "zh-TW": "第三章"
            },
            "isActive": false
        },
        {
            "id": "DESCRIPTIVE_TEXT",
            "parentId": "DESCRIPTIVE_TEXT",
            "type": "episode",
            "name": "EPISODE 3",
            "localizedNames": {
                "ar-AE": "الحلقة 3",
                "de-DE": "EPISODE 3",
                "en-US": "EPISODE 3",
                "es-ES": "EPISODIO 3",
                "es-MX": "EPISODIO 3",
                "fr-FR": "ÉPISODE 3",
                "id-ID": "EPISODE 3",
                "it-IT": "EPISODIO 3",
                "ja-JP": "EPISODE 3",
                "ko-KR": "에피소드 3",
                "pl-PL": "ODCINEK 3",
                "pt-BR": "EPISÓDIO 3",
                "ru-RU": "ЭПИЗОД 3",
                "th-TH": "\nEPISODE 3",
                "tr-TR": "3. BÖLÜM",
                "vi-VN": "HỒI 3",
                "zh-CN": "第三季",
                "zh-TW": "第三幕"
            },
            "isActive": true
        }
    ]
}

Currently is Act 1 Episode 3 in Valorant

Damn, I see, well, the data we’re looking for isn’t here either. I still think it might be in the response since you couldn’t include it all.
I should have expected the data to go over the character limit, so I should have advised you to use Pastebin to share the response, my bad.
You can paste the content of the response there without creating an account, I recommend the following paste settings:
Syntax Highlighting: JSON
Paste Expiration: 1 Day or 1 Week
Paste Exposure: Unlisted
If you want you can give it a password, in which case make sure to share it with me.

Even Pastebin cant handle the all the data :joy:
image

But i believe that the data we’re looking for isn’t here because the response i leave out its just
character names , maps, chromas, skins, etc.

If you want to check it yourself, you can send me a DM to prompt a message (I dont know how to DM ppl in here :joy:) and i’ll give you my credentials to login

OMG, incredible, haha!
No, that’s alright, I’ll take your word for it, I would have hoped that it was in one of the key (version, characters, maps, chromas, skins, skinLevels, equips, gameModes, sprays, sprayLevels, charms, charmLevels, playerCards, playerTitles, acts) of the JSON response.
Guess the data isn’t available from an endpoint then, I’m sorry.
All this wasn’t a waste of time tho’, now we know it’s just not there.
Thanks a lot for your willingness to look for it with me, this will be useful in the future.

Actually, what is the data you were looking for in (version, characters, maps, chromas, skins, skinLevels, equips, gameModes, sprays, sprayLevels, charms, charmLevels, playerCards, playerTitles, acts) of the JSON response? I might have missed it because i thought they are non-related to the act. Now that u said

I would have hoped that it was in one of the key

I might need to check the response code more thoroughly. :grimacing:

I don’t really know where to look at because I don’t have direct access to it, but I thought something like leaderboardRank, or rank could be in either characters, equips, gameModes, playersCards, playerTitles, or acts, but I don’t really know what these refer to, so these might be dead-end ideas.

To go faster, one thing you could do is, if you know what your rank is, CTRL+F it in the JSON response and see if it comes up with a key that’d make sense.

Unlucky really, nothing related to leaderboardRank or rank show up in the JSON response. So i guess this is the end of topic? If you have any idea in the future please dont hesitate to send me a DM tho. Well, thank you very much for your patience and guidance, very much appreciated :pray:

1 Like

I’m sorry we couldn’t find a solution, thank you for trying with me tho’, I appreciate it, if I ever hear about a rank endpoint for this API I’ll make sure to let you know.