Skip to content

API Reference

UA3F provides a RESTful API for runtime status, configuration, rules, logs, and restart control.

Enable it with:

yaml
api-server: "127.0.0.1:9000"
api-server-secret: "change-me"

Authentication

When api-server-secret is not empty, send the secret with either an Authorization header:

http
Authorization: Bearer change-me

or with the secret query parameter:

text
/version?secret=change-me

Unauthorized requests return 401 with:

json
{"error":"unauthorized"}

Endpoints

MethodPathDescription
GET/versionGet the UA3F version
GET/configGet the active runtime configuration
GET/rulesGet all header, body, and redirect rules
GET/rules/headerGet header rewrite rules
GET/rules/bodyGet body rewrite rules
GET/rules/redirectGet URL redirect rules
GET/logsStream or fetch runtime logs
GET/restartReload configuration and restart runtime components

Examples

Get the version:

sh
curl http://127.0.0.1:9000/version

Response:

json
{
  "version": "0.7.0"
}

Get all rules:

sh
curl -H "Authorization: Bearer change-me" http://127.0.0.1:9000/rules

Response shape:

json
{
  "header": [],
  "body": [],
  "redirect": []
}

Rule object

json
{
  "enabled": true,
  "type": "HEADER-KEYWORD",
  "match_header": "User-Agent",
  "match_value": "MicroMessenger",
  "action": "REPLACE",
  "rewrite_header": "User-Agent",
  "rewrite_value": "FFF",
  "rewrite_direction": "REQUEST",
  "rewrite_regex": "",
  "continue": false
}
FieldTypeDescription
enabledbooleanWhether the rule is enabled
typestringMatch type
match_headerstringHeader name for header-based matches
match_valuestringMatch value
actionstringAction to execute
rewrite_headerstringHeader to rewrite
rewrite_valuestringReplacement value
rewrite_directionstringREQUEST or RESPONSE
rewrite_regexstringRegex used by REPLACE-REGEX
continuebooleanContinue evaluating later rules after this match

Released under the GPL-3.0 license.