User Tools

Site Tools


ors-soap-api:public:json_api

This is an old revision of the document!


ORS JSON API

You can now also use our new JSON API. It is very similar to SOAP request, but you don't need SOAP client anymore, instead you can simply send JSON requests to our API url.

Post URL: http://api.ors.si/crs/json

PHP Example

# JSON search region request example
{
  "requestType":"search",
  "action":"regions",
  "search":{
    "typ":"hotel",
    "vnd":"2018-01-10",
    "bsd":"2018-03-10",
    "tdc":"1-5",
    "epc":"2"
  },
  "top":{
    "toc":"FTI",
    "stc":"3"
  },
  "header":{
    "lang":"[lang-code]",
    "usr":"[username]",
    "pass":"[password]",
    "agid":"[agency-id]"
  }
}
// PHP cURL post example
 
$data_string = 'json-request-string';
 
$ch = curl_init('http://api.ors.si/crs/json');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json;charset=utf-8',                                                                                
    'Content-Length: ' . strlen($data_string))                                                                       
);                                                                                                                   
 
$result = curl_exec($ch);
echo $result;

Requests

There are 4 types of requestTypes available:

  • search : for searching regions, offers and trips
  • info : to get object descriptions and flight information,
  • check : for availability request,
  • book : to create registrations, booking, cancellations

Each request must also have an action which is named the same as SOAP api call methods.

So fo example if you wich to search for hotels in a selected region, you create request like so:

{
  "requestType":"search",
  "action":"offers",
  "search":{
    "typ":"hotel",
    "vnd":"2018-01-10",
    "bsd":"2018-03-10",
    "tdc":"1-5",
    "rgcs":"100023",
    "epc":"2"
  },
  "top":{
    "toc":"FTI",
    "stc":"3"
  },
  "header":{
    "lang":"[lang-code]",
    "usr":"[username]",
    "pass":"[password]",
    "agid":"[agency-id]"
  }
}

Response

If error occurs, this is an example of the output

{
  "errorNr":2001,
  "error":{"msg":"Invalid (or missing) action"}
}

On success you will get a JSON string which is the same structure as you would get with SOAP requests. Please check SOAP Calls for details.

ors-soap-api/public/json_api.1513176331.txt.gz · Last modified: 2017/12/13 15:45 by admin