Skip to content

ext0/RobloxSharp

Repository files navigation

RobloxSharp

! Update !

I highly doubt this still works, as ROBLOX has surely changed their APIs since 20(14?). I'll leave this up as a testament to how you SHOULDN'T develop a wrapper for a Web API.

C# API for performing automated tasks on ROBLOX.com

Features

  • Login to get authentication cookies / tokens
  • Check messages and automate responses
  • Monitor trades and build trade responses / requests
  • Automatically purchase assets

Examples

Logging in

CookieContainer collection;
RobloxLogin login = new RobloxLogin("HomeguardDev", "hunter2", out collection);
String authCookies = login.authCookies;

The rest of the examples here will assume that you have already logged in and have authCookies stored

Getting all inbound trades

RobloxTradeHandler tradeHandler = new RobloxTradeHandler();
String XRSFToken = RobloxUtils.getXSRFToken(login.authCookies);
TradeList list = tradeHandler.fetchTrades(login.authCookies, XRSFToken, TradeType.Inbound, 0);
foreach (TradeSession tradeSession in list.Data)
{
  TradeDetailsData info = tradeHandler.getTradeInfo(tradeSession.TradeSessionID, XRSFToken, login.authCookies).data;
  Debug.WriteLine(RobloxUtils.getUsername(tradeSession.TradePartnerID).Username + " has an inbound trade with you!");
  TradeObject trade = RobloxUtils.makeTradeObject(info);
  Debug.WriteLine("They are offering:");
  foreach (InventoryItem item in trade.receiving.OfferList)
  {
    Debug.WriteLine("\t" + item.Name);
  }
  Debug.WriteLine("For your: ");
  foreach (InventoryItem item in trade.sending.OfferList)
  {
    Debug.WriteLine("\t" + item.Name);
  }
}

Accepting all trades above a certain RAP

int myId = RobloxUtils.getUserId("HomeguardDev").Id;
foreach (TradeSession tradeSession in list.Data)
{
  TradeDetailsData info = tradeHandler.getTradeInfo(tradeSession.TradeSessionID, XRSFToken, login.authCookies).data;
  Debug.WriteLine(RobloxUtils.getUsername(tradeSession.TradePartnerID).Username + " has an inbound trade with you!");
  TradeObject trade = RobloxUtils.makeTradeObject(info);
  if (trade.receiving.OfferValue > trade.sending.OfferValue) //accepts all trades where the receiving RAP is higher then your RAP
  {
    String json = tradeHandler.createTradeRequest(myId + "", tradeSession.TradePartnerID, trade);
    tradeHandler.sendTrade(TradeResponseType.Accept, json, XRSFToken, tradeSession.TradeSessionID, login.authCookies);
  }
}

Reading all inbound messages

RobloxMessageHandler messageHandler = new RobloxMessageHandler();
String XRSFToken = RobloxUtils.getXSRFToken(login.authCookies);
MessageCollection messages = messageHandler.getNewMessages("0", login.authCookies);
foreach (Message message in messages.Collection)
{
  Debug.WriteLine(message.Sender.UserName + "->" + message.Recipient.UserName + "\n" + message.Body);
}

Sending a message

RobloxMessageHandler messageHandler = new RobloxMessageHandler();
messageHandler.sendMessage(7904, "Hey Me!", "What's up?", login.authCookies);

Purchasing a limited item

RobloxPurchaseHandler purchase = new RobloxPurchaseHandler();
bool response = purchase.requestLimitedPurchase(1337, 123, 1000, login.authCookies); //1337 is assetID, 123 is userAssetOptionId, and 1000 is the price
Debug.WriteLine(response);

Purchasing an asset

RobloxPurchaseHandler purchase = new RobloxPurchaseHandler();
bool response = purchase.requestAssetPurchase(20642008, 40, CurrencyType.ROBUX, login.authCookies);
Debug.WriteLine(response);

About

C# API for performing automated tasks on ROBLOX.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages