{"openapi":"3.1.0","info":{"title":"Mahjong Hand Checker API","version":"0.1.0","description":"Pay-per-call mahjong hand checker (USDC, x402): is a hand a win, what does it score, what does it wait on. Rule-based, no AI model. Scoring follows Ordstirr's own written rule sets (house rules from published faan/tai lists), not an official tournament ruling.","x-guidance":"Use POST /v1/check-hand with JSON bodies. Unpaid calls receive HTTP 402 with x402 payment terms. See /llms.txt.","termsOfService":"https://ordstirr.com/agents/terms","contact":{"url":"https://ordstirr.com"}},"servers":[{"url":"https://mahjong.ordstirr.com"}],"paths":{"/health":{"get":{"operationId":"health","summary":"Free health check","security":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/v1/check-hand":{"post":{"operationId":"checkMahjongHand","summary":"Check a mahjong hand: win or not, shape, waits, shanten and score (Hong Kong, Taiwanese, Riichi shape, Chinese Official shape)","description":"Send a hand as tile codes. If the hand is complete (3n+2 tiles counting melds as 3), returns whether it is a win, every standard split, and a score for Hong Kong (faan) and Taiwanese 16-tile (tai). If it is one tile short (3n+1), returns the winning tiles it waits on. Always returns shanten. Our own rule sets only; no tournament card content. Unpaid calls receive HTTP 402 with x402 payment terms. Invalid input is rejected with HTTP 400 and never charged.","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.02"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"rules":{"type":"string","enum":["hk","tw","riichi","mcr"],"description":"hk = Hong Kong Old Style (13 tiles), tw = Taiwanese 16-tile, riichi and mcr = shape check only."},"tiles":{"description":"Concealed tiles including the winning tile, as an array [\"1c\",\"2c\"...] or a string \"123c 456b 55d EEE\". 1c-9c characters, 1b-9b bamboo, 1d-9d dots, E S W N winds, Rd Gd Wd dragons.","oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"melds":{"type":"array","maxItems":5,"items":{"type":"object","properties":{"type":{"enum":["chow","pung","kong"]},"tile":{"type":"string","description":"chow: its lowest tile"},"concealed":{"type":"boolean","description":"default false (claimed)"}},"required":["type","tile"],"additionalProperties":false}},"flowers":{"type":"array","items":{"type":"string","description":"F1-F4 flowers, S1-S4 seasons"},"maxItems":8},"winning_tile":{"type":"string","description":"The tile that completed the hand (must be among tiles). Needed for single-wait and concealed-pung rules."},"seat_wind":{"enum":["E","S","W","N"]},"round_wind":{"enum":["E","S","W","N"]},"self_drawn":{"type":"boolean"},"last_tile":{"type":"boolean"},"kong_replacement":{"type":"boolean"},"robbed_kong":{"type":"boolean"},"heavenly":{"type":"boolean"},"earthly":{"type":"boolean"},"dealer_streak":{"type":"integer","minimum":0,"maximum":99,"description":"Taiwanese: times the dealer has kept the deal"}},"required":["rules","tiles"],"additionalProperties":false},"example":{"rules":"hk","tiles":"234c 567b 789d 555d 66b","winning_tile":"6b","self_drawn":true,"seat_wind":"E","round_wind":"E"}}}},"responses":{"200":{"description":"Result","content":{"application/json":{"schema":{"type":"object"},"example":{"rules":"hk","rule_name":"Hong Kong Old Style","complete":true,"shape":"standard","score":{"unit":"faan","total":3,"points":8,"items":[{"name":"Self-drawn","value":1}]},"waits":null,"shanten":-1,"terms_url":"https://ordstirr.com/agents/terms","notice":"Informational only. Review before relying on it."}}}},"400":{"description":"Invalid input (never charged)"},"402":{"description":"Payment required (x402). See the PAYMENT-REQUIRED header."},"413":{"description":"Request body too large (never charged)"}}}}}}