{"openapi":"3.1.0","info":{"title":"Vancouver Prediction Exchange API","version":"1","description":"Trade YES/NO prediction markets on VPX. Prices are in cents (1-99) and a winning share pays 100. All trading uses play money."},"servers":[{"url":"https://www.vancouverpx.ca/api/v1"}],"security":[{"bearerAuth":[]}],"externalDocs":{"url":"https://www.vancouverpx.ca/docs/api"},"paths":{"/markets":{"get":{"summary":"List markets","operationId":"getMarkets","externalDocs":{"url":"https://www.vancouverpx.ca/docs/api/get-markets"},"parameters":[{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/MarketStatus"}}],"responses":{"200":{"description":"Markets, newest first","content":{"application/json":{"schema":{"type":"object","properties":{"markets":{"type":"array","items":{"$ref":"#/components/schemas/Market"}}}}}}},"401":{"$ref":"#/components/responses/Error"}}}},"/market":{"get":{"summary":"Get a market","operationId":"getMarket","externalDocs":{"url":"https://www.vancouverpx.ca/docs/api/get-market"},"parameters":[{"name":"marketId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"201":{"description":"The market","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}},"/market/order-book":{"get":{"summary":"Get a market's order book, seen from each outcome","operationId":"getOrderBook","externalDocs":{"url":"https://www.vancouverpx.ca/docs/api/get-order-book"},"parameters":[{"name":"marketId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Top 10 levels per side","content":{"application/json":{"schema":{"type":"object","properties":{"orderBookYes":{"$ref":"#/components/schemas/OrderBook"},"orderBookNo":{"$ref":"#/components/schemas/OrderBook"}}}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"}}}},"/market/trades":{"get":{"summary":"Get a market's recent trades","operationId":"getTrades","externalDocs":{"url":"https://www.vancouverpx.ca/docs/api/get-trades"},"parameters":[{"name":"marketId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Recent trades","content":{"application/json":{"schema":{"type":"array"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"}}}},"/order":{"post":{"summary":"Place a limit order (good till cancelled)","operationId":"placeOrder","externalDocs":{"url":"https://www.vancouverpx.ca/docs/api/place-order"},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["marketId","side","outcome","price","quantity"],"properties":{"marketId":{"type":"string"},"side":{"type":"string","enum":["BUY","SELL"]},"outcome":{"type":"string","enum":["YES","NO"]},"price":{"type":"number","minimum":1,"maximum":99},"quantity":{"type":"number","exclusiveMinimum":0}}}}}},"responses":{"201":{"description":"The order, possibly already (partly) filled","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"}}}},"/positions":{"get":{"summary":"List your open positions","operationId":"getPositions","externalDocs":{"url":"https://www.vancouverpx.ca/docs/api/get-positions"},"responses":{"200":{"description":"Holdings with a positive quantity","content":{"application/json":{"schema":{"type":"object","properties":{"positions":{"type":"array","items":{"$ref":"#/components/schemas/Position"}}}}}}},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}},"/cancel-order":{"post":{"summary":"Cancel one of your open orders","operationId":"cancelOrder","externalDocs":{"url":"https://www.vancouverpx.ca/docs/api/cancel-order"},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["orderId"],"properties":{"orderId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"The cancelled order","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}},"/cancel-everything":{"post":{"summary":"Cancel all of your open orders","operationId":"cancelAllOrders","externalDocs":{"url":"https://www.vancouverpx.ca/docs/api/cancel-all-orders"},"responses":{"200":{"description":"The cancelled orders","content":{"application/json":{"schema":{"type":"array"}}}},"401":{"$ref":"#/components/responses/Error"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"API key from the Developer Settings page"}},"responses":{"Error":{"description":"Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"object"}}}}}}},"schemas":{"MarketStatus":{"type":"string","enum":["OPEN","CLOSED","RESOLVED","CANCELED"]},"Market":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":["string","null"]},"question":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"status":{"$ref":"#/components/schemas/MarketStatus"},"closesAt":{"type":["string","null"],"format":"date-time"},"resolvesAt":{"type":["string","null"],"format":"date-time"},"resolved":{"type":"boolean"},"labelA":{"type":"string"},"labelB":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"OrderBook":{"type":"object","properties":{"bids":{"type":"array","items":{"$ref":"#/components/schemas/Level"}},"asks":{"type":"array","items":{"$ref":"#/components/schemas/Level"}},"lastTradePrice":{"type":["number","null"]}}},"Level":{"type":"object","properties":{"price":{"type":"number"},"quantity":{"type":"number"},"total":{"type":"number","description":"Cumulative quantity"}}},"Position":{"type":"object","properties":{"id":{"type":"string"},"marketId":{"type":"string"},"marketQuestion":{"type":"string"},"marketStatus":{"$ref":"#/components/schemas/MarketStatus"},"outcome":{"type":"string","enum":["YES","NO"]},"quantity":{"type":"number"},"lockedQuantity":{"type":"number"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}}}}}