Game API - Thundermaker300/RoSharp GitHub Wiki
The Game API allows accessing front-page experiences.
Get Front-Page Experiences
ChartsResponse resp = await GameAPI.GetFrontPageExperiencesAsync([session], [cursor]);
This API returns a ChartsResponse
class which contains a list of front-page categories (ChartCategory
classes) as well as a "next page token" which can be used in the API as the "cursor" parameter to load the next page of experiences. Each ChartCategory
class contains details about the category and a list of experience IDs in that category.
The following example lists each category and the experiences within the category. This sample makes use of the ForEachExperienceAsync
method. Keep in mind that this method converts each experience ID to an Experience
class, which makes an API call. As such, this API member takes time (usually about a second per experience). However, since there is no limit in the code sample below, it'll take a lot of time.
Please also keep in mind that this code sample DOES NOT respect Roblox's ratelimiting. You need to perform your own method of ensuring that this rate-limit is not hit, usually by introducing custom delays. The ForEachExperienceAsync
method aids in this by providing two optional parameters, limit
and startAt
, to control how many experiences are listed and where to start at in the list.
using RoSharp;
using RoSharp.API;
Session session = new Session();
await session.LoginAsync(myCode);
string? cursor = null;
while (true)
{
ChartsResponse resp = await GameAPI.GetFrontPageExperiencesAsync(session, cursor);
foreach (var cat in resp.Categories)
{
Console.WriteLine($"Category {cat.DisplayName} has {cat.ExperienceIds.Count} experiences:");
await cat.ForEachExperienceAsync(exp =>
{
Console.WriteLine(exp.Name);
});
Console.WriteLine("-------------");
}
cursor = resp.NextPageToken;
if (cursor == null)
break;
}