Badge API doesn't return nextPageCursor past 20,901 badges

Hello !
So, to go straight to the point, I’ve been trying to count my badges using the Roblox API with this script in c# :

Code
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace ez
{
    class Program
    {
        private static readonly HttpClient client = new HttpClient(new SocketsHttpHandler
        {
            MaxConnectionsPerServer = 50,
            AutomaticDecompression =
                System.Net.DecompressionMethods.GZip |
                System.Net.DecompressionMethods.Brotli |
                System.Net.DecompressionMethods.Deflate
        },
        disposeHandler: true
        );

        static async Task Main(string[] args)
        {
            string userId = "369742023";
            string baseUrl = $"https://badges.roblox.com/v1/users/{userId}/badges?limit=100&sortOrder=Asc&cursor=";
            string? nextPageCursor = "";
            int totalBadges = 0;

            Console.WriteLine($"Getting every badge for the user {userId}");

            do
            {
                string url = baseUrl + nextPageCursor;
                string json = await GetWithRetryAsync(url);

                JObject data = JObject.Parse(json);
                JArray badges = (JArray)data["data"];
                nextPageCursor = (string?)data["nextPageCursor"];

                foreach (var badge in badges)
                {
                    totalBadges++;
                }
                Console.WriteLine($"Total badges: {totalBadges}");

            } while (!string.IsNullOrEmpty(nextPageCursor));

            Console.WriteLine($"Total number of badges: {totalBadges}");
        }

        // RETRY FUNC
        private static async Task<string> GetWithRetryAsync(string url)
        {
            while (true)
            {
                try
                {
                    HttpResponseMessage response = await client.GetAsync(url);

                    if (response.IsSuccessStatusCode) {
                        return await response.Content.ReadAsStringAsync();
                    }

                    if ((int)response.StatusCode == 429)
                    {
                        Console.WriteLine("Rate limited (429). Retrying in 1 second...");
                        await Task.Delay(1000);
                        continue;
                    }

                    response.EnsureSuccessStatusCode();
                }
                catch (HttpRequestException)
                {
                    Console.WriteLine("Network error. Retrying in 1 second...");
                    await Task.Delay(1000);
                }
            }
        }
    }
}

And I found out that the program randomly stopped at 20,901 badges. And when I joined the GBL Lobby to count my badges, it also got stuck to 20901, as shown here:


And you can tell that this is incorrect, because, just by looking at my inventory, you can easily tell that I have way more badges than that:


5329×3=159870 badges. And in fact, I have over 2 millions badges, so the API not fetching more than 20,901 badges is clearly incorrect. And as the GBL description says: “COUNTS MAY BE BUGGED FOR CERTAIN USERS. IF YOUR COUNT STOPS TOO EARLY, THIS IS OUT OF OUR CONTROL AND IS A ROBLOX ISSUE!”

So, in short, the Roblox badges API (GET /v1/users/{userId}/badges) works fine until it reaches the 20,901 threshold, and after that, the nextPageCursor isn’t returned and it prevents us from counting our badges.

Expected behavior

What should happen is that, calling https://badges.roblox.com/v1/users/{userId}/badges?limit=100&sortOrder=Asc should always return nextPageCursor, until the user has no more badges left in his inventory. Not stop at 20,901.

5 Likes

Look like this has been fixed:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.