{% extends "base.html" %} {% block title %}API Documentation - {{ app_name }}{% endblock %} {% block content %}
REST API for geo-blocking configuration generation.
Choose the endpoint based on your integration needs.
| Use Case | Recommended Endpoint |
|---|---|
| Programmatic CIDR integration (TXT / CSV / JSON / JS) | POST /api/generate/raw |
| Download ready-to-use application config (nginx / apache / haproxy) | POST /api/generate |
| Web UI preview (admin panel) | POST /api/generate/preview |
/api/generate/preview is intended for internal web UI usage.
It returns JSON with a raw config string + metadata and is not recommended for external production integrations.
nginx + map for production.
Prefer nginx variants geo or deny.
/health
Service health check
Simple liveness probe.
/api/countries
Get available countries
Returns list of countries with ISO codes and flag emojis.
{
"success": true,
"countries": [
{"code": "CN", "name": "China", "flag": "🇨🇳"}
]
}
/api/database/status
Check MaxMind DB status
Database status including update need and timestamps.
{
"success": true,
"exists": true,
"needs_update": false,
"last_update": "2026-02-10T08:00:00",
"file_size": 5242880,
"auto_update": true
}
/api/database/update
Trigger MaxMind DB update
Manual database update (download + replace).
{
"success": true,
"url": "https://github.com/...",
"size": 5242880
}
/api/cache/redis/status
Redis L1 status
Redis health + key stats.
/api/cache/sqlite/status
SQLite L2 status
SQLite cache file stats and top countries.
/api/cache/invalidate/<country_code>
Invalidate a single country
Clears Redis networks for a country + related cached configs.
curl -X POST /api/cache/invalidate/CN
/api/cache/flush
Flush Redis cache (all keys)
Flushes all Redis keys used by the application.
curl -X POST /api/cache/flush
/api/progress
Generation progress
Poll this endpoint during generation.
/api/stats/summary
Combined status summary
Aggregated status of MaxMind + SQLite + Redis.
/api/generate/preview
UI preview (JSON wrapper)
config contains raw text.
{
"countries": ["SG"],
"app_type": "haproxy",
"app_variant": "map",
"aggregate": true,
"use_cache": true
}
/api/generate/raw
Raw blocklist (TXT / CSV / JSON / JS)
Output format is selected by app_type.
Cache metadata is returned via response headers.
| app_type | Content-Type | Notes |
|---|---|---|
raw-cidr_txt | text/plain | default |
raw-cidr_csv | text/csv | CSV export |
raw-cidr_json | application/json | {countries, networks, count, aggregated} |
raw-cidr_json + as_js=true | application/javascript | const <js_var> = {...}; |
raw-json | application/json | alias (same schema as raw-cidr_json) |
{
"countries": ["SG"],
"networks": ["1.2.3.0/24", "..."],
"count": 123,
"aggregated": true
}
use_cache to false to force fresh scan.
JSON:
curl -X POST /api/generate/raw \
-H "Content-Type: application/json" \
-d '{"countries":["PL"],"app_type":"raw-cidr_json","aggregate":true,"use_cache":true}' \
-o blocklist.json
JSON (alias raw-json):
curl -X POST /api/generate/raw \
-H "Content-Type: application/json" \
-d '{"countries":["CN"],"aggregate":true,"use_cache":true,"app_type":"raw-json"}' \
-o blocklist.cn.json
JS wrapped:
curl -X POST /api/generate/raw \
-H "Content-Type: application/json" \
-d '{"countries":["PL"],"app_type":"raw-cidr_json","as_js":true,"js_var":"geoipBlocklist"}' \
-o blocklist.js
TXT (default):
curl -X POST /api/generate/raw \
-H "Content-Type: application/json" \
-d '{"countries":["PL"]}' \
-o blocklist.txt
CSV:
curl -X POST /api/generate/raw \
-H "Content-Type: application/json" \
-d '{"countries":["PL"],"app_type":"raw-cidr_csv"}' \
-o blocklist.csv
/api/generate
Download configuration file
Returns a file download (text/plain). Use the download action below.
nginx + map. Prefer nginx geo / deny.
| app_type | app_variant | Recommendation |
|---|---|---|
nginx | geo | recommended |
nginx | deny | recommended |
nginx | map | not recommended |
apache | 24 | recommended |
apache | 22 | legacy |
haproxy | map | recommended |
haproxy | acl | OK |
haproxy | lua | OK |
use_cache:false to force fresh scan. Prefer haproxy map or apache 24 / nginx geo.
HAProxy (map):
curl -X POST /api/generate \
-H "Content-Type: application/json" \
-d '{"countries":["SG"],"app_type":"haproxy","app_variant":"map","aggregate":true,"use_cache":true}' \
-o geoblock_haproxy_map.cfg
Apache 2.4:
curl -X POST /api/generate \
-H "Content-Type: application/json" \
-d '{"countries":["SG"],"app_type":"apache","app_variant":"24","aggregate":true,"use_cache":true}' \
-o geoblock_apache24.conf
Nginx (geo):
curl -X POST /api/generate \
-H "Content-Type: application/json" \
-d '{"countries":["SG"],"app_type":"nginx","app_variant":"geo","aggregate":true,"use_cache":true}' \
-o geoblock_nginx_geo.conf