Announcing Messaging Service API for Open Cloud

Oh, I didn’t see that.

Nice to see Roblox moving over to per-player-in-experience stats for requests-per-minute, was incredibly annoying to make my application scale with the Datastore APIs having a fixed limit.

3 Likes

Wow, this is so useful! I can’t even begin to explain…Actually, I will! I remember thinking of multiple different ways to get around the fact that I wanted to run server events or other things for every single server within my Roblox experience from something outside of Roblox like Discord, and it’s finally feasible. Thank you!

4 Likes

I’ve set up my own test bed to try out this update though I’m having issues with the response from running the POST request on the url returning “Status Code: 200 OK” but my ingame scripts never receive anything regardless of what the status code says. My url looks like this

2 Likes

Was the server you joined live while you sent the request? Only servers that are on when the request is sent will recieve the message.

2 Likes

Yes, there was a live server with the code necessary to receive the request running on it as well. I’m fairly certain the whole process of sending the POST request is correct as why would it send a response message of “OK” if it wasn’t. Though I’m still lost on why nothing is received ingame with the help of SubscribeAsync function

2 Likes

Are we ever going to get official support for creating developer products, currently we have to use the client API to do this which does not work very well especially when it involves the usage of cookies.

Repost from Recent and Upcoming Changes to Roblox Web APIs - #36 by parker02311

2 Likes

I have been waiting for this for soo long. This removes the need of long polling our web servers to send data to roblox games servers. I see many opportunities open up with this. Thanks for considering our feedback!

4 Likes

We’re tackling APIs piece-by-piece. I don’t have an official timeline to share but this is something we plan on exploring further.

8 Likes

This is something we’re working on as well. Our updated docs site will eventually support this functionality.

3 Likes

Now if only I knew how to use this…

4 Likes

For some reason it doesn’t work, I did everything as written in the documentation, I even receive the proper response and Roblox script doesn’t receive anything.

server.lua

local MessagingService = game:GetService("MessagingService")

MessagingService:SubscribeAsync("test", function(message)
	print("Fired", message)
end)

server.js

import fetch from "node-fetch";

var topic = "test";
var message = "hi";

var url = `https://apis.roblox.com/messaging-service/v1/universes/${universeId}/topics/${topic}`;

var headers = {
	"x-api-key": key,
	"Content-Type": "application/json"
};

var body = JSON.stringify({
	message: message
});

var response = await fetch(url, {
	method: "POST",
	headers: headers,
	body: body
});

I get 200 which means OK, along with empty response body.

image

5 Likes

We’re investigating this issue. Will report back once we figure out what’s going on.

----- EDIT -----
We found the problem and we’re working on a fix. We’ll let you know when it’s released.

4 Likes

I like that you give examples, but, the example you give is very limiting. I’m wondering how you would send a JSON object to the request.
So let’s say I have this:

{
    "Color": {"R": 255, "G": 255, "B": 0},
    "Message": "This is the Cloud API!",
    "Header": "Cloud API Announcement"
}

Would I need to shove this JSON into the message string as a string? Or would I be able to give the JSON object directly (like below) and it’d work?

{
    "message": {
        "Color": {"R": 255, "G": 255, "B": 0},
        "Message": "This is the Cloud API!",
        "Header": "Cloud API Announcement"
    }
}
2 Likes

You can definitely send a JSON encoded string, example:

{
    "message":"{\"Content\": { \"Subcontent\": 123}"
}

3 Likes

We have identified and issued a fix, please try the request again.

4 Likes

Yup, it works now.

image

4 Likes

Amazing, great job roblox! This will be very useful for connecting external apps and servers to roblox. We can finally make better web-based admin panels and connect other platforms without sending thousands of HTTP requests (or using long polling), they take a lot of server resources. :smiley:

3 Likes

The Open Cloud continues to surprise me with it’s new features. Keep it up Roblox! :+1:

3 Likes

I tried to use the API but I keep getting error 500 server internal error is there something wrong in my code?

import requests
import json
import Credentials as c

Key = c.Private_Key
UniverseId = c.Univ_Id
TopicId = c.TopicId

Data = "test"

Data = json.dumps(Data)
JsonData = json.loads(Data)

url = 'https://apis.roblox.com/messaging-service/v1/universes/'+ UniverseId +'/topics/'+ TopicId
headers = {'x-api-key': Key,'content-type': 'application/json'}
body = JsonData

response = requests.post(url, data = body, headers = headers)

print(url)
print(body)
print(response)
3 Likes

Yeah, try visiting apis.roblox.com or api.roblox.com either one of them does not exist (yet) or one has internal server error :neutral_face:

2 Likes