Using Google Apps As A api.roblox.com And www.roblox.com Proxy

[2021 Edit]: It has been several years since I have touched this, and I have only used it for small-scale applications on Roblox. I can’t recommend this for a large game, especially long-term since it abruptly stopped working for that project after a year. Do not expect replies from me about this if you ping me about it.

(Thanks to Brad_Sharp for helping me with the JavaScript code)

This tutorial is about a simple idea: Using the www.roblox.com and api.roblox.com web APIs without having to pay for a good host, or having to take a free hose who doesn’t have good limits. This process may be a bit long, but it is worth it to have a reliable provider (Google) able to provide access to the Roblox API at no cost to you.

Step 0: Get Google Apps Script
To create the needed JavaScript, you are going to need to have Google Apps Script. It is free, and it is made by Google. To get to it, you need to go to Google Drive (you do need a google account), go to “New”, go down to “More”, and click “Connect more apps”.
When in the search box, type “Apps” and hit enter. It should be the first thing that shows up. When you find it, click “Connect”

TL;DR: Go to google drive, go to new, go to more, go to connect more apps, and find Google Apps Script.




Step 1: Create The Script
Now, you are actually going to have to create a new script. You can put it into any folder or location in Google Drive. To create the script, go to New, go down to More, then click “Google Apps Script”. You may want to name it to something meaningful.

TL;DR: : See image.




Step 2: Enter the JavaScript Code
This step is fairly simple. Brad_Sharp made a small bit of code that you just need to paste into the script, and remove the existing part.
Pastebin Source: http://pastebin.com/QFtbQpiD
Source:

function doGet(e) {
  var output;
  try
  {
    var query = e.parameter["q"];
    var response = UrlFetchApp.fetch(decodeURIComponent(query));
    output = {"result":"success", "response": JSON.parse(response.getContentText())};
  }
  catch(e)
  {
    output = {"result":"error", "error": "Unable to fetch"};
  }
  return ContentService.createTextOutput(JSON.stringify(output)).setMimeType(ContentService.MimeType.JSON);
}

TL;DR: Replace the code in the script for the code provided above.




Step 3: Publish The Script
This step will be a bit complicated compared to the last steps. You need to make it a public API.

  1. Go to Publish, then to Deploy as web app.
  2. Change who has access to the app to “Anyone, including anonymous”.
  3. Click “Deploy”. When the next window comes up, click “Continue”, and in the window that pops up, click “Allow”
  4. You should now get this window. Don’t close it yet, the given link is important.

TL;DR: See images.




Step 4: Set Up The Module
If you haven’t already, open up Roblox Studio, and insert this module somewhere. You will now need to open it up. Start by getting the script it (in the window, or the page url if you close the window, take the massive string of characters from between /s/ and /exec, or /d/ and /edit if you are using the site url. Then paste it into the ScriptId variable.


TL;DR: Get the script id from the link (massive string of characters) and paste it into the ScriptId in the actual script in Roblox Studio (module link above).





Example Code

local HttpProxy = require(game.Workspace.HttpProxyService:Clone()) --Requires the module. Location will vary by where you place it

--Calls GetAsync to get the "bust" character thumbnail
print(game.HttpService:JSONEncode(HttpProxy:GetAsync("http://www.roblox.com/bust-thumbnail/json?userId=1&height=180&width=180")))
--{"Final":true,"Url":"http://t4.rbxcdn.com/7fce4b7a112122ec0611be343a794a71"}


--Calls GetAsync to get username from the user with the id of 261
print(game.HttpService:JSONEncode(HttpProxy:GetAsync("http://api.roblox.com/Users/261")))
--{"Id":261,"IsOnline":false,"AvatarFinal":false,"Username":"Shedletsky"}


--Calls GetAsync to get the primary group of TheNexusAvenger and Whimzee
print(game.HttpService:JSONEncode(HttpProxy:GetAsync("http://www.roblox.com/Groups/GetPrimaryGroupInfo.ashx?users=TheNexusAvenger,Whimzee")))
--{"Whimzee":{"RoleSetRank":255,"GroupName":"RBXDev","RoleSetName":"Group Owner","GroupId":979242},"TheNexusAvenger":{"RoleSetRank":2,"GroupName":"RBXDev","RoleSetName":"Group Game Managers","GroupId":979242}}

All Roblox web APIs: http://wiki.roblox.com/index.php?title=Web_APIs

If you do have a massive game, you will need to keep in mind the 20,000 request limit per data for the standard user, so you may need another source if you call it per player, however, if you don’t think you will exceed the limit, google will work fine.






If you want to share this post, here is a public link: http://imgur.com/QPl3YWo

197 Likes

<3!

15 Likes

You are my hero! No more need to make hosting website with the same function. Thanks <3

5 Likes

@TheNexusAvenger This is a huge time-saver-- thanks!

This proxy works perfectly for most Roblox API, but it returns an error for…
/v1/games/multiget-place-details and
/v1/games/multiget-playability-status
…where (I noticed that) the response is an array instead of a table.

How can I get around this? Thanks!

3 Likes

Just do a JSON parse on the returned data which should convert the new data into something you can work with for python.

3 Likes

Thanks for the reply.

I believe TheNexusAvenger’s code already does that. I’m having trouble specifically with fetching an array from those URLs. The others in https://games.roblox.com/docs#/ return tables, and there it works perfectly.

My guess is that the solution is pretty easy for someone who knows how the code actually works… I’m not one of those people

What’s happening is when there’s a table inside a table, most languages use both arrays and objects. However, roblox only had tables. The issue that occurs is when the json parse happens in the python code which turns the data into what you see is an array. A simple fix is to not parse the data in the python script but to send that json info straight over to the roblox script where you can then JSONDecode it.

2 Likes

Can someone please give me the link to get a groups member count?

You should be able to get the right api endpoint by looking at https://api.roblox.com/docs?useConsolidatedPage=true .

Does the script still work? I’m not sure why there is an error.

image

1 Like

Weird! I try to publish the script but I don’t see any ''publish buttons ‘’

Tried this, Not sure if its working anymore?

So for anyone having issues with this.

FOR SOME stupid reason, the main code that you put this on NEEDS to be named “Code.gs”, if it isn’t, then it won’t work. And if you’re in another language, the default isn’t “Code”, for me it was “Código”, so beware of that.

Edit: now it works with codigo, i honestly don’t even know at this point.

image

Any Idea this happens?

Hm yes, you’re using another proxy service for Roblox. rprxy.xyz is not a bad choice, I think a lot of people use that too, but you’re not supposed to use it with this thing.

what should i use instead?

30charararacters

Use the system set up above, and replace the rprxy.xyz with roblox.com

Oops i did something wrong! Thanks!

Sorry to bother you, but i’m getting this.
image

My Script:

local success, result = pcall(function() return HttpService:JSONEncode(HttpProxy:GetAsync("https://avatar.roblox.com/v1/users/"..tostring(UserId).."/outfits")) or nil, true end)

The proxy already does JSONDecode on the data. You don’t need to. I’m pretty sure you have to specify the amount of outfits too. Probably look at: