Documenation

Integrate blox.games into your game

How does it work?

Users have the ability to vote once every 12 hours for a game. They can either vote for the same game or vote for a new game. You can obtain your API key by going to your game (or importing it if it does not currently exist), and clicking claim game and following the flow. Roblox prevents any form of real-time voting recognition so all votes will have to be requested over HTTP. Upon requesting votes, we mark them as read to prevent them being read twice. Upon receiving the vote list, due to games being distributed you'll have to do some form of pub/sub.


The script

The script below is merely an example of how you could get this to integrate with your game!

local HttpService = game:GetService("HttpService") local MessagingService = game:GetService("MessagingService") local Players = game:GetService("Players") local RunService = game:GetService("RunService") local Chat = game:GetService("Chat") local VOTES = "https://www.blox.games/api/votes" local VOTE_TOPIC = "votes" local headers = { ["Authorization"] = "YOUR API KEY", } local function usersWhoVoted() local response local data pcall(function () response = HttpService:GetAsync(VOTES, false, headers) data = HttpService:JSONDecode(response) end) if not data then return { } end local votedUsers = { } for i, vote in pairs(data) do votedUsers[i] = vote.userId end return votedUsers end local function triggerFunction(user) print("Vote: " .. user) end spawn(function() while true do local votedUsers = usersWhoVoted() for _, votedUser in ipairs(votedUsers) do if (not RunService:IsStudio()) then local publishSuccess, publishResult = pcall(function() MessagingService:PublishAsync(VOTE_TOPIC, votedUser) end) if not publishSuccess then continue end else triggerFunction(votedUser) end end wait(5) end end) pcall(function() return MessagingService:SubscribeAsync(VOTE_TOPIC, function(message) for _, player in pairs(Players:GetPlayers()) do if player.UserId == message.Data then triggerFunction(message.Data) end end end) end)

Want to check if a user has voted synchronously?

You can use the following endpoint to check if a user has voted for your game:

https://www.blox.games/api/games/[placeId]/players/[playerId]

The endpoint returns the following schema:

{ "votedEver": true, "votedInPast24Hours": false, "votedInPast12Hours": false, "lastVote": "2022-09-16T11:03:14.466Z" }

Still need help?

If you still need help with integrating, feel free to join our discord and ping a member of staff!

Join our Discord

Meet other players and join games together

Can't find your game?

Add your game