Introduction

The Thrace.Site API allows tour operators and agents to implement into their website an automated solution to adding and updating tour information on the thrace.site website.

Quick Start Guide

For developers eager to get up and running using the API, the following are the 2 basic steps to follow.

  1. Contact us via the contact form to register your tour operator agency with us and receive your unique API key.
  2. Implement the api call into your web platform (sample PHP code provided below for reference)

Note: Requests should not be made through client-side scripts to prevent your API key being stolen.

The following PHP code uses cURL to add or update a tour.


// api calls // > addupdate - add or update a tour // > delete - remove a tour // > // set your API key and call $api_key = 'YOUR_API_KEY_GOES_HERE'; $api_cmd = 'addupdate'; $parameters = [ 'id' => '100', // an id to assign to this tour (e.g. your database entry id) 'days' => 1, // how many days this tour lasts 'nights' => 0, // how many nights is this tour? 'startcountry' => 'bg', // the iso2 country where the tour begins 'countries' => 1, // how many countries does the tour include stops. 'cities' => 2, // how many cities does the tour include stops. 'accominc' => true, // is accommodation included in the starting price? 'price_currency' => 'EUR', // iso 3 character currency code, only EUR is supported. 'startprice' => 25.20, // starting price per person // a href pointing to an image representing this tour (this must be a https connection). 'img_url' => 'https://link-to-your-image.jpg', // meta languages can be en, bg or tr (respectively English, Bulgarian or Turkish) 'meta' => [ 'en' => [ 'url' => 'https://url', // url to the official tour page 'title' => 'A Tour', // title of the tour. Max 256 characters. // text for the tour. Max 1024 characters. 'text' => 'Just a simple tour', // some example features 'features' => [ [ // a type of heading/group. Max 24 characters. 'type' => 'Included', // the name of the feature. Max 32 characters. 'name' => 'Meals', // text for the feature. Max 256 characters. 'text' => '2 full course meals are included in the starting price.', ], [ 'type' => 'Included', 'name' => 'Transport', 'text' => 'You will be collected from and dropped back home.', ], ] ], 'bg' => [ 'url' => 'http://url', // url to the official tour page 'title' => 'A Tour', // title of the tour. Max 256 characters. // text for the tour. Max 1024 characters. 'text' => 'Just a simple tour', // some example features 'features' => [ [ // a type of heading/group. Max 24 characters. 'type' => 'Included', // the name of the feature. Max 32 characters. 'name' => 'Meals', // text for the feature. Max 256 characters. 'text' => '2 full course meals are included in the starting price.', ], [ 'type' => 'Included', 'name' => 'Transport', 'text' => 'You will be collected from and dropped back home.', ], ] ] ] ]; $headers = [ 'Content-Type: application/json', "X-THRACE-SITE-API-KEY: {$api_key}" ]; $payload = json_encode($parameters); // encode the parameters as json $url = "https://thrace.site/?api=tours&f={$api_cmd}"; $curl = curl_init(); // get cURL resource // set cURL options curl_setopt_array($curl, array( CURLOPT_URL => $url, // set the request URL CURLOPT_HTTPHEADER => $headers, // set the headers CURLOPT_POSTFIELDS => $payload, // add the json payload CURLOPT_RETURNTRANSFER => 1 // ask for raw response instead of bool )); $response = curl_exec($curl); // send the request, save the response curl_close($curl); // close request // 200 OK is returned if acceepted and 400 Bad Request if something went wrong (response will contain the error if so)

The following code requests deletion of several tours.


// set your API key and call $api_key = 'YOUR_API_KEY_GOES_HERE'; $api_cmd = 'delete'; $parameters = [100, 121, 532]; $headers = [ 'Content-Type: application/json', "X-THRACE-SITE-API-KEY: {$api_key}" ]; $payload = json_encode($parameters); // encode the parameters as json $url = "https://thrace.site/?api=tours&f={$api_cmd}"; $curl = curl_init(); // get cURL resource // Set cURL options curl_setopt_array($curl, array( CURLOPT_URL => $url, // set the request URL CURLOPT_HTTPHEADER => $headers, // set the headers CURLOPT_POSTFIELDS => $payload, // add the json payload CURLOPT_RETURNTRANSFER => 1 // ask for raw response instead of bool )); $response = curl_exec($curl); // send the request, save the response //$json = json_decode($response, true); // decode the json response as an array curl_close($curl); // close request // 200 OK is returned if acceepted and 400 Bad Request if something went wrong (response will contain the error if so) print($response); // print the json

If you require help to implement the API into your website or software, please do not hesitate to contact us for help!