RoSharp is a feature-intensive C# framework for the Roblox Web API.
RoSharp can be used to access various information from Roblox and perform various actions from a C# console app. The use cases are unlimited, ranging from simple programs collecting information to full-scale custom systems to manage and modify groups, experiences, etc.
The framework is built on .NET 8.0, and requires version 13.0.3 or greater of Newtonsoft.Json (which will be installed alongside the framework if not present already).
Installation
Installing the RoSharp framework is easy! It can be installed directly from NuGet or with the following command in the command-line.
Install-Package RoSharp -Version 1.0.0
The source code is available on GitHub. Every public member within the framework is documented via C#’s XML documentation, so users of Visual Studio and Visual Studio Code (and likely other IDEs) should be covered!
Features
There are dozens of features within this framework, including…
- Users: Get information of any user on the platform, including their badges, inventory (if visible), experiences, and more.
- Communities: Manage your community from a console app, Discord bot, etc! This framework includes the ability to make new ranks, accept and decline join requests, delete wall posts, remove members, and more!
- Assets: View data of assets and manage owned assets directly from the framework.
- Experiences: See all sorts of data from your experiences, even MAU and income data, with much more to come! You can also modify experiences, ban users, etc. You can even modify in-experience DataStores and send MessagingService messages using this framework thanks to Roblox’s open-cloud API. The first of its kind to have these game-changing capabilities!
- Price Floors: Integrated API to view Roblox’s live price floor data. Use this data alongside the Assets API to calculate the price of an item automatically, and keep track of ever-changing Roblox price floors.
- Custom Requests: RoSharp provides an easy way for you, the user, to make your own requests to the Roblox API using the framework’s authentication system. Gone are the days of digging into the depths of authentication yourself, this framework has you covered! Get the URL and go, while the framework does the HTTP magic of headers and content itself.
- (BONUS) DevForum API: Read-only API for viewing the DevForum from the eyes of a non-authenticated user via Discourse’s APIs. See posts and replies of public posts, including official Roblox updates.
There’s so much content within this framework that it’s impossible to mention everything in this post. You’ll have to explore yourself! I’m dedicating as much time as I can to documentation, so stay tuned.
Samples
.ROBLOSECURITY Authentication
Most Roblox APIs require authentication via the .ROBLOSECURITY
token. RoSharp handles this entirely through the use of Session
objects. The below code sample signs into Roblox through the .ROBLOSECURITY token.
using RoSharp;
string code = "<roblosecurity code here>";
Session session = new Session();
await session.LoginAsync(code); // Awaited as we sign into Roblox.
// If successful, the session is now logged in and can be used for API that requires authentication.
Console.WriteLine(session.AuthUser.Username); // Print the name of the user that is authenticated.
Please keep in mind that this is a sample and you should NEVER store your .ROBLOSECURITY
token directly within the source, especially if the code is being shared!
Open Cloud API Key
If you are intending to only use Open-Cloud related endpoints, such as experience DataStores & MessagingService messages, you can use Session
objects just for storing an API key and avoid user authentication entirely. The below sample stores an API key for later use.
using RoSharp;
string apiKey = "<api key here>";
Session session = new Session();
session.SetAPIKey(apiKey); // Does not need awaited as there's no async operation, it just sets the API key internally.
Please keep in mind that this is a sample and you should NEVER store your API key directly within the source, especially if the code is being shared!
Get user information
using RoSharp;
using RoSharp.API;
// Authentication is optional for this example and the session does not need to be provided. However, not all information is available to an unauthorized viewer (such as a user’s premium status).
User user = await User.FromId(userIdHere, sessionHere);
// OR
User user = await User.FromUsername(usernameHere, sessionHere);
Console.WriteLine(user.Username);
Communities
using RoSharp;
using RoSharp.API;
using RoSharp.API.Communities;
// Get Community information
Community community = await Community.FromId(communityIdHere, sessionHere);
Console.WriteLine(community.Name);
// Get the member manager for the below examples
MemberManager members = await community.GetMemberManagerAsync();
// Get user's role in a community
Role? userRole = await members.GetRoleInCommunityAsync(userObjectHere); // Object can be substituted for ID and/or username.
if (userRole != null)
{
Console.WriteLine(userRole.Name);
}
// Set user's role in community
await members.SetRankAsync(userObjectHere, roleObjectHere); // Objects can be substituted for UserId/Username and Role name/ID.
Wiki
More samples and information is available on the RoSharp wiki.
Thank you, and please share how you use resource, I’d love to see it!