Data Export Service API

From BetgamesTV
Jump to navigation Jump to search

Intro

Return bets transaction report by partner id.
The maximum number of rows that can return the service is 100000.

Request

GET: 
/s/api/v2/bets_report/index?format=:format&partner_id=:partner_id&date_from=:date_from&date_to=:date_to

IMPORTANT: for all requests, please use secured hypertext protocol (HTTPS).

Allowed Parameters

Field Type Require Description
format String Yes Default value "json".
Allowed values:"json", "xml", "csv"
date_from String Yes Datetime format like Y-m-d H:i:s.
The date_from cannot be greater than date_to
date_to String Yes Datetime format like Y-m-d H:i:s
partner_id Number Yes Partner unique ID.
betshop_id Number No Betshop unique ID.
pos_id Number No Pos unique ID.
pos_user_id Number No Pos user unique ID.
player_id Number No Player unique ID.
odd_id Number No Odd unique ID.
game_id Number No Game-ID's
platform_id Number No Platform unique ID.
1 - Shop.
2 - Webshop.
3 - Web.
4 - Web mobile.
currency_id Number No Currency unique ID.
transaction_type_id Number No

Transaction type.
1 - Paid in.
2 - Calculated as refunded.
3 - Calculated as won.
4 - Calculated as lost.
5 - Calculated as canceled.
6 - Paid out as refunded.
7 - Paid out as won.
8 - Paid out as lost.
9 - Paid out as canceled.
10 - Undo calculation.
11 - Undo calculation.

include_subpartners Number No 1 - includes data from all subpartners

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Usage

Request curl example:

curl 'https://api.betgames.tv/s/api/v2/bets_report/index?format=json&partner_id=1&date_from=2016-03-15%2000:00:00&date_to=2016-03-15%2023:59:59'

Request php example:

<?php
 include('vendor/rmccue/requests/library/Requests.php');
 // PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46)
 // Copyright (c) 1997-2014 The PHP Group
 // Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
 // with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
 // with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

 Requests::register_autoloader();
 $params = [
     'format'     => 'json', // json, xml, csv
     'partner_id' => 1,
     'date_from'  => '2016-03-15 00:00:00',
     'date_to'    => '2016-03-15 23:59:59',
 ];
 $response = Requests::get('https://api.betgames.tv/s/api/v2/bets_report/index?'.https_build_query($params));

 if ($response->status_code >= 400) {
     foreach ($response->body['errors'] as $error){
         throw new Exception($error);
     });
 } else {
    $decodeJson = json_decode($response->body);
    $db = new DB();

    // Save report to database
    foreach (array_chunk($decodeJson, 1000) as $el) {
         $db->insert_batch('db_table', $el);
    }
 }
?>

Success-Response

Header HTTPS/1.1 200 OK

JSON

[
 {
     "id": 1,
     "transaction_type_id": 2,
     "platform_id": 4,
     "amount": 576.00,
     "player_id": "38675",
     "bet_id": 538925,
     "partner_id": 662472,
     "betshop_id": 830434,
     "pos_id": 996918,
     "pos_user_id": 790381,
     "odd_id": 287626,
     "game_id": 7,
     "currency_id": 84,
     "date_time": 1457718445,
     "partner_name": "Alpha",
     "betshop_name": "Alpha shop",
     "pos_name": "Alpha pos",
     "pos_user_name": "Alpha pos user"
 },
 {
     "id": 2,
     "transaction_type_id": 1,
     "platform_id": 3,
     "amount": 977.00,
     "player_id": "800341",
     "bet_id": 588127,
     "partner_id": 528682,
     "betshop_id": 836183,
     "pos_id": 255639,
     "pos_user_id": 789795,
     "odd_id": 494583,
     "game_id": 3,
     "currency_id": 52,
     "date_time": 1456228892,
     "partner_name": "Beta",
     "betshop_name": "Beta shop",
     "pos_name": "Beta pos",
     "pos_user_name": "Beta pos user"
 }
]

XML

<?xml version="1.0"?>
 <data>
     <item key="0">
         <id>3200201</id>
         <transaction_type_id>1</transaction_type_id>
         <platform_id>4</platform_id>
         <amount>117</amount>
         <player_id>212643</player_id>
         <bet_id>51004279</bet_id>
         <partner_id>1425</partner_id>
         <betshop_id>3891</betshop_id>
         <pos_id>2477</pos_id>
         <pos_user_id>2397</pos_user_id>
         <odd_id>55</odd_id>
         <game_id>1</game_id>
         <currency_id>58</currency_id>
         <date_time>2016-03-15 12:54:07</date_time>
         <partner_name>Alpha</partner_name>
         <betshop_name>Alpha shop</betshop_name>
         <pos_name>Alpha pos</pos_name>
         <pos_user_name>Alpha pos user</pos_user_name>
     </item>
     <item key="0">
         <id>3200202</id>
         <transaction_type_id>2</transaction_type_id>
         <platform_id>4</platform_id>
         <amount>13.00</amount>
         <player_id>21443</player_id>
         <bet_id>5464279</bet_id>
         <partner_id>3</partner_id>
         <betshop_id>234</betshop_id>
         <pos_id>5685</pos_id>
         <pos_user_id>88</pos_user_id>
         <odd_id>980</odd_id>
         <game_id>7</game_id>
         <currency_id>58</currency_id>
         <date_time>2016-03-15 12:54:07</date_time>
         <partner_name>Beta</partner_name>
         <betshop_name>Beta shop</betshop_name>
         <pos_name>Beta pos</pos_name>
         <pos_user_name>Beta pos user</pos_user_name>
     </item>
 </data>

CSV

id,transaction_type_id,platform_id,amount,player_id,bet_id,partner_id,betshop_id,pos_id,pos_user_id,odd_id,game_id,currency_id,date_time,partner_name,betshop_name,pos_name,pos_user_name
3200201,1,4,117.00,212643,51004279,1425,3891,2477,2397,55,1,58,2016-03-15 12:54:07,Alpha,Alpha shop,Alpha pos,Alpha pos user
3200202,2,1,140.00,1557,74218707,1425,3144,3190,816,430,3,16,2016-03-15 12:54:07,Beta,Beta shop,Beta pos,Beta pos user

Error 4xx

Name Description
partner_id Export service is not available for this partner.
To solve this problem you should enabled "Service export" for this partner in admin part.
exceeds_rows_limit The number of records 1081540 exceeds the maximum 100000, please reduce the period.
To solve this problem, please reduce the time for which you want to receive the report.

Error-Response

Header HTTPS/1.1 400 Bad Request

JSON

{
   "errors": {
      "date_from": "The date_from cannot be greater then date_to",
      "date_to": "The date_to should be contain Y-m-d H:i:s",
      "partner_id": "Export service is not available for this partner",
      "exceeds_rows_limit": "The number of records 1081540 exceeds the maximum 100000, please reduce the period",
      "error": "Partner not found."
   }
 }

XML

<?xml version="1.0"?>
<errors>
     <error>The date_from cannot be greater then date_to</error>
     <error>The date_to should be contain Y-m-d H:i:s</error>
     <error>Export service is not available for this partner</error>
     <error>The number of records 1081540 exceeds the maximum 100000, please reduce the period</error>
     <error>Partner not found.</error>
</errors>

CSV

"errors"
"The date_from cannot be greater then date_to"
"The date_to should be contain Y-m-d H:i:s"
"Export service is not available for this partner"
"The number of records 1081540 exceeds the maximum 100000, please reduce the period"
"Partner not found."