{"openapi":"3.0.3","info":{"title":"Random Dice 2 Lab Public API","version":"1.1.3","description":"Public programmatic interface for Random Dice 2 Lab game datasets, deck shares, MCP tool integrations, and calculation endpoints.","x-versioning-policy":"API endpoints are versioned under /api/v1/. Breaking changes will trigger /api/v2/ with a 6-month deprecation timeline."},"servers":[{"url":"https://rd2-lab.com","description":"Primary API Server"},{"url":"/","description":"Relative Server"}],"paths":{"/api/v1/shares":{"post":{"operationId":"createDeckShareV1","summary":"Create a deck share shortcode","description":"Store a simulation deck and rank build in D1 and retrieve a 6-character share code.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareCreateRequest"}}}},"responses":{"200":{"description":"Share successfully created or existing code retrieved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareCreateResponse"}}}},"400":{"description":"Invalid payload format.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/shares":{"post":{"operationId":"createDeckShare","summary":"Create a deck share shortcode (Canonical alias)","description":"Store a simulation deck and rank build in D1 and retrieve a 6-character share code.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareCreateRequest"}}}},"responses":{"200":{"description":"Share successfully created or existing code retrieved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareCreateResponse"}}}},"400":{"description":"Invalid payload format.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/shares/{code}":{"get":{"operationId":"getDeckShare","summary":"Retrieve deck configuration by code","description":"Fetch stored deck and rank configuration payload using a 6-character share code.","parameters":[{"name":"code","in":"path","required":true,"description":"6-character Base62 share code.","schema":{"type":"string","pattern":"^[0-9A-Za-z]{6}$"}}],"responses":{"200":{"description":"Share payload found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareDetailResponse"}}}},"404":{"description":"Share code not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/data/dice_tree.json":{"get":{"operationId":"getDiceTreeData","summary":"Get canonical dice tree topology","description":"Complete 243-node Directed Acyclic Graph containing all dice, runes, player passives, and unlock costs.","parameters":[{"name":"version","in":"query","required":false,"description":"Game balance data version tag (optional, e.g. '1.1.3').","schema":{"type":"string","default":"1.1.3"}}],"responses":{"200":{"description":"Full dice tree JSON graph.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DiceTreeResponse"}}}},"404":{"description":"Dataset file not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/boss_event_data.json":{"get":{"operationId":"getBossAndEventsData","summary":"Get monster compendium and wave events","description":"Dataset of 26 monsters and 57 wave events with HP scaling and SP rewards.","parameters":[{"name":"category","in":"query","required":false,"description":"Filter compendium category (optional, e.g. 'all', 'monsters', 'events').","schema":{"type":"string","enum":["all","monsters","events"],"default":"all"}}],"responses":{"200":{"description":"Monsters and events JSON dataset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BossEventResponse"}}}},"404":{"description":"Dataset file not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"ShareCreateRequest":{"type":"object","required":["payload"],"properties":{"payload":{"type":"string","description":"Base62 encoded deck and ranks configuration string."},"thumbnail":{"type":"string","description":"Optional base64 data URL for preview card rendering."}}},"ShareCreateResponse":{"type":"object","required":["code"],"properties":{"code":{"type":"string","description":"6-character Base62 unique share code.","example":"aB3x9Z"}}},"ShareDetailResponse":{"type":"object","required":["payload"],"properties":{"payload":{"type":"string","description":"Base62 encoded build data."}}},"DiceTreeResponse":{"type":"object","required":["summary","nodes"],"properties":{"summary":{"type":"object","required":["node_count","edge_count"],"properties":{"node_count":{"type":"integer","example":243},"edge_count":{"type":"integer","example":252}}},"nodes":{"type":"array","items":{"type":"object","required":["id","name_zh","node_type"],"properties":{"id":{"type":"string","example":"1001"},"name_zh":{"type":"string","example":"鐵骰子"},"name_en":{"type":"string","example":"Iron Dice"},"node_type":{"type":"string","example":"dice"},"category":{"type":"string","example":"physical"}}}}}},"BossEventResponse":{"type":"object","required":["monsters"],"properties":{"monsters":{"type":"array","items":{"type":"object","required":["id","name_zh"],"properties":{"id":{"type":"string","example":"boss_snake"},"name_zh":{"type":"string","example":"蛇王"},"name_en":{"type":"string","example":"Snake Boss"}}}}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","example":"NOT_FOUND"},"message":{"type":"string","example":"The requested resource was not found."},"hint":{"type":"string","example":"Check /openapi.json or /llms.txt for available endpoints."}}}}}}}}