Copy in Pool
Overview
The Copy In Pool mode is an extension of the CopyStake product. In this mode, users copy the streamer's bets by contributing funds to a shared pool. The size of their win or loss is proportional to their share of the pool. All actions are processed via the streamer's balance on the operator's side.
This document defines the API contract required for operators to integrate the Copy In Pool functionality.
API Access:
all requests from CopyStake to Operator contain
X-API-KEY
with value issued by Operator;all requests from Operator to CopyStake contain
X-API-KEY
with value issued by CopyStake;
Signature:
all requests from CopyStake must be signed by CopyStake and verified by Operator;
all requests from Operator must be signed by Operator and verified by CopyStake;
secretKey for signing the payload in both cases is issued by CopyStake
the signature will be placed in the
X-REQUEST-SIGNATURE
header of each request and uses Base64(HmacSHA512(SecretKey, MD5(request body)))dealing with
X-REQUEST-SIGNATURE
Callback URL:
callback_url
- provided by Operator, e.g.callback_url=https://integration.operator.com/api/v1/copystake
IMPORTANT:
Operators need to whitelist the Trueplay IPs to receive callbacks about the status of transactions. Otherwise, Trueplay will return errors for deposit/withdrawal tokens requests.
Validation rules:
Operator side:
to prevent fraud and loss of funds by the follower, Operator should ensure control over the withdrawal of funds from the streamer’s balance on the operator’s site to streamer’s personal account (out of operator’s site);
CopyStake side:
to ensure the correct execution of operations, CopyStake should perform transfer operations only for users identified in the CopyStake system as streamers
Transfer operation
OPERATOR
type = DEPOSIT only under the condition of a successfully executed BET transaction on the follower’s account, i.e., the action when the follower joined the pool;
type = WITHDRAWAL under the condition that the follower decided to leave the pool (or the stream ended, or other scenarios). This operation must be completed with a WIN transaction on the follower’s account.
Performing deposit/withdraw operations concerning the streamer’s balance. This method can be invoked:
POST
{callback_url}/transfer
Headers
Content-Type: application/json
X-API-KEY: value issued by Operator
X-REQUEST-SIGNATURE: value generated based on the request payload (secret key issued by CopyStake)
Request
Field
Type
Require
Description
userId
String
mandatory
user identifier in the operator system
currency
String
optional
currency ISO 4217
field is present, return the account balance information in the specified currency
field is absent, return the account balance information with which the game was launched (not a balance inside the game)
field is absent and there is no active game session - throw ERR_OPEN_SESSION_NOT_FOUND
Response success
Field
Type
Require
Description
balance
Double
mandatory
rounding to 8 decimal places
current available user’s balance
currency
String
mandatory
currency ISO 4217
Response error
HTTP 400 Bad Request
Field
Type
Require
Description
errorCode
String
mandatory
ERR_UNKNOWN
General error status, for cases without a special error code
ERR_TRANSFER_FORBIDDEN
Any conditions under which the user is prohibited for deposit/withdraw operations
ERR_INSUFFICIENT_BALANCE
Insufficient streamer balance
ERR_INVALID_USER
User does not exist
ERR_OPEN_SESSION_NOT_FOUND
User session not found
errorMessage
String
optional
more detailed description of the errorRequest example
Response example
200 OK
{
"balance": 805.00000000,
"currency": "USD",
}
Get balance (Copy In Pool mode)
This API method allows operators to retrieve the current balance of the streamer before join the pool.
POST
{callback_url}/streamer-balance
Headers
Content-Type: application/json
X-API-KEY: value issued by CopyStake
Request
Field
Type
Require
Description
language
String
optional
User's UI language code from the permitted set in the backoffice (ISO 639)
streamId
String
optional
User identifier for active stream. If present, followers are directed to the Broadcast page, skipping the Lobby
Response success
Field
Type
Require
Description
url
String
mandatory
CopyStake url with auth token
Response error HTTP
400 Bad Request
Field
Type
Require
Description
errorCode
String
mandatory
ERR_UNKNOWN General error status, for cases without a special error code.
ERR_COPYSTAKE_OFF CopyStake is disabled
errorMessage
String
optional
more detailed description of the error
Response example
200 OK
{
"url": "https://copystake.trueplay.io?token=eyJhbGciOiJIUzUxMiJ9.eyJpZF9vcGVyYXRvciI6”
}
Game Pool state
Send information to the Operator that the streamer's balance is the Game Pool.
It could be OPEN before the first follower decides to join the pool or CLOSED when the last follower leaves the pool. Based on the information about state, Operator able to create internal rules to forbidden some operator actions (withdrawal of funds from the streamer’s balance on the operator’s site to streamer’s personal account, token exchanges and other that can impact on streamer’s balance)
POST
{callback_url}/game-pool
Headers
Content-Type: application/json
X-API-KEY: value issued by CopyStake
Request
Field
Type
Require
Description
userId
String
mandatory
User identifier in the operator system
state
String
mandatory
OPEN - first follower decides to join the pool
CLOSE - last follower leaves the pool
200 OK
Last updated