Audnexus does not curate metadata and returns provider data as-is. Audible and other providers have duplicates, misspellings, and inconsistent values, and delisted products can be hard to find. AudiobookDB curates and corrects records, maintains the data, and applies standards to titles and credits. Start new projects there. Audnexus stays online for existing integrations.
Audnexus is the legacy, self-hosted HTTP API for audiobook metadata. It combines Audible's API and product pages into consistent records for media servers and metadata-provider plugins. A client can retrieve what it needs in one or two API calls. MongoDB stores records, and Redis can cache responses. Optional history records metadata and artwork changes as revisions.
Nexus, noun: a connection or series of connections linking two or more things.
When we looked for audiobook metadata, there was no single open source of truth. Some community-curated sources had closed their APIs. We built audnexus to bring audiobook content from multiple sources together in one response.
That makes it easier to integrate with existing media servers. With one or two API calls, clients have little to no processing overhead, which helps developers build stable plugins quickly. We built audnexus as an interim provider and a future seeder for a community-driven database. AudiobookDB is where that curation happens now.
- Start with AudiobookDB
- About
- Quick start
- API
- Deployment
- Configuration
- Database indexes and startup readiness
- Redis durability and sizing
- Book history
- Troubleshooting
- Development and tests
- Built with
- Contributing
- Author
- Acknowledgements
- License
You need Git, Docker with Compose, and curl. Create /mnt/docker/mongo/data on the Docker host and make it writable by the MongoDB container. Alternatively, change the bind mount in docker-compose.develop.yml. This directory holds the database.
Clone the repository and start the stack:
git clone https://github.com/laxamentumtech/audnexus.git
cd audnexus
docker compose -f docker-compose.develop.yml up -dThe stack starts the API, worker, MongoDB, and separate control and cache Redis services. It publishes the API on port 3000. The bundled MongoDB image is pinned to mongo:7.0.45. The Compose file defaults to the mutable ghcr.io/laxamentumtech/audnexus:develop image for this quick start. For production, use an immutable release tag or digest instead. See Docker Swarm.
Wait for startup, then check health and request a book:
curl -f http://localhost:3000/health
curl -f http://localhost:3000/books/B08G9PRS1KThe health response has "status":"healthy", with server, database, and redis checks set to true. The book response is a JSON record with ASIN B08G9PRS1K and title Project Hail Mary. The first request needs access to Audible, and availability can vary by region. Once the endpoint responds, point your media server or plugin at http://<host>:3000.
Audnexus prepares its database, collection validators, and required indexes at startup. It also creates the update schedules automatically. Index builds can delay readiness on an existing database. See startup readiness if the API is not ready yet.
The API reference describes book, author, chapter, search, history, artwork, health, and metrics endpoints. It also lists supported regions and request parameters. The OpenAPI source is in this repository.
Typed errors and rate-limit errors use an error object with a code, message, and optional details. Some routes return their own error shapes. A rate-limit response, for example, is:
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit reached. Please try again later.",
"details": null
}
}| Code | HTTP status | Meaning |
|---|---|---|
BAD_REQUEST |
400 | The request is invalid. |
CONTENT_TYPE_MISMATCH |
400 | The item has a different content type from the one requested. |
NOT_FOUND |
404 | The requested resource was not found. |
REGION_UNAVAILABLE |
404 | The item is unavailable in the requested region. |
PRODUCT_DELISTED |
404 | Audible reports that the product is delisted. |
CONFLICT |
409 | A concurrent or contradictory state prevents the operation. |
VALIDATION_ERROR |
422 | Schema validation failed. |
RATE_LIMIT_EXCEEDED |
429 | The request rate limit was reached. |
The details field can be omitted or null. Other status-bearing errors can use their numeric status as the error code.
MongoDB is required for every deployment. Redis is optional for an API-only deployment, but the worker and scheduled updates require REDIS_URL. The API uses an in-process rate limiter without control Redis. Chapter requests require registered Audible device credentials: ADP_TOKEN and PRIVATE_KEY. See the Audible registration guide.
From the repository root, build the image with the default Dockerfile:
docker build -t audnexus .For a local Compose deployment, set AUDNEXUS_IMAGE=audnexus so the stack uses that image. Use a release tag or digest for production.
- Create an application from the Git repository and select a branch.
- Configure
MONGODB_URIand any settings you need from Configuration. Use a reachable MongoDB service with persistent storage. - Build with the repository's Dockerfile. Set the application port to
3000and the health check to/health. - For scheduled updates, run a separate worker service from the same image with
bun run workeras its start command. Give it the same MongoDB and Redis settings as the API, includingREDIS_URL.
Use a separate cache Redis for REDIS_CACHE_URL if you enable cache eviction. The API can run without Redis, but the worker cannot.
For optional automatic deployment, add the Coolify webhook URL as the GitHub secret COOLIFY_WEBHOOK. Create a Coolify API token with Deploy permission and add it as COOLIFY_TOKEN. The Coolify workflow calls the webhook after a successful current main CI run with a successful image build. Coolify then builds from its connected repository and branch. The workflow does not move image tags.
The production docker-compose.yml runs the API, worker, MongoDB, two Redis services, and Traefik. It defaults to 15 API replicas. Adjust that count for your deployment. You need an initialized Docker Swarm and a writable /mnt/docker/mongo/data on the node running MongoDB. Plan placement and persistent storage for that node-local bind mount.
Do not enable BOOK_HISTORY_ENABLED=true against the bundled MongoDB service. It is standalone, not a replica set, so the API and worker will fail at boot. Point MONGODB_URI to a transaction-capable replica set first.
The durable Redis volume is node-local too. Label exactly one Swarm node before deploying. Replace NODE with the name of the node that will hold redis-data:
docker node update --label-add audnexus-redis=true NODEWith no labeled node, Redis stays pending. A second labeled node can cause a reschedule onto an empty volume and loss of queue and rate-limit state. Before moving the label, restore or migrate the existing volume to the new node.
Set and export AUDNEXUS_IMAGE, TRAEFIK_DOMAIN, and TRAEFIK_EMAIL in the deployment shell. Use a fully qualified immutable release version tag or SHA-256 digest for AUDNEXUS_IMAGE. Never use :latest, :develop, an untagged repository, or a bare version such as v1.15.0 for production. The Compose file requires a nonempty image reference but does not prove it is immutable.
From a checkout with Bun installed, check the reference's form before deploying:
bun scripts/validate-image-reference.ts "$AUDNEXUS_IMAGE"The validator accepts fully qualified version tags and SHA-256 digest pins. It cannot prove that a tag points to the release you intended. Deploy from a Swarm manager:
docker stack deploy -c docker-compose.yml audnexusAfter deployment, verify that the running image digest matches the release you selected.
The stack publishes MongoDB and control Redis ports as well as the API and Traefik ports. Restrict access to the database ports for your environment. Swarm starts services in parallel, so its health checks and restart policies handle dependencies that are not ready yet.
These are application defaults unless noted otherwise. Set them on each process that needs them. The bundled Compose files pass only the variables listed under each service, so add other settings to the relevant service if you need them. Both Compose files set MAX_REQUESTS to 300 by default, rather than the application default of 100.
| Variable | Default | Purpose |
|---|---|---|
MONGODB_URI |
Required | MongoDB connection URI, such as mongodb://localhost:27017/audnexus. The application always uses the audnexus database. |
DB_INDEX_MODE |
auto |
Create missing required indexes at startup, or use verify to require them without creating indexes. |
DB_INDEX_BUILD_WAIT_MS |
1800000 |
Maximum wait in milliseconds for each required index build. |
REDIS_URL |
Unset | Control Redis for BullMQ and shared rate limiting. Required by the worker. Use noeviction. |
REDIS_CACHE_URL |
Falls back to REDIS_URL |
Document-cache Redis. Use a separate server before enabling cache eviction. |
REDIS_CACHE_TTL_SECONDS |
432000 |
Positive integer cache TTL in seconds, applied on inserts and overwrites. |
HOST |
0.0.0.0 |
API listen address. |
PORT |
3000 |
API listen port. |
LOG_LEVEL |
info |
Log level: trace, debug, info, warn, error, or fatal. |
TRUSTED_PROXIES |
127.0.0.1 plus fetched Cloudflare ranges |
Comma-separated trusted proxy IP addresses or CIDR ranges. Add your proxy address when it is not loopback. |
DEFAULT_REGION |
us |
Default region for batch processing. |
ADP_TOKEN, PRIVATE_KEY |
Unset | Registered Audible device credentials for chapters. |
MAX_REQUESTS |
100 |
Maximum requests per minute per source. Compose defaults to 300. |
| Variable | Default | Purpose |
|---|---|---|
UPDATE_INTERVAL |
30 |
Days between book and author update passes. 0 disables those schedules. |
UPDATE_INTERVAL_CHAPTERS |
30 |
Days between chapter update passes. 0 disables the chapter schedule. |
UPDATE_THRESHOLD |
7 |
Minimum age in days before checking a document for updates again. |
RATE_LIMIT_COOLDOWN_BASE_MS |
120000 |
Initial inter-item cooldown after consecutive rate-limit responses. |
RATE_LIMIT_COOLDOWN_MAX_MS |
7200000 |
Maximum adaptive cooldown in milliseconds. |
HTTP_MAX_SOCKETS |
50 |
Maximum pooled HTTP sockets. Values above 50 are clamped. |
HTTP_TIMEOUT_MS |
30000 |
HTTP request timeout in milliseconds. |
SCHEDULER_CONCURRENCY |
5 |
Maximum concurrent scheduler operations. |
SCHEDULER_MAX_PER_REGION |
5 |
Maximum per-region concurrency in batch processing. |
SCHEDULER_BATCH_SIZE |
1000 |
Documents per pagination batch, capped at 10000. |
SCHEDULER_ITEM_TIMEOUT_MS |
120000 |
Per-item wait deadline in milliseconds. 0 disables it. A late handler can continue and its writes can still land. |
SCHEDULER_MAX_ITEMS |
0 |
Maximum documents visited per pass. 0 means unlimited. |
JITTER_MS |
0-5000 |
Random pacing range in milliseconds, as min-max or a bare maximum. |
AUDIBLE_BATCH_SIZE |
1 |
Ratings-backfill batch size. Values from 2 to 50 use Audible's undocumented multi-ASIN endpoint for same-region books. Stubs and failed chunks fall back to individual requests. |
The worker creates or refreshes the enabled schedules and enqueues startup passes where needed. You do not need to set up the scheduler manually.
The general Boolean flags accept true in any case or 1 for true. BOOK_HISTORY_ENABLED is stricter: use lowercase true or false.
| Variable | Default | Purpose |
|---|---|---|
USE_PARALLEL_SCHEDULER |
false |
Enable parallel updates. This is high risk and requires testing. |
USE_SORTED_KEYS |
false |
Sort object keys, with O(n log n) overhead. |
CIRCUIT_BREAKER_ENABLED |
true |
Enable the circuit breaker for external API calls. |
BOOK_HISTORY_ENABLED |
false |
Record book metadata and artwork history. Requires a transaction-capable MongoDB replica set. |
METRICS_ENABLED |
false |
Enable performance metrics and /metrics. |
METRICS_AUTH_TOKEN |
Unset | Token accepted in the x-metrics-token header. |
METRICS_ALLOWED_IPS |
Unset | Comma-separated IP addresses or CIDR ranges allowed to access metrics. |
UPDATE_STATS |
0 |
Set to 1 to enable the ratings-backfill admin route. |
ADMIN_TOKEN |
Unset | Token for /books/backfill-ratings, sent in the x-admin-token header. The route also requires UPDATE_STATS=1 and control Redis. |
If metrics are enabled without a token or IP allowlist, /metrics is publicly accessible. Configure at least one access control for a deployment exposed to other users.
Earlier documentation listed MAX_CONCURRENT_REQUESTS, USE_CONNECTION_POOLING, and USE_COMPACT_JSON as tuning controls. The current application reads these values into configuration but has no runtime consumers for them. Use HTTP_MAX_SOCKETS to configure pooled sockets.
The API and worker prepare the shared schema and index catalog before they become ready. With the default DB_INDEX_MODE=auto, startup creates missing indexes and waits for required builds. This applies to existing volumes and external databases as well as new installations. Startup adopts equivalent existing indexes even if their names differ. ASIN/region indexes remain non-unique and do not deduplicate old records.
Set DB_INDEX_MODE=verify if a deployment job owns index creation. Startup then checks for completed matching indexes without issuing index DDL. It still prepares collection schemas, so it needs createCollection and collMod privileges.
DB_INDEX_BUILD_WAIT_MS limits the wait for each index, not the whole startup. Indexes build sequentially, so total startup can take longer. The bundled Compose health-check grace defaults to 30m. Increase STARTUP_GRACE_PERIOD for the full build time, or optionally pre-apply the catalog for a large database before rolling out the same application version.
After building the project and setting MONGODB_URI, the database-only commands are:
bun dist/indexes.js check
bun dist/indexes.js applycheck is read-only and works with read-only credentials. It does not create collections, prepare schemas, connect to Redis, or start jobs. apply prepares schemas and indexes without starting the API or worker. Both target the audnexus database. The commands are optional for normal startup.
Automatic index changes are additive. The application reports unknown, redundant, and legacy indexes but never drops them automatically. Same-name conflicts and changes to uniqueness, partial filters, collation, TTL, or text indexes require an explicit migration. MongoDB permits only one text index per collection, so a changed text index cannot use a blind build-new/drop-old sequence. /health checks service connectivity, not ongoing index drift.
The bundled stacks separate control Redis from the disposable document cache. Control Redis holds BullMQ jobs, schedules, and shared rate-limit state. It persists /data, enables append-only file (AOF) persistence with appendfsync everysec, and uses noeviction. Cache Redis uses allkeys-lfu without AOF or RDB persistence. A cache restart can require repopulation, but must not remove control state. Logical databases on one Redis server do not isolate memory pressure or eviction.
For an existing single-Redis deployment, deploy code that supports the split first. Set REDIS_CACHE_URL to a separate private cache. Verify that document callers have moved before you reduce the original Redis budget. Do not enable eviction on the old shared instance or flush its database. Before you roll back to code that ignores REDIS_CACHE_URL, restore a compatible shared-Redis budget.
If AOF is disabled on an existing control Redis, it is not safe to add appendonly yes and recreate the container as a migration. Quiesce writers and preserve a recoverable snapshot. Enable AOF on the running instance, then wait for a successful rewrite and fsync. Verify the data on the intended volume before you replace the container. AOF every second can still lose recent writes. Keep tested backups.
The Compose files expose these sizing and logging settings:
| Variable | Default | Purpose |
|---|---|---|
REDIS_CONTROL_MAXMEMORY |
128mb |
Control-state budget, not an eviction allowance. |
REDIS_CACHE_MAXMEMORY |
512mb |
Disposable cache budget. |
MONGO_WIREDTIGER_CACHE_GB |
1.0 |
WiredTiger cache size, not total MongoDB memory. |
STARTUP_GRACE_PERIOD |
30m |
Health-check grace for startup and index builds. |
CONTAINER_LOG_MAX_SIZE |
10m |
Maximum size of each rotated container log. |
CONTAINER_LOG_MAX_FILES |
3 |
Number of retained log files per container. |
These values are not container memory limits or capacity guarantees. Allow for clients, allocators, MongoDB memory outside the cache, index builds, and Redis fork and copy-on-write peaks. Do not count swap as sustainable capacity. Monitor disk space for database growth and RDB/AOF rewrites.
MONGO_IMAGE, REDIS_IMAGE, and REDIS_CACHE_IMAGE override the bundled database image pins. Use immutable references and validate database upgrades separately from memory tuning. An application dependency update does not upgrade an external managed database. Do not roll back the application image just to change resource settings.
History records accepted metadata and artwork changes as revisions. It is disabled by default. Set BOOK_HISTORY_ENABLED=true only after MONGODB_URI points to a transaction-capable replica set. Startup prepares the required indexes automatically. Recording does not store image bytes, and it does not track ratings.
To seed legacy artwork, build the project and set MONGODB_URI. These commands connect directly to MongoDB without starting the API, Redis, or worker:
bun dist/history.js audit
bun dist/history.js seed
bun dist/history.js statusaudit reports identity exceptions and a summary of identity and image counts. seed requires a transaction-capable replica set and prepared indexes. It commits each row and its checkpoint together and resumes after interruption. It does nothing if you repeat a completed run. status reports progress and retained history coverage.
To start a new scan instead of resuming an in-flight run, use:
bun dist/history.js seed --restartThis resets scan progress and its captured bound, not history data. bun dist/history.js prepare is an optional way to prepare schemas and the full index catalog ahead of startup. Like indexes apply, it creates missing indexes even when DB_INDEX_MODE=verify. Inside the deployed image, run the same bun dist/history.js commands with the container's configured MONGODB_URI.
- If the API is not listening yet, check the container logs and allow time for the required index builds. Confirm that the MongoDB bind mount exists and is writable.
- If
/healthreturns503, check MongoDB and each configured Redis role. The response reports their connectivity. - If updates are not running, confirm that the worker is running and has
REDIS_URL. The API can serve requests without it, but cannot schedule updates without control Redis. - If history-enabled startup fails, verify that MongoDB is a transaction-capable replica set and that required history indexes are ready. The bundled standalone MongoDB cannot pass this check.
- If startup reports an index conflict, inspect the report before making a migration. Startup does not replace or drop the conflicting index.
Install Bun 1.3.9 or newer. CI uses Bun 1.4.4. Provide a reachable MongoDB instance and set MONGODB_URI. Only the worker and scheduled jobs need Redis.
bun install
bun run build
MONGODB_URI=mongodb://localhost:27017/audnexus bun run serveFor a build followed by debug watch mode, use bun run debug with MONGODB_URI set. Package imports resolve to dist, so rebuild after changing other TypeScript source files. To run the worker, build first and start bun run worker with both MONGODB_URI and REDIS_URL set.
bun run test
bun run test:indexes
RUN_LIVE_TESTS=true bun run test:liveThe default test command writes coverage to coverage/. The index integration tests start a MongoDB replica set in Docker. Live tests contact Audible and are disabled unless RUN_LIVE_TESTS=true. Chapter live tests also need ADP_TOKEN and PRIVATE_KEY. See the live test guide. For history integration tests, use bun run test:history.
To generate HTML from the checked-in OpenAPI source, run bun run build-docs. This writes docs/index.html. The checked-in HTML and spec carry an older version label, so use the live API reference or a release's documentation asset for published docs.
Audnexus uses Fastify for HTTP, Bun as its runtime, MongoDB and Papr for data storage, and Redis for control state and optional caching. BullMQ runs the update worker.
See CONTRIBUTING.md for contribution guidance and CHANGELOG.md for changes.
@djdembeck created audnexus and did the initial work.
