{"openapi":"3.1.0","info":{"title":"BetStream 3D Partner API","version":"1.0.0","summary":"Live games as content: cards, steps and results of every round, signed webhooks, and the players to embed.","description":"For partners that take their own bets on 3D Sabong, 3DKarera Live and 3DRoulette Live, or show them. Guide: https://3dsabong.com/docs/api.\n\n**Signing.** Every request carries `X-Operator-Id`, `X-Timestamp` (unix seconds, within 300 s of ours) and `X-Signature` = hex(HMAC-SHA256(secret, \"<timestamp>.<METHOD>.<path with query>.<body as sent>\")). Webhooks we send are signed the same way with the same secret.\n\n**Results are told only when a round is over.** `seed` and `result` are null until `status` is `settled`. A round under way is `running`, and nothing about it says how it will end.\n\n**Compatibility.** Within v1 nothing is removed or changes meaning: fields and enum values are only ever added. Ignore what you do not know. A breaking change is a new version (/partner/v2), and v1 stays for at least 6 months after it is announced.","contact":{"name":"BetStream 3D","url":"https://betstream3d.com/contact"}},"servers":[{"url":"https://3dsabong.com"}],"security":[{"operatorId":[],"timestamp":[],"signature":[]}],"tags":[{"name":"Games"},{"name":"Rounds"},{"name":"Events"},{"name":"Webhooks"}],"paths":{"/partner/v1/games":{"get":{"tags":["Games"],"operationId":"listGames","summary":"The games this partner may use, with the player to embed for each","responses":{"200":{"description":"The games","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GameList"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/partner/v1/games/{game}/live":{"get":{"tags":["Rounds"],"operationId":"liveRound","summary":"The round on now","parameters":[{"name":"game","in":"path","required":true,"schema":{"type":"string","enum":["sabong","karera","roulette"]}}],"responses":{"200":{"description":"The round on now, if any","content":{"application/json":{"schema":{"type":"object","required":["now","round"],"properties":{"now":{"type":"string","format":"date-time"},"round":{"oneOf":[{"$ref":"#/components/schemas/Round"},{"type":"null"}]}}}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/partner/v1/games/{game}/rounds":{"get":{"tags":["Rounds"],"operationId":"finishedRounds","summary":"Finished rounds (settled or void), oldest first, after a round number","parameters":[{"name":"game","in":"path","required":true,"schema":{"type":"string","enum":["sabong","karera","roulette"]}},{"name":"after","in":"query","schema":{"type":"integer","minimum":0,"default":0},"description":"Rounds numbered above this"},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":500,"default":100}}],"responses":{"200":{"description":"A page of rounds","content":{"application/json":{"schema":{"type":"object","required":["rounds","next"],"properties":{"rounds":{"type":"array","items":{"$ref":"#/components/schemas/Round"}},"next":{"oneOf":[{"type":"integer","description":"Pass as `after` for the next page; null when there is none"},{"type":"null"}]}}}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/partner/v1/games/{game}/rounds/{round}":{"get":{"tags":["Rounds"],"operationId":"getRound","summary":"One round, as it stands","parameters":[{"name":"game","in":"path","required":true,"schema":{"type":"string","enum":["sabong","karera","roulette"]}},{"name":"round","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"The round","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Round"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/partner/v1/games/karera/schedule":{"get":{"tags":["Rounds"],"operationId":"kareraSchedule","summary":"The race on now and the races after it, with their fields and the going","parameters":[{"name":"count","in":"query","schema":{"type":"integer","minimum":1,"maximum":40,"default":12}}],"responses":{"200":{"description":"The timetable","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/partner/v1/events":{"get":{"tags":["Events"],"operationId":"listEvents","summary":"Every step of every round, in order, after an event id: the same events the webhook sends","parameters":[{"name":"after","in":"query","schema":{"type":"integer","minimum":0,"default":0},"description":"Events numbered above this. Keep the last id you have processed and pass it here"},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":500,"default":100}},{"name":"game","in":"query","schema":{"type":"string","enum":["sabong","karera","roulette"]}}],"responses":{"200":{"description":"A page of events","content":{"application/json":{"schema":{"type":"object","required":["events","next","last"],"properties":{"events":{"type":"array","items":{"$ref":"#/components/schemas/Event"}},"next":{"type":"integer","description":"Pass as `after` for the next page"},"last":{"type":"integer","description":"The newest event there is"}}}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/partner/v1/webhooks":{"get":{"tags":["Webhooks"],"operationId":"webhookStatus","summary":"The webhook address and the latest deliveries to it","responses":{"200":{"description":"Status","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}},"post":{"tags":["Webhooks"],"operationId":"setWebhook","summary":"Set (or, with null, remove) the address events are sent to","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"oneOf":[{"type":"string","format":"uri","description":"https"},{"type":"null"}]}}}}}},"responses":{"200":{"description":"Saved","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},"/partner/v1/webhooks/test":{"post":{"tags":["Webhooks"],"operationId":"testWebhook","summary":"Send a `ping` event to the webhook now and report the answer","responses":{"200":{"description":"What happened","content":{"application/json":{"schema":{"type":"object","properties":{"delivered":{"type":"boolean"},"status":{"oneOf":[{"type":"integer"},{"type":"null"}]},"error":{"oneOf":[{"type":"string"},{"type":"null"}]}}}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}}},"webhooks":{"event":{"post":{"summary":"An event: POSTed to the partner's webhook address, signed. Answer 2xx; anything else is retried (5 s, 15 s, 1 min, 5 min, then every 10 min, for 24 h). Events go one at a time, in order. The same id may come twice: process it once.","parameters":[{"name":"X-Event-Id","in":"header","schema":{"type":"string"}},{"name":"X-Event-Type","in":"header","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Received"}}}}},"components":{"securitySchemes":{"operatorId":{"type":"apiKey","in":"header","name":"X-Operator-Id"},"timestamp":{"type":"apiKey","in":"header","name":"X-Timestamp","description":"Unix seconds"},"signature":{"type":"apiKey","in":"header","name":"X-Signature","description":"hex(HMAC-SHA256(secret, \"<timestamp>.<METHOD>.<path with query>.<body as sent>\"))"}},"responses":{"Error":{"description":"An error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","examples":["INVALID_SIGNATURE","OPERATOR_DISABLED","GAME_NOT_FOUND","ROUND_NOT_FOUND","INVALID_REQUEST","RATE_LIMITED"]},"message":{"type":"string"}}}}}}}}},"schemas":{"GameList":{"type":"object","required":["version","games","statuses","events"],"properties":{"version":{"type":"string"},"statuses":{"type":"array","items":{"type":"string"}},"events":{"type":"array","items":{"type":"string"}},"games":{"type":"array","items":{"type":"object","required":["id","name","embedUrl"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"embedUrl":{"type":"string","format":"uri","description":"Put it in an iframe with allow=\"autoplay; fullscreen\""},"cycleMs":{"oneOf":[{"type":"integer","description":"Time from one round to the next, where it is fixed"},{"type":"null"}]}}}}}},"Round":{"type":"object","required":["game","round","status","seal","seed","result"],"properties":{"game":{"type":"string","enum":["sabong","karera","roulette"]},"round":{"type":"integer","description":"Fight, race or spin number"},"status":{"type":"string","enum":["open","closed","running","settled","void"],"description":"open: bets may be taken. closed: no more bets. running: under way. settled: over, with its result. void: no result; return every bet"},"opensAt":{"oneOf":[{"type":"string","format":"date-time"},{"type":"null"}]},"closesAt":{"oneOf":[{"type":"string","format":"date-time"},{"type":"null"}]},"startsAt":{"oneOf":[{"type":"string","format":"date-time"},{"type":"null"}]},"resultAt":{"oneOf":[{"type":"string","format":"date-time"},{"type":"null"}]},"seal":{"oneOf":[{"type":"string","description":"SHA-256 commitment to the seed, published when the round opens"},{"type":"null"}]},"seed":{"oneOf":[{"type":"string","description":"Revealed when the round is settled; it opens the seal and gives the result"},{"type":"null"}]},"card":{"type":"object","description":"What is on offer. sabong: meron, wala, odds. karera: going, distance, runners [{n, horseId, name, rating}]. roulette: wheel, pockets"},"result":{"oneOf":[{"type":"object","description":"sabong: {winner: MERON|WALA|DRAW}. karera: {winner, order}. roulette: {number, colour}"},{"type":"null"}]},"voidReason":{"oneOf":[{"type":"string"},{"type":"null"}]}}},"Event":{"type":"object","required":["id","type","game","round","at","data"],"properties":{"id":{"type":"integer","description":"Increases by event; the cursor for GET /partner/v1/events"},"type":{"type":"string","enum":["round.opened","round.closed","round.started","round.settled","round.voided","ping"]},"game":{"oneOf":[{"type":"string"},{"type":"null"}]},"round":{"oneOf":[{"type":"integer"},{"type":"null"}]},"at":{"type":"string","format":"date-time"},"data":{"$ref":"#/components/schemas/Round"}}}}}}