REST API Reference¶
Ferrous DNS exposes a REST API for managing all aspects of the server. The API is served on the same port as the web dashboard (web_port, default 8080).
Base URL¶
| Mode | Base URL |
|---|---|
| Normal | http://<server>:8080/api |
| Pi-hole compat | http://<server>:8080/ferrous/api |
When pihole_compat = true, the Ferrous API moves to /ferrous/api/* and the Pi-hole v6 API occupies /api/*.
Authentication¶
When authentication is enabled ([auth] section in config), all API endpoints require either a valid session cookie or an API token — except the public auth endpoints listed below.
Session Authentication¶
Authenticate via the login endpoint to receive a session cookie:
POST /api/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "your-password"
}
The server sets a ferrous_session cookie on successful login. The cookie is sent automatically with subsequent requests from the dashboard.
API Token Authentication¶
For programmatic access, include an API token in the X-Api-Key header:
Create and manage tokens via the API Token endpoints below.
Both methods accepted
The auth guard accepts either a valid session cookie or an X-Api-Key header. You do not need both.
Response Format¶
All responses are JSON. Successful mutations return:
Errors return an appropriate HTTP status code with:
Health & System¶
Health Check¶
Returns server health status.
System Info¶
Returns system information: kernel version, load averages, memory usage.
Hostname¶
Returns the server hostname.
Statistics¶
Summary Stats¶
Returns aggregated query statistics: total queries, blocked queries, block rate.
Query Rate¶
Returns the current query rate. Supports unit=second or unit=minute.
Query Timeline¶
Returns query volume over time for dashboard graphs.
Top Blocked Domains¶
Top Clients¶
Query Log¶
List Queries¶
Returns recent DNS queries with filtering support.
| Parameter | Type | Description |
|---|---|---|
limit | integer | Max results (default: 100) |
offset | integer | Pagination offset |
Configuration¶
Get Config¶
Returns the full current configuration including server, DNS, blocking, logging, and database settings.
Update Config¶
Partial update — only include the sections you want to change:
Server settings (require restart):
Reload Config¶
Reloads the configuration from the TOML file without restarting the server. DNS, blocking, and cache settings take effect immediately. Server-level settings (ports, pihole_compat) require a full restart.
Get Settings¶
Returns DNS-specific settings (non-FQDN blocking, PTR blocking, local domain).
Update Settings¶
{
"never_forward_non_fqdn": true,
"never_forward_reverse_lookups": true,
"local_domain": "lan",
"local_dns_server": "192.168.1.1:53"
}
Auth Endpoints¶
Auth Status¶
Returns whether authentication is enabled and whether a password has been configured. Public — no auth required.
First-Run Setup¶
Sets the admin password on first run (when no password is configured). Public — no auth required.
Warning
This endpoint is only available when password_hash is empty. Once a password is set, it returns 403 Forbidden.
Login¶
Authenticates with username and password. Returns a session cookie (ferrous_session).
| Field | Type | Default | Description |
|---|---|---|---|
username | str | — | Admin username |
password | str | — | Admin password |
remember_me | bool | false | Extend session lifetime to remember_me_days |
Logout¶
Invalidates the current session. Public — no auth required (clears session if present).
Change Password¶
Changes the admin password. Protected — requires valid session or API token.
List Sessions¶
Returns all active sessions. Protected.
Revoke Session¶
Revokes a specific session by ID. Protected.
API Tokens¶
Named API tokens for programmatic access. Tokens are stored as SHA-256 hashes — the full token is only shown once at creation.
List Tokens¶
Returns all tokens. Only the token prefix is shown in the listing.
Create Token¶
Response includes the full token value — save it immediately:
Update Token¶
Update the token name or import a custom key:
Pi-hole migration
Use the key field to import existing API keys from Pi-hole or other tools.
Delete Token¶
User Management¶
List Users¶
Returns all users. Protected.
Create User¶
Delete User¶
Cache¶
Cache Stats¶
Returns cache hit/miss counts, hit rate, and total entries.
Cache Metrics¶
Returns detailed cache metrics: hits, misses, evictions, insertions, optimistic refreshes, lazy deletions, compactions, hit rate.
Upstream Health¶
Health Summary¶
Returns health status per upstream server (Healthy / Unhealthy).
Health Detail¶
Returns detailed health information per upstream: pool name, strategy, latency metrics, failure counts.
Clients¶
List Clients¶
Returns all detected clients with IP, MAC, hostname, group, query count, and last seen.
Client Stats¶
Returns per-client query statistics.
Create Manual Client¶
Update Client¶
Delete Client¶
Assign Client to Group¶
Client Subnets¶
Subnets auto-assign clients matching a CIDR range to a group.
List Subnets¶
Create Subnet¶
Delete Subnet¶
Groups¶
List Groups¶
Create Group¶
Get Group¶
Update Group¶
Delete Group¶
Get Group Clients¶
Blocklist Sources¶
List Sources¶
Create Source¶
{
"name": "HaGeZi Pro",
"url": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/domains/pro.txt",
"enabled": true
}
Get Source¶
Update Source¶
Delete Source¶
Whitelist Sources¶
List Sources¶
Create Source¶
Get / Update / Delete¶
Managed Domains¶
Individual domains added to the blocklist or allowlist via the dashboard.
List Domains¶
Create Domain¶
Get / Update / Delete¶
Regex Filters¶
List Filters¶
Create Filter¶
Get / Update / Delete¶
Block Filter Stats¶
Returns blocking engine statistics: total domains in blocklist, total in allowlist, filter size.
Blocklist & Allowlist (Compiled)¶
Get Active Blocklist¶
Returns the full compiled blocklist currently in memory.
Get Active Allowlist¶
Returns the full compiled allowlist currently in memory.
Services (1-Click Blocking)¶
Service Catalog¶
Returns all available service categories (built-in + custom).
Returns a specific service definition with its domain list.
Blocked Services¶
Returns services currently blocked for a group.
Block Service¶
Unblock Service¶
Custom Services¶
Define your own blockable service categories.
List / Create¶
{
"name": "My Custom Tracker",
"domains": ["tracker1.example.com", "tracker2.example.com"],
"category": "tracking"
}
Get / Update / Delete¶
Safe Search¶
Get Configs¶
Toggle Safe Search¶
Delete Configs¶
Local DNS Records¶
Static A/AAAA records served directly from cache.
List Records¶
Create Record¶
Update / Delete¶
Schedule Profiles¶
Time-based blocking profiles for parental controls.
List / Create Profiles¶
Get / Update / Delete Profile¶
Manage Time Slots¶
Assign Schedule to Group¶
Pi-hole v6 Compatibility API¶
When pihole_compat = true, the following Pi-hole v6 endpoints are available at /api/*:
| Method | Endpoint | Description |
|---|---|---|
POST | /api/auth | Pi-hole v6 login (session-based, same flow as Pi-hole) |
GET | /api/auth | Pi-hole v6 session status |
DELETE | /api/auth | Pi-hole v6 logout |
GET | /api/stats/summary | Dashboard summary stats |
GET | /api/stats/history | Query history timeline |
GET | /api/stats/top_blocked | Top blocked domains |
GET | /api/stats/top_clients | Top querying clients |
GET | /api/stats/query_types | Query type distribution |
See Pi-hole Compatibility for details.