Files
api-duneawa/README.md
2026-05-10 20:38:05 +02:00

102 lines
3.1 KiB
Markdown

# Dune API
Node.js API for Dune: Awakening Questlog data. It imports items, skills, recipes, placeables, and NPCs in English and German into MongoDB, then exposes them through REST endpoints and Swagger UI.
## Quick Start
```powershell
npm install
npm run import:smoke
npm start
```
Open Swagger UI locally at `http://localhost:3030/docs`.
## Docker
```powershell
docker compose up --build
```
The container listens on `3030` and Docker Compose exposes it on `8030` by default. Set `API_HOST_PORT=3031` if your machine needs the alternate host port.
## Public HTTPS Domains
This app is configured for Dokploy/Traefik HTTPS by default. Traefik should terminate TLS and route both public HTTPS domains to the app container:
```text
https://dune.api.coppnic.cc -> container port 3030
https://ui.dune.api.coppnic.cc -> container port 3030
```
The public API URL is `https://dune.api.coppnic.cc`. Swagger UI is available at `https://ui.dune.api.coppnic.cc/docs`.
The OpenAPI document advertises the HTTPS API domain by default, so Swagger requests go to the right public API host. These values can be adjusted through environment variables:
```env
PUBLIC_API_URL=https://dune.api.coppnic.cc
PUBLIC_UI_URL=https://ui.dune.api.coppnic.cc
FORCE_HTTPS=true
```
## Import All Data
```powershell
npm run import
```
You can also call the script directly with filters:
```powershell
node scripts/import.js --datasets=items,skills --languages=en,de --max-pages=1
```
or call `POST /api/import` from Swagger UI with an empty JSON body:
```json
{}
```
The importer pulls every page for all configured datasets and both supported languages by default.
## Endpoints
- `GET /health`
- `GET /docs`
- `GET /openapi.json`
- `GET /api/item`
- `GET /api/item/{id}`
- `GET /api/skill`
- `GET /api/skill/{id}`
- `GET /api/recipe`
- `GET /api/recipe/{id}`
- `GET /api/placeable`
- `GET /api/placeable/{id}`
- `GET /api/npc`
- `GET /api/npc/{id}`
- `GET /api/{dataset}`
- `GET /api/{dataset}/{id}`
- `GET /api/search?q=...`
- `POST /api/import`
- `GET /api/import/status`
Use singular datasets for detailed records. These collections store the full Questlog single-record payloads. For example, `item` includes item-specific `raw.stats` structures such as `weaponStats`, `fillableStats`, and wearable stats.
```text
GET /api/item?language=en&limit=25
GET /api/item/LongRifle_Unique_Poison_03?language=en
GET /api/items/LongRifle_Unique_Poison_03?language=en
GET /api/item/Bloodsack_02?language=de
GET /api/skill/skills_ability_poisonmine?language=en
GET /api/recipe/Bloodsack_2_Recipe?language=en
GET /api/placeable/Atre_Banner_Placeable?language=en
GET /api/npc/bs43q?language=en
GET /api/search?q=rifle&datasets=item,skill,recipe&language=en
```
Public API datasets: `item`, `skill`, `recipe`, `placeable`, `npc`, `items`, `skills`, `recipes`, `placeables`, `npcs`.
Plural datasets are the older paginated Questlog summary collections. For OpenClaw and other clients that need complete stats and relationships, prefer the singular datasets.
For convenience, `GET /api/{pluralDataset}/{id}` checks the matching detailed singular collection first when one exists, then falls back to the older summary record.