English • Español
FiveHub API client for FiveM. List, fetch, and delete assets, and get signed URLs from the server. Designed to be used from other resources via exports.
- API Key from FiveHub (Dashboard → API Key).
- Optional:
X-Organization-Idif the user belongs to multiple organizations.
- Copy the
fivemfolder (or its contents) into your FiveM server'sresourcesdirectory, for example:resources/ fivehub/ fxmanifest.lua config.lua server.lua - Set the convars in
server.cfg(or editconfig.lua):
set fivehub:baseUrl "https://fivehub.pro"
set fivehub:apiKey "your-api-key"
set fivehub:organizationId "optional-org-id"- Start the resource in
server.cfg:
ensure fivehubAll functions are server-side and use callbacks with the signature (err, result).
exports.fivehub:ListAssets(function(err, data)
if err then
print("Error: " .. tostring(err))
return
end
-- data.assets, data.total, data.limit, data.offset
for _, asset in ipairs(data.assets) do
print(asset.id, asset.name, asset.publicUrl)
end
end)
-- With pagination
exports.fivehub:ListAssets({ limit = 20, offset = 0 }, function(err, data)
if err then return end
-- ...
end)exports.fivehub:GetAsset("asset-id-here", function(err, asset)
if err then
print("Error: " .. tostring(err))
return
end
print(asset.name, asset.publicUrl, asset.size)
end)Useful for time-limited links. expiresIn is in seconds (default: 3600).
exports.fivehub:GetAssetUrl("asset-id", 7200, function(err, data)
if err then return end
-- data.url, data.expiresIn, data.asset
print("URL valid for " .. data.expiresIn .. " seconds: " .. data.url)
end)
-- Without the second argument: defaults to 3600 seconds
exports.fivehub:GetAssetUrl("asset-id", function(err, data)
if err then return end
print(data.url)
end)exports.fivehub:DeleteAsset("asset-id-here", function(err)
if err then
print("Error: " .. tostring(err))
return
end
print("Deleted successfully")
end)| Export | Arguments | Callback | Description |
|---|---|---|---|
ListAssets |
[options], cb |
(err, data) |
List assets (options: limit, offset). |
GetAsset |
assetId, cb |
(err, asset) |
Get an asset by ID. |
GetAssetUrl |
assetId, [expiresIn], cb |
(err, data) |
Return a signed URL (expiresIn in seconds). |
DeleteAsset |
assetId, cb |
(err) |
Delete an asset. |
Uploading files from FiveM requires building a multipart/form-data body and reading files from disk; this resource does not include an upload export. To upload from the server you can:
- Call the API directly using
PerformHttpRequestwith a multipart body, or - Use a separate service/backend that receives the file and calls the FiveHub API (for example, with the JavaScript SDK).
These endpoints are used, with the following headers:
X-API-KEY: API Key (required).X-Organization-Id: Organization ID (optional).
| Method | Path | Description |
|---|---|---|
| GET | /api/assets |
List (query: limit, offset) |
| GET | /api/assets/:id |
Get one |
| GET | /api/assets/:id/url |
Signed URL (query: expiresIn) |
| DELETE | /api/assets/:id |
Delete |
On error, the callback receives a string as the first argument (for example "Invalid API key" or "Asset not found"). Always check err before using the result.