TVBET API documentation 1.2.0

General interaction layout

  1. Iframe-client of the game sends requests to the TvBet game server.
  2. The TvBet server interacts with API partner for conducting money transactions and other actions.

Iframe integration

To integrate the game client into the iframe at the partner site, you need to connect the following script on the page:

https://<tvbetframe>/assets/frame.js

An example code for initialization:

new TvbetFrame({
  'lng'        : 'en',
  'clientId'   : '35',
  'tokenAuth'  : '<token>',
  'server'     : 'https://<tvbetframe>',
  'floatTop'   : '#fTop',
  'containerId': 'tvbet-game',
  'game_id'    : 8
  }); 

Parameters and default values:

var params = {
    'lng'        : 'en',  // language, English by default
    'tokenAuth'  : false, // token authorization
    'clientId'   : false, // client id
    'server'     : false, // url of TVBet server
    'containerId': 'tvbet-game', // id of the container element which will be inserted in the iframe
    'singleGame' : false, // disables the menu and launches a specific game by id
    'game_id'    : false, // starts a specific game by id (it takes priority over the singleGame)
    'page'       : false, // when you start go to the page
    'nosoon'     : false, // disable games marked "Soon".
    'floatTop'   : false, // floating element selector (if the site has a floating menu)
    'pinned'     : false, // open game in pinned mode
    'exitUrl'    : false, // the URL for exiting the game, it is only displayed in the mobile version (it takes priority over the same setting in the admin panel)  
    'gameAuth'   : null, // URL or global js function. If set, when an unauthorized user tries to click "Place a Bet", he will be redirected to the specified address or the specified function will be called.
    'scrollContainer': false, // If you use "overflow: scroll" on something element over iframe, you need set css selector of this element to parameter "scrollContainer", else set it "false"
}

An example code for integration using the bootloader:

<script type="text/javascript" src="https://tvbetframe999.com/assets/frame.js"></script>
<script>
  (function () {
    new TvbetFrame({
      'lng'        : 'en',
      'clientId'   : '9999',
      'tokenAuth'  : '8fgi340g3oif039efj3jef039ejfoerjg',
      'server'     : 'https://tvbetframe999.com',
      'floatTop'   : '#fTop',
      'containerId': 'tvbet-game',
    });
  })();
</script>

If for some reason the tvbetframe loader code is not suitable for your page, you can connect the jframe by the link and register all the necessary event handlers via javascript.

The tokens system

On the partner server generate an alphanumeric string, its called a token. Each user must correspond to 2 tokens. The first is the authentication token, which is substituted into the iframe address as the tokenAuth parameter.
It is used to request authentication, get user data and get 2nd token. The second is the interaction token, which is used for other operations.

Tokens must satisfy the following requirements:

  1. Contain letters and numbers.
  2. Be 10 to 100 symbols long.
  3. Be unique to each user.
  4. Have a limited timeline (60 minutes).

:information_source: We recommend you to update the lifetime of the token if API request is successful.

Security check

All requests and responses between TvBet and partner servers must contain the time of formation (ti) and signature (si). JSON is the format used for requests and responses.

Parameter “ti” (time)

It is equal to the number of seconds when the request or response was made, since UNIX Epoch.

:information_source: For all queries which were described below the “ti” parameter is the number of seconds which begins from Unix Epoch (January 1 1970 00:00:00 GMT)

An example of getting current time:

// PHP
time();
// C#
(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

If the difference between the value of the “ti” parameter that came in the request from TvBet to the partner server exceeds the current time value by 3 seconds it means the data is considered irrelevant and an error response should be returned.

If the difference between the value of the “ti” parameter, which came in the response from the partner server to TvBet, exceeds the current time value by 3 seconds it means the data is not considered relevant and an error will be displayed.

An example of a query with “ti” parameter:

{
    "ti": 1516176813,
    "si": "IS1cJRqj1FryTWWDhFpFVw==",
    "to": "ab9984617a6ec835844bacbd47bfb59c"
}

An example of a response with “ti” parameter:

{
    "ti": 1516176823,
    "si": "E4HzbczCO0Biv9X7YgajxQ==",
    "sc": true,
    "cd": 0,
    "er": "",
    "val": {
        "uid": "29578409",
        "cc": "RUB",
        "to": "4c3b69185558977ce3e2bf1fae29b015",
        "ts": true
    }
}

:information_source: This is done so that the bets of test accounts do not fall into the general statistics ts = true. For real accounts ts = false.

An example of a response with an error:

{
    "ti": 1516176823,
    "si": "h1d/EC2o+jqa45p+tAnYIA==",
    "sc": false,
    "cd": 2,
    "er": "The request time exceeds 3 seconds",
    "val": null
}

Parameter “si” (signature)

The signature is the base64 MD5 converted hash of the concatenation of the request and the private key.

:information_source: Each partner has their own private key.

Let’s consider step-by-step the creation of “si” signature. As an example we can use the following query:

{
    "ti": 1520430024,
    "to": "c41d77361ffe32b0fdaf04d59377d436",
    "bid": 228784,
    "tt": 1,
    "sm": "2.3"
}
  1. We should convert the query into a JSON string (obviously, the order of parameters in the query is important and it must match this example).

{"ti":1520430024,"to":"c41d77361ffe32b0fdaf04d59377d436","bid":228784,"tt":1,"sm":"2.3"}

  1. Then we must concatenate the JSON string received and the private key.

{"ti":1520430024,"to":"c41d77361ffe32b0fdaf04d59377d436","bid":228784,"tt":1,"sm":"2.3"}faas3c1e3a3c8ae56r8g845e0ba2tb3ccv

  1. We calculate MD5 hash of the received string.

402a171664ee5d37823c5c98a23c6a56

  1. We must convert hash (bytes, not a line) in base64 string.

QCoXFmTuXTeCPFyYojxqVg==

Example of the code that forms the signature:

// PHP
$md5_hex_string = md5($json_string . $secret_key);
$sign = base64_encode(hex2bin($md5_hex_string));
// C#
var stringBytes = Encoding.UTF8.GetBytes(jsonString + secretKey);
using (MD5 md5Hash = MD5.Create())
{
    var md5BytesArray = md5Hash.ComputeHash(stringBytes);
    var sign = Convert.ToBase64String(md5BytesArray);
}
  1. Form the request with the received signature.
{
    "ti": 1520430024,
    "si": "QCoXFmTuXTeCPFyYojxqVg=="
    "to": "c41d77361ffe32b0fdaf04d59377d436",
    "bid": 228784,
    "tt": 1,
    "sm": "2.3"
}

It is obvious that the verification of this request is carried out in the same way with previously deleted “si” paramerter.

An example of response with an error:

{
    "ti": 1520430028,
    "si": "efNxQarWtkW21sqn4/7o5g==",
    "sc": false,
    "cd": 5,
    "er": "The signature of request is wrong",
    "val": null
}

:information_source: Use the service cryptii.com (or similar service ) with a chain of blocks: Text - > Hash function (MD5) - > Base64 (Standart) - > Text to test the algorithm.

API of a partner

The TvBet server communicates with the API of a partner through HttpWebRequest that calls the methods described below. These methods should be implemented by the partner. The methods must be available from the following url pattern:

https://partners_api_url/method_name

GetUserData

Authentication and getting user data.

POST https://partners_api_url/GetUserData

Use the https protocol (port 443)

A query example :

{
    "ti": 1516176813,
    "si": "IS1cJRqj1FVyTWWDhFpFVw==",
    "to": "ab9984617a6ec835844bacbd47bfb59c",
    "ed": 102
}

A response example:

{
    "ti": 1516176823,
    "si": "H5CNHpawgp5ET2mpYtpRBg==",
    "sc": true,
    "cd": 0,
    "er": "",
    "val": {
        "uid": "29578409",
        "cc": "RUB",
        "to": "4c3b69185558977ce3e2bf1fae29b015",
        "ts": false,
        "bl": "4059.85"
    }
}

:fire: The parameter ts is stored on the server TvBet at the time of the first bet and in the future, requests with a different parameter value are considered to be erroneous. The user must have an unchanged test sign!

The maximum length of the partner’s user id (uid) is 255 characters

:information_source: There is a currency code manual in the supplement.

An example of response with an error:

{
    "ti": 1516176823,
    "si": "RzG/dB0CGNsLXSQgSjfsGw==",
    "sc": false,
    "cd": 5,
    "er": "The token not valid or no longer valid",
    "val": null
}

Error codes “cd”:

RefreshToken

Extension of the life of the token or getting a new one.

POST https://partners_api_url/RefreshToken

A query example:

{
    "ti": 1516176813,
    "si": "IS1cJRqj1FVyTWWDhFpFVw==",
    "to": "ab9984617a6ec835844bacbd47bfb59c",
    "ed": 102
}

A response example:

{
    "ti": 1516176823,
    "si": "H5CNHpawgp5ET2mpYtpRBg==",
    "sc": true,
    "cd": 0,
    "er": "",
    "val": {
        "to": "ab9984617a6ec835844bacbd47bfb59c"
    }
}

:information_source: If the lifetime of the token has not expired, that is transferred in the request, then you need to update its lifetime and return it in the reply. If the token is outdated, then new tokens should be generated for the user, and in the response, return the authentication token.

Error codes “cd”:

MakePayment

Execution of payment transactions.

POST https://partners_api_url/MakePayment

An example of request:

{
    "ti": 1516177630,
    "si": "nwCzFGY0OVDpp1wwxE3E/Q==",
    "to": "4c3b69185558977ce3e2bf1fae29b015",
    "bid": 228784,
    "tt": -1,
    "sm": "20"
}

“tt” transaction types:

An example of response:

{
    "ti": 1516177634,
    "si": "ZFtAaMH3TeuVdIvF3D5VQA==",
    "sc": true,
    "cd": 0,
    "er": "",
    "val": {
        "tid": "147035",
        "dt": 1515749778,
    }
}

An example of response with an error:

{
    "ti": 1516177634,
    "si": "nvUm3kpTe13YBQsmQQHvug==",
    "sc": false,
    "cd": 8,
    "er": "There are not enough funds on the user's balance",
    "val": null
}

Error codes “cd”:

:warning: In case of an error “Transaction already exists” (code 12) in the response field “val” it is necessary to transfer the id of that transaction

{
    "ti": 1516177634,
    "si": "nvUm3kpTe13YBQsmQQHvug==",
    "sc": false,
    "cd": 12,
    "er": "Transaction already exists",
    "val": {
        "tid": "147035"
    }
}

GetPaymentInfo

Getting information about the payment transaction.

POST https://partners_api_url/GetPaymentInfo

A query example:

{
    "ti": 1516181924,
    "si": "DkahadATh0b3VlP96GAQyA==",
    "tid": "147121",
    "to": "4c3b69185558977ce3e2bf1fae29b015"
}

A response exаmple:

{
    "ti": 1516181928,
    "si": "SQfMJ+sLo89DSBy45UCkVA==",
    "sc": true,
    "cd": 0,
    "er": "",
    "val": {
        "dt": 1520499223,
        "bid": 228987,
        "tt": -1,
        "uid": "29579409",
        "sm": "11"
    }
}

An error response example:

{
    "ti": 1516181928,
    "si": "G48jxamvRvNJQLV+Gyn1Yg==",
    "sc": false,
    "cd": 14,
    "er": "Transaction not found",
    "val": null
}

Error codes “cd”:

GetPromoInfo

Obtaining coupon characteristics to activate a promo code when accepting a bet on it.

:information_source: Work general scheme is that partner on his side generates and distributes promotional codes to users. On the product page, during formation of the coupon, user can specify promotional code which he got. The coupon will be checked for compliance with the conditions set by the partner while accepting the bet ( GetPromoInfo ). According to the results of the test will be generated the response and sent to the pr field of the MakePayment method.

POST https://partners_api_url/GetPromoInfo

Request example:

{
    "ti": 1516181924,
    "si": "DkahadATh0b3VlP96GAQyA==",
    "pr": "qwerty123",
    "to": "4c3b69185558977ce3e2bf1fae29b015"
}

Response example:

{
    "ti": 1516181928,
    "si": "SQfMJ+sLo89DSBy45UCkVA==",
    "sc": true,
    "cd": 0,
    "er": "",
    "val": {
        "am": "700",
        "mc": "3.5",
        "gts": [2,3],
        "bt": 1,
        "ec": 2,
        "gtl": [
            {
                "gt": 2,
                "c": 3
            },
            {
                "gt": 3,
                "c": 3
            }
        ]
    }
}

Example of an answer with an error:

{
    "ti": 1516181928,
    "si": "G48jxamvRvNJQLV+Gyn1Yg==",
    "sc": false,
    "cd": 19,
    "er": "The promotional code has already been used",
    "val": null
}

Error codes “cd”:

CloseBet

Sending bet closed flag

:information_source: This method passes information about closing a bet: bet id and a flag (open, closed). A closed bet means that transactions (MakePayment requests) will no longer be received at this bet. If the bet is open, then sending transactions is allowed.

If the bet has already been closed and a CloseBet request with the open flag has arrived, then the transaction wire becomes allowed for the bet again, for example, if a payout cancellation is required (tt=-2). Upon completion of all necessary transactions, a request with the closed flag will be sent again.

POST https://partners_api_url/CloseBet

Request example:

{
    "ti": 1516181924,
    "si": "DkahadATh0b3VlP96GAQyA==",
    "to": "4c3b69185558977ce3e2bf1fae29b015",
    "bid": 228784,
    "c": true
}

Response example:

{
    "ti": 1516181928,
    "si": "SQfMJ+sLo89DSBy45UCkVA==",
    "sc": true,
    "cd": 0,
    "er": ""
}

An error response example:

{
    "ti": 1516181928,
    "si": "G48jxamvRvNJQLV+Gyn1Yg==",
    "sc": false,
    "cd": 2,
    "er": "Request timeout exceeded"
}

Error Codes “cd”:

MakeCashbackPayment

Execution of a cashback transaction

POST https://partners_api_url/MakeCashbackPayment

Request example:

{
    "ti": 1516177630,
    "si": "nwCzFGY0OVDpp1wwxE3E/Q==",
    "to": "4c3b69185558977ce3e2bf1fae29b015",
    "cid": 480,
    "ctt": 1,
    "am": "180",
    "tax": "20"
}

“tt” transaction types:

Response example:

{
    "ti": 1516177634,
    "si": "ZFtAaMH3TeuVdIvF3D5VQA==",
    "sc": true,
    "cd": 0,
    "er": "",
    "val": {
        "tid": "147035",
        "dt": 1515749778,
    }
}

An error response example:

{
    "ti": 1516177634,
    "si": "nvUm3kpTe13YBQsmQQHvug==",
    "sc": false,
    "cd": 3,
    "er": "User not found",
    "val": null
}

Error Codes “cd”:

:warning: In case of an error “Transaction already exists” (code 12) in the response field “val” it is necessary to transfer tid and dt

{
    "ti": 1516177634,
    "si": "nvUm3kpTe13YBQsmQQHvug==",
    "sc": false,
    "cd": 12,
    "er": "Transaction already exists",
    "val": {
        "tid": "147035",
        "dt": 1515749778,
    }
}

An addition

Language code list:

Code Name
AL Albanian
AR Arab
AZ Azerbaijani
BG Bulgarian
BR Brazilian
BS Bosnian
CN Chinese
DE Deutsch
EN English
ES Spanish
FA Persian
FR French
HE Hebrew
HI Hindi
HR Croatian
HT Creole
HY Armenian
IT Italian
JA Japanese
KA Georgian
KO Korean
KZ Kazakh
PL Polish
PT Portuguese
RU Russian
SR Serbian
SW Swahili
TH Thai
TR Turkish
UK Ukrainian
UZ Uzbek
VI Vietnamese

Games code list:

Game Code
Wheelbet 2
Poker 3
War Of Elements 5
5Bet 6
7Bet 7
Keno 9
1Bet 10
Teen Patti 11
Lucky6 12
FruitRace 14
Mega6 15
Spin2Wheels 16
Andar Bahar 17
BlackJack 19
Jokerbet 20

Currency code list:

Ticker Currency
AUD Australian Dollar
AZN Azerbaijani manat
ALL Albanian lek
DZD Algerian Dinar
AOA The Angolan Kwanza
ARS Argentine Peso
AMD Armenian dram
BDT Bangladeshi taka
BHD Bahrain Dinar
BYN Belarusian ruble new
BGN The Bulgarian Lev
BOB Boliviano
BWP Botswana Pool
BRL Brazilian real
BIF Burundian franc
CUP Cuban Peso
HUF Hungarian Forint
VES Sovereign Bolivar
VND Vietnamese Dong
HTG Haitian Gourde
GMD The Gambian dalasi
GHS Ghana cedi
GTQ Guatemalan quetzal
GNF Guinean Franc
HNL Honduran lempira
HKD Hong Kong Dollar
GEL Georgian lari
DKK Danish krone
AED Dirham United Arab Emirates
ZWL Zimbabwe Dollar
USD US Dollar
DOP Dominican peso
EUR Euro
EGP Egyptian pound
ZMW Zambian kwacha
INR Indian Rupee
IDR Indonesian Rupee
JOD Jordanian Dinar
IQD Iraqi Dinar
IRR Iranian Rial
ISK Icelandic krone
KZT Kazakhstani tenge
KHR Cambodian riel
CAD Canadian Dollar
QAR Qatar Riyal
KES Kenyan Shilling
KGS The Kyrgyz som
CNY Chinese yuan
COP Colombian peso
KMF Comorian Franc
BAM Bosnia and Herzegovina convertible mark
CDF Congolese Franc
CRC Costa Rican colon
KWD Kuwaiti Dinar
LAK Lao kip
LBP Lebanese pound
LBPM Lebanese pound market
LRD Liberian dollar
LYD Libyan Dinar
LSL Lesotho’s Loti
MUR Mauritius Rupee
MRU Moorish Ugia
MKD Macedonian Denar
MWK Malawian kwacha
MGA Malagasy Ariary
MYR Malaysian ringgit
MAD Moroccan Dirham
MXN Mexican Peso
MZN Mozambican Mikalik
MDL Moldovan Leu
MNT Mongolian tugrik
MMK Myanmar kyat
NAD The Namibian dollar
NPR Nepalese rupee
NGN Nigerian Naira
NIO Nicaraguan cordoba
NZD New Zealand Dollar
ILS New Israeli Sheqel
TWD New Taiwan Dollar
NOK Norwegian Krone
OMR Omani Rial
PAB Panamanian balboa
PKR Pakistani Rupee
PYG Paraguayan Guarani
PEN Peruvian new sol
PLN Polish zloty
PRB The Transnistrian ruble
RUB Russian Ruble
RWF Rwandan franc
RON Romanian leu
SAR Saudi Riyal
SZL Swaziland Lilangeni
SCR Seychelles Rupee
SLL Sierra Leonean leone
RSD Serbian Dinar
SGD Singapore Dollar
SOS Somali Shilling
SYP Syrian pound
SYPM Syrian pound market
SDG Sudanese pound
TJS Tajik somoni
THB Thai Baht
TZS Tanzanian Shilling
TND Tunisian Dinar
TRY Turkish lira
TTD Trinidad and Tobago dollar
TMT Turkmen manat
TMTM Turkmen manat market
UGX Ugandan Shilling
UZS Uzbek Sum
UAH Ukrainian Hryvnia
UYU Uruguayan peso
PHP Philippine Peso
DJF Frank Djibouti
XOF Franc CFA BCEAO
XAF CFA Franc BEAC
GBP Pound Sterling
HRK Croatian kuna
CZK The Czech crown
CLP Chilean Peso
SEK Swedish Krona
CHF Swiss Franc
LKR Sri Lanka Rupee
ERN Eritrean Nacfa
CVE Escudo Cape Verde
ETB The Ethiopian Birr
ZAR South African Rand
KRW South Korean Won
SSP South Sudanese Pound
JPY Japanese Yen
SLE Sierra Leonean Leone
MVR Maldivian rufiyaa
VEF Venezuelan bolivar

Cryptocurrencies code list:

Код Название
BLU Blue Coin
BTS BitShares
BCN Bytecoin
BNB Binance Coin
BNS BNS Token
BUSD Binance USD
ADA Cardano
LINK Chainlink
CNB Coinsbit Token
DGB DigiByte
DOGE Dogecoin
EOS EOSIO
GAME GameСredits
ICX ICON
µBT Micro-Bitcoin
mBT Milli-Bitcoin
mBCH Milli-Bitcoin Cash
mBTG Milli-Bitcoin gold
mDASH Milli-DASH
mETH Milli-Ethereum
mETC Milli-Ethereum Classic
mLTC Milli-LiteСoin
mXMR Milli-Monero
mZEC Milli-Zcash
OMG OmiseGO
QTUM QTUM
SIB SIBCoin
TRX TRON
USDT Tether
WIN WINk
XVG Verge
XEM Xem/Nem
XRP Ripple Coin
UBTC United Bitcoin
FUN FUNToken
TFUN TFUN
XFUN XFUN
NEO Neo
BITORB BitOrbit
SATS Satoshi
USDC USD Coin