Using the Rubitime Service API

To connect Bitrix24, amoCRM or Google Calendar, see this instruction .

To use the API, you need to generate an access key at the 5th step of the settings, in the "Receiving and saving data using API" block. To generate a key, press the "Generate Key" button, to regenerate "Regenerate Key", to delete "Delete Key".

To get the data, you need to call https://rubitime.ru/rest/{{method}} , pass the "rk" key and POST parameters by request:

Method Parameter Description
get-record 'id' => 1 // post id
'rk' => 'xxx' & nbsp; // API key
Get data about record number X, where X is # of record.
get-records 'from' => '2020-01-01', // date from which to get records;
'to '=> '2020-01-02', // date by which to get records.
'rk '=> 'xxx' & nbsp; // API key
Get an array of records by dates from and to. Date format: YYYY-MM-DD. It is not recommended to specify a large interval in case of a large number of records in the period.
create-record
and update-record
' id ' => 79379, // only for update-record
' branch ' => '1013', // branch id
' cooperator ' => '1702', // employee id
' service ' => '3925', // service id
' name ' => 'Ivanov Ivan Ivanovich', // Client's full name
' email ' => 'test@test.ru', // client email
' phone ' => '+70000000000', // customer's phone number
' comment ' => 'Comment', // customer comment on the post
' datetime ' => '2020-01-18 20:00', // date and time at which the client is registered
' price '=> 100.00, // service cost
' duration ' => 60, // service duration in minutes
' prepayment ' => 50.00, // prepayment amount
' reminder ' => '2020-01-18 19:00', // Moscow time to send a reminder
' custom1 '=> 'Additional field 1', // data for additional fields: custom1, custom2, ..., custom6
' status '=> 0 , // post status: 0 => 'Recorded', 1 => 'On service', 2 => 'Completed', 3 => 'Awaiting prepayment', 4 => 'Canceled', 5 => 'Awaiting confirmation', 6 => 'Advance booking'
' source ' => 'my_source', // source, defaults to 'api'
' rk ' => 'xxx', // API key
Create a new entry and edit an existing entry. Required parameters: branch, cooperator, service, status, datetime, rk.
get-clients 'rk' => 'xxx' & nbsp; // API key Get an array of clients.
get-time 'id' => 1, // service id
'rk' => 'xxx' & nbsp; // API key
Get service schedule: array of dates and times to record.

3 parameters are returned in response:

status - can be ok or error;
message - message text;
data - result of request execution.

Example request

An example of receiving a schedule for the rendering of the service # 3 "Makeup" from Victoria from demo site (number the service is indicated in the block header when editing the service itself "Edit service # 3"):

$queryUrl = 'https://rubitime.ru/rest/get-time/3';
$queryData = [
    'rk' => 'xxx',
];

$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_URL => $queryUrl,
    CURLOPT_POSTFIELDS => http_build_query($queryData),
]);
$result = curl_exec($curl);
curl_close($curl);

$result = json_decode($result, true);
if ($result) {
    if ($result['status'] == 'ok') {
        echo "Success: {$result['message']}";
        var_dump($result['data']);
    } else {
        echo "Error: {$result['message']}";
    }
}

Example response

[
    'status' => 'ok',
    'message' => 'Service found',
    'data' => [
        '2019-10-14' =>
            [
                '10:00' => [
                    'available' => true,
                    'time' => "10:00",
                    'fulldate' => "2019-10-14 10:00:00",
                    'fulldaten' => 1584169200,
                    'cooperator' => 2,
                    'service' => 3,
                    'rclientid' => null,
                    'baseCooperator' => 2,
                    'cooperatorName' => "Viktoria",
                ],
                '11:00' => [
                    'available' => false,
                    'time' => "10:00",
                    'fulldate' => "2019-10-14 11:00:00",
                    'fulldaten' => 1684169200,
                    'cooperator' => 2,
                    'service' => 3,
                    'rclientid' => null,
                    'baseCooperator' => 2,
                    'cooperatorName' => "Viktoria",
                ],
                //...
            ],
        '2019-10-15' => [
            [
                '10:00' => [
                    'available' => true,
                    'time' => "10:00",
                    'fulldate' => "2019-10-15 10:00:00",
                    'fulldaten' => 1584169200,
                    'cooperator' => 2,
                    'service' => 3,
                    'rclientid' => null,
                    'baseCooperator' => 2,
                    'cooperatorName' => "Viktoria",
                ],
                //...
            ],
        ],
    ]
];