This is a caching proxy for AniDB to prevent the rate limits by ensuring requests are cached. This is intended throttle the performance to prevent bans. Note there is still a chance you will get banned when you hit some daily limits not just because of rate of requests.
/api/anime-titles.dat.gzmaps to https://anidb.net/api/anime-titles.dat.gz/api/anime-titles.xml.gzmaps to https://anidb.net/api/anime-titles.xml.gz/httpapimaps to http://api.anidb.net:9001/httpapi documented in https://wiki.anidb.net/HTTP_API_Definition/images/main/*maps to https://cdn.anidb.net/images/main/
The /httpapi route applies two extra behaviors:
- Upstream calls are rate-limited so only one request is sent every 2 seconds (cache hits are returned immediately).
- If the first bytes of the response (after gzip decoding) contain
<error, the proxy setsCache-Control: no-storeto avoid caching error responses. request=animeonly keys againstaidand drops the other query parameters for the key
You can configure these environment variables:
HTTPAPI_MIN_DURATION(default:5s) — the minimum spacing between upstream calls enforced by themin_durationhandler.HTTPAPI_BACKEND_TIMEOUT(default:300s) — the cache backend timeout used for upstream backend requests.HTTPAPI_BACKEND(default:http://api.anidb.net:9001) — the upstream backend URL; you can point this at another proxy instance to chain with a friend and balance request limits.
Important: HTTPAPI_BACKEND_TIMEOUT must be at least as large as HTTPAPI_MIN_DURATION, and in practice should be larger because multiple requests may queue behind the first and each queued request increases the time the backend needs to serve them. A recommended tuning starting point is to set HTTPAPI_BACKEND_TIMEOUT to 100× HTTPAPI_MIN_DURATION.
Optionally, set a jitter factor (a small fractional random delay applied to min_duration) via the environment variable HTTPAPI_MIN_DURATION_JITTER (default: 0.01). Example (docker-compose):
services:
anidb-proxy:
image: ghcr.io/trajano/anidb-proxy:latest
environment:
- HTTPAPI_MIN_DURATION=5s
- HTTPAPI_BACKEND_TIMEOUT=300s
- HTTPAPI_MIN_DURATION_JITTER=0.01The min_duration handler also supports optional Caddyfile settings:
wait_threshold(default:5s) — maximum delay before the handler responds or proceeds.wait_mode(default:redirect) —redirect,retry-after, orwait.
Note: when wait_mode is set to wait, two requests for the same ID can both reach the upstream and the second request will not leverage the cache.
Additional mappings provided against /httpapi/ so it will be a single root.
/httpapi/anime-titles.dat.gzmaps to https://anidb.net/api/anime-titles.dat.gz/httpapi/anime-titles.xml.gzmaps to https://anidb.net/api/anime-titles.xml.gz/httpapi/images/main/*maps to https://cdn.anidb.net/images/main//httpapi/searchmaps to the search server though it's TTL is 1h rather than 24h. Onlyqueryandlangsneed to be provided astask=searchis implied.