I’ve recently created an API that allows Developers to get the Image Asset Id directly from the Decal Id by sending a request to my proxy server from in-game. This is a very quick method for those trying to use Image’s in-game that they don’t own and can’t access through InsertService. This is also better than trying to remove a digit from the end of the ID and trying to guess the Image ID.
It is very simple to access, and doesn’t require a massive knowledge of programming either.
Incorrect requests will will send a 400
Status Code signifying a malformed/incorrect request, with the error being provided in the response body.
Successful requests will send a 200
Status Code signifying a successful request, and the ImageId will be provided in the response body.
Unsuccessful requests, for example when an Image was not found, will send a 404
Status Code signifying an unsuccessful request, with the error being provided in the response body.
Let’s get to the Lua bit. This is very easy to use, and there are two ways of doing this; RequestAsync
and GetAsync
.
Below are examples of how to use both.
RequestAsync
local HttpService = game:GetService("HttpService")
local reqResponse = HttpService:RequestAsync{
Url = "http://lordhammy-api.herokuapp.com/api/GetImageFromDecalID/"..DECAL_ID_HERE;
Method = "GET";
}
if reqResponse.Success then
print("Status code: " .. reqResponse.StatusCode .. " " .. reqResponse.StatusMessage)
print("Response body:\n" .. reqResponse.Body)
-- SUCCESSFUL REQUEST WILL SAY:
-- Status code: 200 OK
-- Response body:
-- IMAGE_ID_HERE
else
print("The request failed: " .. reqResponse.StatusCode .. " " .. reqResponse.StatusMessage)
end
GetAsync
local httpService = game:GetService('HttpService')
local function GetAsync(Url)
local reqResults = {}
ypcall(function ()
reqResults = { httpService:GetAsync(Url) }
end)
return unpack(reqResults)
end
local function GetImageFromDecal(DecalId)
local ImageID = GetAsync("http://lordhammy-api.herokuapp.com/api/GetImageFromDecalID/"..DecalId)
if (ImageID and ImageID ~= "No image found for provided DecalId") then
return ImageID
end
end
local requestedImage = GetImageFromDecal(DECAL_ID_HERE)
if requestedImage then
print(requestedImage)
else
print('Image not found')
end
I know there may be other API’s like this, but this is something I needed personally and decided to release for use. If there are any bugs or suggestions please feel free to let me know below.