2.3 KiB
2.3 KiB
API Endpoints for Frontend Compatibility
This document defines the minimal backend surface expected by the Vue frontend. Default base path is /api; responses are JSON with Content-Type: application/json.
POST /api/randomize
- Purpose: Produce a randomized Dota 2 build and optionally return the full data sets used for rendering.
- Request body:
includeSkills(boolean) — include a skill build suggestion.includeAspect(boolean) — include an aspect suggestion.itemsCount(number) — how many items to return (UI offers 3–6).
- Response 200 body:
hero— object{ id: string; name: string; primary: string; }.items— array of{ id: string; name: string; }with lengthitemsCount(also used to hydrate cached items if you return the full pool).skillBuild(optional) —{ id: string; name: string; description?: string; }whenincludeSkillsis true.aspect(optional) — string whenincludeAspectis true.heroes(optional) — full hero list to cache client-side; same shape ashero.skillBuilds(optional) — full skill build list; same shape asskillBuild.aspects(optional) — array of strings.
- Example request:
{
"includeSkills": true,
"includeAspect": false,
"itemsCount": 6
}
- Example response:
{
"hero": { "id": "pudge", "name": "Pudge", "primary": "strength" },
"items": [
{ "id": "blink", "name": "Blink Dagger" },
{ "id": "bkb", "name": "Black King Bar" }
],
"skillBuild": { "id": "hookdom", "name": "Hook/Rot Max", "description": "Max hook, then rot; early Flesh Heap." },
"heroes": [{ "id": "axe", "name": "Axe", "primary": "strength" }],
"skillBuilds": [{ "id": "support", "name": "Support" }],
"aspects": ["Heroic Might"]
}
Error Handling
- Use standard HTTP status codes (400 invalid input, 500 server error).
- Error payload shape:
{ "message": "Failed to load random build" }
- The UI surfaces
messagedirectly; keep it user-friendly.
Implementation Notes
- Ensure deterministic constraints: unique
idper entity and avoid empty arrays whenincludeSkills/includeAspectare true. - If backing data is static, you may return
heroes/items/skillBuilds/aspectsonce per request; the frontend caches them after the first successful call.