# DeBets Seamless Server API

This section describes the structure of the Seamless API provided by DeBets Seamless Server.

If you choose to request DeBets to provide Seamless API that match a specific format that you already support you should skip this page and read these requirements.

If you are willing to integrate DeBets Seamless Server API go on reading this page.

# Format of the seamless requests

Seamless requests are HTTP GET requests that must be sent to the follwing endpoint:

https://seamless.debets.io/

An action path must be added to the URL above to specify the requested Seamless operation. For instance, for a debit request the following URL must be called:

https://seamless.debets.io/debit

All other parameters must be specified as querystring parameters.

# Staging environment

For testing you should use DeBets stating environment. This environment uses testnet blockchains and allows you to play the games with testnet cryptos. To use the staging environment simply change the seamless subdomain into seamless-test:

https://seamless-test.debets.io/debit

# Format of the seamless response

The response has a JSON body that contains a result code which can be one of the following values:

Result Code description
200 OK, operation is successful
403 not enough funds (debit request only)
500 internal error

Successful requests always return the player balance in the response:

{
    status: 200,
    balance: 10.50
}

When the player has connected his Wallet to DeBets ClientApp each Seamless response also returns the Wallet address:

{
    status: 200,
    balance: 10.50,
    address: "0xBC6093df29aa04599b8A7889DEd89bc7fdF545b5",
    depositId: "0x432f3c1c247f91b39e3fdd92f5114c634f963a9d3d52863ebe75c435587f2fc8"  
}

# External parameters

In the description of the seamless requests that will follow game ID, session ID, round ID and transaction ID are external identifiers that represent the game, the game session, the game round and transaction in your game server or gaming platform. They are not controlled by DeBets and they will be used by DeBets in the same format and value as they are provided.

# Authentication mechanism

Requests must comply to a simple authentication mechanism that is based on a salt which is used to hash the content of the querystring parameters with a secret word prepended to it. This secret word is known by both parties only (caller of the API and DeBets Seamless Server), thus being able to reproduce the hash using the secret word allows the receiving party to identify the caller.

The hash must be computed with the SHA-1 hashing function and must be added to the URL of every request as the last querystring parameter called key.

Consider the following example where the secret word used to compute the hash is SECRET:

https://seamless.debets.io/getBalance?accountId=5&sessionId=TK384848&gameId=21&key=eb0413e0a96697a82a14dd41adeff38c4dd7519a

In the above call the value for key is:

eb0413e0a96697a82a14dd41adeff38c4dd7519a

And this is the SHA-1 of all other querystring parameters with the word SECRET prepended:

SECRETaccountId=5&sessionId=TK384848&gameId=21

In all Seamless calls that will be described the key querystring parameter used to authenticate requests will be omitted from the list of parameters involved in the call.

# GetBalance request

This request is called by the game server or gaming platform to get the balance of the player.

Gets the player balance

Parameter type required description
accountId integer ID of the gaming account
sessionId string ID of the game session
gameId string ID of the game

Example response:

{
    status: 200,
    balance: 10.50,
    address: "0xBC6093df29aa04599b8A7889DEd89bc7fdF545b5",
    depositId: "0x432f3c1c247f91b39e3fdd92f5114c634f963a9d3d52863ebe75c435587f2fc8" 
}

# Debit request

This request is called by the game server or the gaming platform to deduct the bet from the player balance anytime a new round starts.

Deducts the amount bet from the player balance

Parameter type required description
accountId integer ID of the gaming account
sessionId string ID of the game session
gameId string ID of the game
amount number bet amount
transactionId string ID of the transaction
roundId string ID of the round

Example response:

{
    status: 200,
    balance: 10.50,
    address: "0xBC6093df29aa04599b8A7889DEd89bc7fdF545b5",
    depositId: "0x432f3c1c247f91b39e3fdd92f5114c634f963a9d3d52863ebe75c435587f2fc8" 
}

Example response with Provably Fair:

{
    status: 200,
    seed: 978001236
    balance: 10.50,
    address: "0xBC6093df29aa04599b8A7889DEd89bc7fdF545b5",
    depositId: "0x432f3c1c247f91b39e3fdd92f5114c634f963a9d3d52863ebe75c435587f2fc8" 
}

# Credit request

This request is called by the game server or gaming platform to add the win to the player balance at the end of a round.

Adds the amount won to the player balance

Parameter type required description
accountId integer ID of the gaming account
sessionId string ID of the game session
gameId string ID of the game
amount number win amount
transactionId string ID of the transaction
roundId string ID of the round

Example response:

{
    status: 200,
    balance: 10.50,
    address: "0xBC6093df29aa04599b8A7889DEd89bc7fdF545b5",
    depositId: "0x432f3c1c247f91b39e3fdd92f5114c634f963a9d3d52863ebe75c435587f2fc8" 
}