{"openapi":"3.1.0","info":{"title":"swap — EMC cashier","description":"USDT (TRC20) in → EMC out → signed callback.","version":"0.1.0"},"paths":{"/web/config":{"get":{"tags":["web"],"summary":"Web Config","description":"Limits/rate for the page to render (so the form matches the server).","operationId":"web_config_web_config_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebConfigResponse"}}}}}}},"/web/stats":{"get":{"tags":["web"],"summary":"Web Stats","description":"Public proof-of-reserves digest: USDT/EMC balances, order counts, 24h/7d\nactivity. Keyless and TTL-cached (no rate gate) — read-only and safe to expose.","operationId":"web_stats_web_stats_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebStatsResponse"}}}}}}},"/web/challenge":{"get":{"tags":["web"],"summary":"Web Challenge","description":"Issue a proof-of-work challenge for the next order (empty when disabled).","operationId":"web_challenge_web_challenge_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebChallengeResponse"}}}}}}},"/web/order":{"post":{"tags":["web"],"summary":"Web Create Order","description":"Public order creation: no key, rate-limited. One-way, exact amount, no\nrefunds (per the offer). The page must show the EXACT `amount_usdt` to pay.","operationId":"web_create_order_web_order_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebOrderRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebOrderResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/web/order/{token}":{"get":{"tags":["web"],"summary":"Web Order Status","description":"Poll a public order by its opaque token (no key, no id enumeration).","operationId":"web_order_status_web_order__token__get","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string","title":"Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebStatusResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/web/order/{token}/cancel":{"post":{"tags":["web"],"summary":"Web Cancel Order","description":"Let the buyer drop an unpaid order early (expire it now), freeing its\nawaiting slot ahead of the TTL. Only an `awaiting_payment` order can be\ncancelled; once a payment is in flight or settled it's too late (409). A\npayment that nonetheless arrives after cancellation matches no open order and,\nper the offer, is recorded unmatched and not refunded — same as a late payment.","operationId":"web_cancel_order_web_order__token__cancel_post","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string","title":"Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebStatusResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/healthz":{"get":{"summary":"Healthz","operationId":"healthz_healthz_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Healthz Healthz Get"}}}}}}},"/buy_emc":{"post":{"summary":"Post Buy Emc","description":"Create (or return idempotently) an order and its unique deposit address.","operationId":"post_buy_emc_buy_emc_post","parameters":[{"name":"x-api-key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BuyEmcRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BuyEmcResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/order/{order_id}":{"get":{"summary":"Get Order","operationId":"get_order_order__order_id__get","parameters":[{"name":"order_id","in":"path","required":true,"schema":{"type":"integer","title":"Order Id"}},{"name":"x-api-key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"BuyEmcRequest":{"properties":{"amount_usdt":{"type":"number","exclusiveMinimum":0.0,"title":"Amount Usdt","description":"USDT to collect (≤ cap)"},"destination_emc_address":{"type":"string","title":"Destination Emc Address","description":"where EMC is delivered"},"callback_url":{"type":"string","title":"Callback Url","description":"signed POST lands here when paid"},"ref":{"type":"string","title":"Ref","description":"caller's invoice id — idempotency key"}},"type":"object","required":["amount_usdt","destination_emc_address","callback_url","ref"],"title":"BuyEmcRequest"},"BuyEmcResponse":{"properties":{"order_id":{"type":"integer","title":"Order Id"},"deposit_address":{"type":"string","title":"Deposit Address","description":"unique TRON address to send USDT to"},"amount_usdt":{"type":"number","title":"Amount Usdt"},"emc_amount":{"type":"number","title":"Emc Amount"},"status":{"$ref":"#/components/schemas/OrderStatus"},"expires_at":{"type":"string","title":"Expires At"}},"type":"object","required":["order_id","deposit_address","amount_usdt","emc_amount","status","expires_at"],"title":"BuyEmcResponse"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"OrderResponse":{"properties":{"order_id":{"type":"integer","title":"Order Id"},"ref":{"type":"string","title":"Ref"},"status":{"$ref":"#/components/schemas/OrderStatus"},"amount_usdt":{"type":"number","title":"Amount Usdt"},"emc_amount":{"type":"number","title":"Emc Amount"},"destination_emc_address":{"type":"string","title":"Destination Emc Address"},"deposit_address":{"type":"string","title":"Deposit Address"},"emc_txid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Emc Txid"},"expires_at":{"type":"string","title":"Expires At"},"created_at":{"type":"string","title":"Created At"},"updated_at":{"type":"string","title":"Updated At"}},"type":"object","required":["order_id","ref","status","amount_usdt","emc_amount","destination_emc_address","deposit_address","expires_at","created_at","updated_at"],"title":"OrderResponse"},"OrderStatus":{"type":"string","enum":["created","awaiting_payment","confirmed","emc_delivered","notified","underpaid","overpaid","aml_hold","deliver_failed","expired"],"title":"OrderStatus"},"StatsActivity":{"properties":{"last_24h":{"$ref":"#/components/schemas/StatsWindow"},"last_7d":{"$ref":"#/components/schemas/StatsWindow"}},"type":"object","required":["last_24h","last_7d"],"title":"StatsActivity"},"StatsBalances":{"properties":{"deposit_address":{"type":"string","title":"Deposit Address"},"usdt_deposit":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Usdt Deposit"},"emc_reserve":{"anyOf":[{"$ref":"#/components/schemas/StatsEmcReserve"},{"type":"null"}]}},"type":"object","required":["deposit_address"],"title":"StatsBalances"},"StatsEmcReserve":{"properties":{"balance":{"type":"number","title":"Balance"},"outstanding":{"type":"number","title":"Outstanding"},"buffer":{"type":"number","title":"Buffer"},"available":{"type":"number","title":"Available"},"watermark":{"type":"number","title":"Watermark"},"low":{"type":"boolean","title":"Low"}},"type":"object","required":["balance","outstanding","buffer","available","watermark","low"],"title":"StatsEmcReserve"},"StatsOrders":{"properties":{"total":{"type":"integer","title":"Total"},"delivered":{"type":"integer","title":"Delivered"},"delivered_emc":{"type":"number","title":"Delivered Emc"},"by_status":{"additionalProperties":{"type":"integer"},"type":"object","title":"By Status"}},"type":"object","required":["total","delivered","delivered_emc","by_status"],"title":"StatsOrders"},"StatsWindow":{"properties":{"created":{"type":"integer","title":"Created"},"delivered":{"type":"integer","title":"Delivered"},"delivered_emc":{"type":"number","title":"Delivered Emc"}},"type":"object","required":["created","delivered","delivered_emc"],"title":"StatsWindow"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"WebChallengeResponse":{"properties":{"enabled":{"type":"boolean","title":"Enabled","description":"whether a solution is required"},"challenge":{"type":"string","title":"Challenge"},"bits":{"type":"integer","title":"Bits"}},"type":"object","required":["enabled","challenge","bits"],"title":"WebChallengeResponse"},"WebConfigResponse":{"properties":{"min_usdt":{"type":"number","title":"Min Usdt"},"max_usdt":{"type":"number","title":"Max Usdt"},"emc_per_usdt":{"type":"number","title":"Emc Per Usdt"},"support_email":{"type":"string","title":"Support Email","description":"operator contact for manual cases","default":""}},"type":"object","required":["min_usdt","max_usdt","emc_per_usdt"],"title":"WebConfigResponse"},"WebOrderRequest":{"properties":{"amount_usdt":{"type":"number","exclusiveMinimum":0.0,"title":"Amount Usdt","description":"USDT to pay (within limits)"},"destination_emc_address":{"type":"string","title":"Destination Emc Address","description":"your EMC address"},"pow_challenge":{"type":"string","title":"Pow Challenge","description":"challenge string from GET /web/challenge","default":""},"pow_solution":{"type":"string","title":"Pow Solution","description":"solved nonce for that challenge","default":""}},"type":"object","required":["amount_usdt","destination_emc_address"],"title":"WebOrderRequest"},"WebOrderResponse":{"properties":{"token":{"type":"string","title":"Token","description":"opaque handle to poll this order"},"order_id":{"type":"integer","title":"Order Id"},"deposit_address":{"type":"string","title":"Deposit Address"},"amount_usdt":{"type":"number","title":"Amount Usdt","description":"EXACT amount to send — pay this figure"},"emc_amount":{"type":"number","title":"Emc Amount"},"status":{"$ref":"#/components/schemas/OrderStatus"},"expires_at":{"type":"string","title":"Expires At"}},"type":"object","required":["token","order_id","deposit_address","amount_usdt","emc_amount","status","expires_at"],"title":"WebOrderResponse"},"WebStatsResponse":{"properties":{"generated_at":{"type":"string","title":"Generated At"},"balances":{"$ref":"#/components/schemas/StatsBalances"},"orders":{"$ref":"#/components/schemas/StatsOrders"},"activity":{"$ref":"#/components/schemas/StatsActivity"}},"type":"object","required":["generated_at","balances","orders","activity"],"title":"WebStatsResponse"},"WebStatusResponse":{"properties":{"order_id":{"type":"integer","title":"Order Id","description":"human-quotable order number (DB id)"},"status":{"$ref":"#/components/schemas/OrderStatus"},"amount_usdt":{"type":"number","title":"Amount Usdt"},"emc_amount":{"type":"number","title":"Emc Amount"},"destination_emc_address":{"type":"string","title":"Destination Emc Address"},"deposit_address":{"type":"string","title":"Deposit Address"},"emc_txid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Emc Txid"},"expires_at":{"type":"string","title":"Expires At"}},"type":"object","required":["order_id","status","amount_usdt","emc_amount","destination_emc_address","deposit_address","expires_at"],"title":"WebStatusResponse"}}}}