How do i request a random word from a website using roblox's http service

I want to request a random word from https://randomwordgenerator.com/ but I don’t know how, I don’t know how to get their API or JSON format

Do they have an API cause I haven’t been able to find it unfortunately. In the meantime, with a simple google search I actually did find a website that actually has an API. Here’s how you would get x amount of random words from the website’s API.

local HttpService = game:GetService("HttpService")
local URL = "https://random-word-api.vercel.app/api?words="

local TOTAL_WORDS = 10

local success, result = pcall(function()
    return HttpService:JSONDecode(HttpService:GetAsync(URL..TOTAL_WORDS))
end)

if success and result then
    for _, word in result do
        print(word)
    end
else
    warn(`API request failed. Error: {result}`)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.