### Get start time matrix with getStartTimeMatrix Source: https://help.simplybook.me/index.php/User_API_guide Retrieves available time slots for booking within a specified date range, service, and performer. ```php $dateFrom = '2015-03-03'; $dateTo = '2015-03-04'; $serviceId = 1; $performerId = 1; $qty = 1; $availableTime = $client->getStartTimeMatrix($dateFrom, $dateTo, $serviceId, $performerId, $qty); // returns array( // '2015-03-03' => array('09:00:00', '09:30:00', '10:00:00', ....), // '2015-03-04' => array('09:00:00', '09:30:00', '10:00:00', ....), //); ``` -------------------------------- ### Client API Authorization - Server Side Source: https://help.simplybook.me/index.php/User_API_guide Shows how to get a token and initialize a JSON-RPC client for the Client API from server-side PHP. ```APIDOC ## Client API Authorization - Server Side ### Description Obtain a token and initialize a JSON-RPC client for the Client API (Company Public Service) from server-side PHP. ### Method POST ### Endpoint https://user-api.simplybook.me/login/ ### Parameters #### Request Body - **YOUR_COMPANY_LOGIN** (string) - Required - Your company login. - **YOUR_API_KEY** (string) - Required - Your API key. ### Request Example ```php $loginClient = new JsonRpcClient('https://user-api.simplybook.me' . '/login/'); $token = $loginClient->getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY); ``` ### Response #### Success Response (200) - **token** (string) - The token-key for authentication. #### Response Example ```php $token = $loginClient->getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY); ``` ### Notes After obtaining the token, initialize the JSON-RPC client with the token in the headers. ```php $client = new JsonRpcClient('https://user-api.simplybook.me' . '/', array( 'headers' => array( 'X-Company-Login: ' . YOUR_COMPANY_LOGIN, 'X-Token: ' . $token ) )); ``` ``` -------------------------------- ### Get services list with getEventList Source: https://help.simplybook.me/index.php/User_API_guide Retrieves a list of available services with their details, including duration, description, and activity status. ```php $services = $client->getEventList(); // returns array(array( // 'id' => 1, - service id // 'name' => 'Service 1', - service's name // 'description' => 'Describe your service...', - service description // 'duration' => 60, - service duration // 'hide_duration' => 0, - Hide duration to clients flag, // 'picture' => null, - file name of picture or null // 'picture_path' => '/uploads/apidemo/event__picture/small/', - full path to picture, // 'position' => 1 - service position // 'is_active' => 1, - the service is activated // 'is_public' => 1, - the service is allowed to book by clients // ), ...) ``` -------------------------------- ### Client API Authorization - Client Side Source: https://help.simplybook.me/index.php/User_API_guide Shows how to get a token and initialize a JSON-RPC client for the Client API from client-side JavaScript. ```APIDOC ## Client API Authorization - Client Side ### Description Obtain a token and initialize a JSON-RPC client for the Client API (Company Public Service) from client-side JavaScript. ### Method POST ### Endpoint https://user-api.simplybook.me/login ### Parameters #### Request Body - **YOUR_COMPANY_LOGIN** (string) - Required - Your company login. - **YOUR_API_KEY** (string) - Required - Your API key. ### Request Example ```javascript var loginClient = new JSONRpcClient({ 'url': 'https://user-api.simplybook.me' + '/login', 'onerror': function (error) {}, }); var token = loginClient.getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY); ``` ### Response #### Success Response (200) - **token** (string) - The token-key for authentication. #### Response Example ```javascript var token = loginClient.getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY); ``` ### Notes After obtaining the token, initialize the JSON-RPC client with the token in the headers. ```javascript this.client = new JSONRpcClient({ 'url': 'https://user-api.simplybook.me', 'headers': { 'X-Company-Login': YOUR_COMPANY_LOGIN, 'X-Token': token }, 'onerror': function (error) {} }); ``` ``` -------------------------------- ### User/Admin API Authorization - Client Side Source: https://help.simplybook.me/index.php/User_API_guide Shows how to get a token and initialize a JSON-RPC client for the User/Admin API (Company Administration Service) from client-side JavaScript. ```APIDOC ## User/Admin API Authorization - Client Side ### Description Obtain a token and initialize a JSON-RPC client for the User/Admin API (Company Administration Service) from client-side JavaScript. ### Method POST ### Endpoint https://user-api.simplybook.me/login ### Parameters #### Request Body - **YOUR_COMPANY_LOGIN** (string) - Required - Your company login. - **YOUR_USER_LOGIN** (string) - Required - Your user login. - **YOUR_USER_PASSWORD** (string) - Required - Your user password. ### Request Example ```javascript var loginClient = new JSONRpcClient({ 'url': 'https://user-api.simplybook.me' + '/login', 'onerror': function (error) {}, }); var token = loginClient.getUserToken(YOUR_COMPANY_LOGIN, YOUR_USER_LOGIN, YOUR_USER_PASSWORD); ``` ### Response #### Success Response (200) - **token** (string) - The token-key for authentication. #### Response Example ```javascript var token = loginClient.getUserToken(YOUR_COMPANY_LOGIN, YOUR_USER_LOGIN, YOUR_USER_PASSWORD); ``` ### Notes After obtaining the token, initialize the JSON-RPC client with the token in the headers. ```javascript this.client = new JSONRpcClient({ 'url': 'https://user-api.simplybook.me' + '/admin/', 'headers': { 'X-Company-Login': YOUR_COMPANY_LOGIN, 'X-User-Token': token }, 'onerror': function (error) {} }); ``` ``` -------------------------------- ### getStartTimeMatrix Source: https://help.simplybook.me/index.php/User_API_guide Retrieves available time slots for booking within a date range for a given service and performer. Returns a list of start times for each date. ```APIDOC ## getStartTimeMatrix ### Description Returns an array of available start times for each date in the specified range, for the given service and performer. ### Method GET ### Endpoint Not specified ### Parameters #### Path Parameters - **dateFrom** (string) - Required - Start date in YYYY-MM-DD format - **dateTo** (string) - Required - End date in YYYY-MM-DD format - **serviceId** (integer) - Required - Service id - **performerId** (integer) - Required - Performer id - **qty** (integer) - Required - Quantity of slots needed ### Request Example ``` $dateFrom = '2015-03-03'; $dateTo = '2015-03-04'; $serviceId = 1; $performerId = 1; $qty = 1; $availableTime = $client->getStartTimeMatrix($dateFrom, $dateTo, $serviceId, $performerId, $qty); ``` ### Response #### Success Response Returns an associative array keyed by date (YYYY-MM-DD) with an array of available start times in HH:MM:SS format. #### Response Example ``` array( '2015-03-03' => array('09:00:00', '09:30:00', '10:00:00', ...), '2015-03-04' => array('09:00:00', '09:30:00', '10:00:00', ...), ) ``` ``` -------------------------------- ### Get service performers list with getUnitList Source: https://help.simplybook.me/index.php/User_API_guide Retrieves a list of service performers (employees) with their contact information and availability status. ```php $services = $client->getUnitList(); // returns array(array( // 'id' => 1, - performer id // 'name' => 'Provider 1', - performer name // 'phone' => '111111111', - perfomer phone number // 'description' => 'Describe your performer...', - performer description // 'email' => 'test@gmail.com', - perfomer email, // 'is_active' => 1, - the performer is activated // 'is_visible' => 1, - the perfomer is visible for clients, // 'picture' => null, - file name of picture or null,, // 'picure_path' => '/uploads/apidemo/unit_group__picture/small/', - full path to picture // 'position' => 1, - performer position // 'qty' => 1, performer quantity // ), ...) ``` -------------------------------- ### User/Admin API Authorization - Server Side Source: https://help.simplybook.me/index.php/User_API_guide Shows how to get a token and initialize a JSON-RPC client for the User/Admin API (Company Administration Service) from server-side PHP. ```APIDOC ## User/Admin API Authorization - Server Side ### Description Obtain a token and initialize a JSON-RPC client for the User/Admin API (Company Administration Service) from server-side PHP. ### Method POST ### Endpoint https://user-api.simplybook.me/login/ ### Parameters #### Request Body - **YOUR_COMPANY_LOGIN** (string) - Required - Your company login. - **YOUR_USER_LOGIN** (string) - Required - Your user login. - **YOUR_USER_PASSWORD** (string) - Required - Your user password. ### Request Example ```php $loginClient = new JsonRpcClient('https://user-api.simplybook.me' . '/login/'); $token = $loginClient->getUserToken(YOUR_COMPANY_LOGIN, YOUR_USER_LOGIN, YOUR_USER_PASSWORD); ``` ### Response #### Success Response (200) - **token** (string) - The token-key for authentication. #### Response Example ```php $token = $loginClient->getUserToken(YOUR_COMPANY_LOGIN, YOUR_USER_LOGIN, YOUR_USER_PASSWORD); ``` ### Notes After obtaining the token, initialize the JSON-RPC client with the token in the headers. ```php $client = new JsonRpcClient('https://user-api.simplybook.me' . '/admin/', array( 'headers' => array( 'X-Company-Login: ' . YOUR_COMPANY_LOGIN, 'X-User-Token: ' . $token ) )); ``` ``` -------------------------------- ### Get work days info with getWorkCalendar Source: https://help.simplybook.me/index.php/User_API_guide Retrieves working hours and day-off information for a specific month and performer. ```php $year = 2015; $month = 3; // March $performerId = 1; // Can be null $workDaysInfo = $client->getWorkCalendar($year, $month, $performerId); // returns array( // '2015-03-01' => array('from' => '09:00:00', 'to' => '18:00:00', 'is_day_off' => 0), // '2015-03-02' => array('from' => '09:00:00', 'to' => '18:00:00', 'is_day_off' => 0), // ... //); ``` -------------------------------- ### Service booking and confirmation with secret API key Source: https://help.simplybook.me/index.php/User_API_guide Demonstrates how to call the book method and confirm the booking using a secure signature generated with your secret API key when confirmation is required. ```php $additionalFields = array( '6740d3bce747107ddb9a789cbb78abf3' => 'value1', 'b0657bafaec7a2c9800b923f959f8163' => 'value2' ); $clientData = array( 'name' => 'Client name', 'email' => 'client@email.com', 'phone' => '+13152108338' ); $bookingsInfo = $client->book($eventId, $unitId, $date, $time, $clientData, $additionalFields); if ($bookingsInfo->require_confirm) { foreach ($bookingsInfo->bookings as $booking) { $sign = md5($booking->id . $booking->hash . YOUR_API_SECRET_KEY); $result = $client->confirmBooking($booking->id, $sign); echo ' Confirm result '; var_dump($result); } } ``` -------------------------------- ### getWorkCalendar Source: https://help.simplybook.me/index.php/User_API_guide Retrieves working day information for a given month and optionally for a specific performer. Returns start and end times for each day and indicates day-offs. ```APIDOC ## getWorkCalendar ### Description Returns an array of working day information for the specified year and month, optionally filtered by performer. Each day includes start time, end time, and day-off flag. ### Method GET ### Endpoint Not specified ### Parameters #### Path Parameters - **year** (integer) - Required - Year for which to retrieve work calendar - **month** (integer) - Required - Month (1-12) for which to retrieve work calendar - **performerId** (integer|null) - Optional - Performer id to filter the calendar; can be null for company-wide calendar ### Request Example ``` $year = 2015; $month = 3; // March $performerId = 1; // Can be null $workDaysInfo = $client->getWorkCalendar($year, $month, $performerId); ``` ### Response #### Success Response Returns an associative array keyed by date (YYYY-MM-DD) with the following fields: - **from** (string) - Working day start time in HH:MM:SS format - **to** (string) - Working day end time in HH:MM:SS format - **is_day_off** (integer) - Flag indicating if the day is a day off (0 or 1) #### Response Example ``` array( '2015-03-01' => array('from' => '09:00:00', 'to' => '18:00:00', 'is_day_off' => 0), '2015-03-02' => array('from' => '09:00:00', 'to' => '18:00:00', 'is_day_off' => 0), ... ) ``` ``` -------------------------------- ### Client API client-side authorization (getToken + JSONRpcClient) Source: https://help.simplybook.me/index.php/User_API_guide Client-side authorization for the Client API (company public service). First obtain a token using getToken with your company login and API key, then initialize the JSON-RPC client with the token in the X-Token header. ```javascript var loginClient = new JSONRpcClient({ 'url': 'https://user-api.simplybook.me' + '/login', 'onerror': function (error) {}, }); var token = loginClient.getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY); ``` ```javascript this.client = new JSONRpcClient({ 'url': 'https://user-api.simplybook.me', 'headers': { 'X-Company-Login': YOUR_COMPANY_LOGIN, 'X-Token': token }, 'onerror': function (error) {} }); ``` -------------------------------- ### Calculate booking end time with calculateEndTime Source: https://help.simplybook.me/index.php/User_API_guide Calculates the end date and time of a service based on the start time, service ID, and performer ID. ```php $startDateTime = '2015-03-03 09:00:00'; $serviceId = 1; $performerId = 1; $availableTime = $client->calculateEndTime($startDateTime, $serviceId, $performerId); // returns '2015-03-03 10:00:00' ```