FreeTool
txApi
by NickTacke · version 2026.10.25 · updated 5 days ago
No reviews yet
- Downloads
- 0
- Reviews
- 0
- Size
- 19 KB
- Code check
- Clean
- Licence
- MIT
- Released
- Nov 2026
FiveM resource that exposes txAdmin's web endpoints as a Lua API for players and admin actions
txApi
A less sketchy FiveM server resource that authenticates with txAdmin, exposes helper methods for actions, players, server controls, and (soon) utilities like noclip/repair/heal through imported functions.
Quick Start
Key, Type, Purpose, Notes
Runtime Overview
API ReferenceCore Helpers
Function, Returns, Notes
**
Modules
txApi.actions — History endpoints
Functions
Function, Description
**
Field, Type / Allowed Values, Notes
Examples
txApi.players — Player endpoints
Functions
Function, Description
**
Field, Type / Allowed Values, Notes
**
A less sketchy FiveM server resource that authenticates with txAdmin, exposes helper methods for actions, players, server controls, and (soon) utilities like noclip/repair/heal through imported functions.
Quick Start
- Drop the folder into your server resources, e.g.
resources/[local]/txApi. - Add
ensure txApitoserver.cfg. - Reference the bootstrapper in dependent resources:
-- fxmanifest.lua
server_scripts {
'@txApi/init.lua'
}
- Configure credentials and behaviour in
settings/config.lua.
Key, Type, Purpose, Notes
Config.Hostname, string, Base URL for txAdmin, Example: http://127.0.0.1:40120Config.Username / Config.Password, string, txAdmin credentials for API login, Use a service account; keep secrets out of gitConfig.Whitelist, string[], Resource names allowed to call txApi exports, Requests from others return 403Config.LogLevel, LogLevel alias (error · warn · info · debug · trace), Minimum log verbosity, Default infoRuntime Overview
init.lualazy-loads modules, hydrates thetxApitable, and spawns a thread that auto-authenticates when credentials exist.- Authentication state (cookie + CSRF token) lives in
core/http/auth.lua; helpers read from the sharedAuthStatetable. - All HTTP calls funnel through
txApi.txRequest, which enforces whitelisting, injects auth headers, and JSON-encodes bodies. - Logging is centralised in
core/logging/logging.lua; module helpers emit at sensible levels.
-- server.lua
while not txApi.isAuthenticated() do
Citizen.Wait(1000)
end
-- Most helpers accept either a net ID or a license identifier
txApi.players.message(12, 'Server restart in 5 minutes')
txApi.actions.revoke('WACF-2SF1')
txApi.server.restart()API ReferenceCore Helpers
Function, Returns, Notes
txApi.authenticate(host, user, pass), boolean, Stores session cookie + CSRF token on success, not necessary when credentials added to config.luatxApi.isAuthenticated(), boolean, Convenience flagtxApi.sendHTTPRequest(url, opts), HTTPResponse, Thin wrapper around PerformHttpRequesttxApi.txRequest(endpoint, opts), HTTPResponse, Authenticated request to / using whitelist + headerstxApi.log(level, ...), nil, Colourised console output respecting Config.LogLevel**
HTTPOptions** (used by sendHTTPRequest, txRequest):
method:GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD(defaults toGET).body: string or table payload (tables are JSON-encoded automatically bytxRequest).headers: table of additional headers.
{ ok = false, status = , errorText = }.Modules
txApi.actions — History endpoints
Functions
Function, Description
actions.search(options), Query history by timestamp, player info, reason, or action IDactions.stats(), Fetch aggregated history statisticsactions.revoke(actionId), Revoke a recorded warn/ban**
ActionSearchOptions**Field, Type / Allowed Values, Notes
sortingKey, timestamp · playerName · playerLicense · playerNetId, Defaults to timestampsortingDesc, 'true' · 'false', Defaults to 'true'actionId, string, Uses searchType=actionIdreason, string, Uses searchType=reasonidentifier, string, Uses searchType=identifiersfilter, 'warn' · 'ban', Adds filterbyTypeExamples
-- Most recent bans (descending)
txApi.actions.search({ filter = 'ban' })
-- Search using a specific player identifier and sort by name
txApi.actions.search({ identifier = 'license:1234', sortingKey = 'playerName', sortingDesc = 'false' })
-- Snapshot the current totals
local totals = txApi.actions.stats()
if totals.ok == false then
print(('Failed to fetch stats: %s'):format(totals.errorText or 'unknown'))
else
print(('Warns: %s, Bans: %s'):format(totals.totalWarns, totals.totalBans))
end
-- Compare against a previous run
local current = txApi.actions.stats()
if current.ok == false then
txApi.log('error', 'Failed to fetch current stats: ' .. (current.errorText or 'unknown'))
elseif previousStats and current.totalBans > previousStats.totalBans then
txApi.log('warn', 'New bans detected since last check')
end
-- Revoke a known action id
txApi.actions.revoke('WACS-12GF')
-- Revoke the first result from a search
local results = txApi.actions.search({ identifier = 'license:1234' })
if results.ok == false then
txApi.log('error', 'Search failed: ' .. (results.errorText or 'unknown'))
elseif results[1] then
txApi.actions.revoke(results[1].actionId)
endtxApi.players — Player endpoints
Functions
Function, Description
players.search(options), Find players by name, identifiers, or notesplayers.stats(), Fetch players metrics (total, active/new in last 24h, new in last 7d)players.get(playerId), Fetch a single player profile (includes playTime) by net ID or licenseplayers.action(action, playerId, body), Low-level helper backing the wrappersplayers.message(playerId, message), Send a message to a playerplayers.warn(playerId, reason), Issue a warningplayers.kick(playerId, reason), Disconnect a playerplayers.ban(playerId, reason, duration), Apply temporary or permanent bans**
PlayerSearchOptions**Field, Type / Allowed Values, Notes
name, string, Uses searchType=playerNameidentifier, string, Uses searchType=playerIdsnotes, string, Uses searchType=playerNotessortingKey, playTime · tsJoined · tsLastConnection, Defaults to tsJoinedsortingDesc, 'true' · 'false', Defaults to 'true'offsetLicense, string, Continue pagination from a license value**
players.action parameters**
action:message|warn|kick|ban.playerId: server net ID or identifier string (e.g.license:abcdef...). Colon-prefixed identifiers are normalis