This Cloudflare Worker provides a secure and cacheable API to check the latest version of a FiveM resource based on GitHub releases.
This is primarily designed for private repos for escrowed resources so you don't need to expose your access token in your resources, but it works fine with public repositories too.
It allows your FiveM resources to fetch version data from the github release via:
https://yourapidomain.com/versions/<resource-name>
- Successful response
{
"resource": "TAM_WeaponRealism",
"latestVersion": "v1.3.0",
"releaseUrl": "https://github.com/threeamigosmodding/TAM_WeaponRealism/releases/tag/v1.3.0",
"publishedAt": "2025-07-10T15:03:00Z"
}
- Error response. The error & resource will change depending on what failed.
{
"error": "Repository or release not found. Check that the resource exists and has at least one GitHub release.",
"resource": "UnknownResource"
}
Here's how you can utilize this in your resources.
CreateThread(function()
PerformHttpRequest("https://api.threeamigos.shop/versions/TAM_WeaponRealism", function(statusCode, response, headers)
if statusCode ~= 200 then
lib.print.warn("[Version Checker]: Failed to fetch latest version from API.")
return
end
local jsonData = json.decode(response)
if not jsonData or not jsonData.latestVersion then
lib.print.warn("[Version Checker]: Invalid API response.")
return
end
local latestVersion = jsonData.latestVersion
local currentVersion = GetResourceMetadata(GetCurrentResourceName(), "version", 0)
if not currentVersion then
lib.print.warn("[Version Checker]: No version metadata found in fxmanifest.")
return
end
if currentVersion ~= latestVersion then
lib.print.warn(("[Version Checker]: Outdated! Installed: %s, Latest: %s — Download the latest from CFX Portal."):format(currentVersion, latestVersion))
else
lib.print.info(("[Version Checker]: You are up to date! Version: %s"):format(currentVersion))
end
end, "GET", "", {})
end)
- A Cloudflare account
- Node.js <= 20. I recommend using node version manager or volta
- A domain (Optionally can use the cloudflare provided one)
- A Github account w/ resources that have proper release tags
- Wrangler CLI
- Clone the repository
- Install packages (either w/
pnpm i
ornpm i
etc) - Edit
src/index.ts
and change references ofThreeAmigosModding
to your Github username/org. - Add your Personal Access Token as a secret variable in the worker, named
GITHUB_TOKEN
. - https://developers.cloudflare.com/workers/configuration/secrets/#adding-secrets-to-your-project - Optionally, setup a custom domain for the worker - https://developers.cloudflare.com/workers/configuration/routing/custom-domains/
- If you aren't going to be using a custom domain, you'll need to remove the route in
wranger.jsonc
.
- If you aren't going to be using a custom domain, you'll need to remove the route in
- Deploy to a Cloudflare worker via
pnpx wrangler deploy
or by going through the Cloudflare dashboard.
This project is licensed under the GNU General Public License v3.0.
You are free to use, modify, and distribute it under the terms of the license,
as long as you credit the original authors and keep it under the same license.
See the full license text in LICENSE
.
If you use or modify this project, you must provide visible credit to:
Three Amigos Modding
GitHub: https://github.com/threeamigosmodding/version-api
This credit must appear:
- In the documentation or README of your project
- Or in an about/license section of your project
Built by Three Amigos Modding to provide secure and simple version tracking for FiveM resources.