DEVELOPER AREA

Request account

Contact us to start integration

Each account will have:

  • More endpoints, one for each hotel he has inserted and valid for alls
  • 2 strings: sub and secret-key, to create your JSON web token, see Authentication.

Support

Write to info@okrate.it

Authentication

Authentication is used to identify the caller and secure communication for all requests both ways, to our servers and to partner servers. In order to be granted access, you will need to include in the auth header a JWT as Bearer token, generated as follows:

the header must be

{
"alg": "HS512",
"typ": "JWT",
"expiresIn": "1m"
}

the payload must be

{
"sub": string,
"exp": timestamp
}

sub is the partner unique id will be a visibile on admina area (in the form of a uuid)

exp is a unix timestamp pointing to a minute from now (when the request is sent)

the signature must be

HMACSHA512(
base64UrlEncode(header) + "." + base64UrlEncode(payload),
secret-key
)

secret-key will be a visibile on admina area

the algorithm is HS512;

The sub and secret-key are unique and serve to identify your company, therefore must be used for every property

  • sub and secret key will remain the same in the production environment
  • token expiration is mandatory and can be max 1 minute.

Example php code to get token

Library available on:

https://github.com/firebase/php-jwt

  

 

<?php

include ‘class/php-jwt-class/src/JWToken.php’;

 

$issuedAt = time();

$expirationTime = $issuedAt + 59;

$payload = array(

    “sub” => strval($smartpricing_sub),

    “exp”   =>  $expirationTime

);

 

$token = JWToken::encode($payload, $okrate_secret_key,‘HS512’);

 

 

 

Send reservations to okrate

Endpoint

http://console.okrate.it/api/v1/partners/accommodations/{hotelid}/reservations    

 

Where {hotelid} is the hotel id of hotel

Example php code

$json={

      “id”: “22807”,

      “channel”: “Dirette”,

      “rateDescription”: “RO”,

      “checkinAt”: “2024-09-23”,

      “checkoutAt”: “2024-09-29”,

      “status”: “confirmed”,

      “currency”: “EUR”,

      “boardType”: “RO”,

      “amountReservation”: 2060,

      “bookedAt”: “2023-10-19T21:40:32Z”,

      “rooms”: [

        {

          “id”: “Camera Doppia”,

          “name”: “Camera Doppia”,

          “numUnits”: 1,

          “adults”: 2,

          “children”: 0,

          “amountRoom”: 1030,

          “nights”: [

            {

              “price”: 172,

              “date”: “2024-09-23”

            },

            {

              “price”: 172,

              “date”: “2024-09-24”

            },

            {

              “price”: 172,

              “date”: “2024-09-25”

            },

            {

              “price”: 172,

              “date”: “2024-09-26”

            },

            {

              “price”: 172,

              “date”: “2024-09-27”

            },

            {

              “price”: 172,

              “date”: “2024-09-28”

            }

          ]

        },

        {

          “id”: “Camera Doppia”,

          “name”: “Camera Doppia”,

          “numUnits”: 1,

          “adults”: 2,

          “children”: 0,

          “amountRoom”: 1030,

          “nights”: [

            {

              “price”: 172,

              “date”: “2024-09-23”

            },

            {

              “price”: 172,

              “date”: “2024-09-24”

            },

            {

              “price”: 172,

              “date”: “2024-09-25”

            },

            {

              “price”: 172,

              “date”: “2024-09-26”

            },

            {

              “price”: 172,

              “date”: “2024-09-27”

            },

            {

              “price”: 172,

              “date”: “2024-09-28”

            }

          ]

        }

      ]

    }

  ];

 

$curl = curl_init();

curl_setopt_array($curl, array(

  CURLOPT_URL => ‘http://console.okrate.it/api/v1/partners/accommodations/6/reservations’,

  CURLOPT_RETURNTRANSFER => true,

  CURLOPT_ENCODING => ,

  CURLOPT_MAXREDIRS => 10,

  CURLOPT_TIMEOUT => 0,

  CURLOPT_FOLLOWLOCATION => true,

  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

  CURLOPT_CUSTOMREQUEST => ‘POST’,

  CURLOPT_POSTFIELDS =>$json,

  CURLOPT_HTTPHEADER => array(

    ‘Content-Type: application/json’,

    ‘Authorization: Bearer ‘.$token

  ),

));

 

$response = curl_exec($curl);

 

curl_close($curl);

echo $response;

 Json schema 

id*

string
example: 1234567890

id of the reservation on the partner system

checkinAt*

string($date)
example: 2021-08-01

Checkin date in the YYYY-MM-DD format

checkoutAt*

string($date)
example: 2021-08-02

Checkout date in the YYYY-MM-DD format

status*

string
example: confirmed

on our systems the status of a reservations can be only confirmed or canceled; if your systems use a different categorization, please parse thoose statuses to one recognized by us

Enum:
[ confirmed, canceled ]

partnerStatus

string
example: Option

The name of the status actually used by your system

amountReservation*

number
minimum: 0
example: 100

Total reservation amount

bookedAt*

string($date-time)

Booking datetime ISO UTC or ISO with timezone

canceledAt

string($date-time)
example: 2020-10-01T18:45:00Z

Cancellation datetime ISO UTC or ISO with timezone

channel

string
example: Booking.com

Reservation channel name (ie booking.com)

rateDescription*

string
example: Room only

description of the rate relative to the reservation

segment

string
example:

Segment

boardType

string
example: BB

Board type

modifiedAt

string($date-time)
example: 2020-11-01T22:00:00Z

Reservation modification date

currency

string
example: EUR

Currency

rooms*
id*

string
example: DBL STD

the id of the room Type, not the identifier of the room.

name

string
example: Double standard

the name of the room type

numUnits*integer
minimum: 1
example: 1
adults*integer
minimum: 1
example: 2
children*integer
minimum: 0
example: 0
amountRoomnumber
minimum: 0
example: 100
nights*
price*

number
minimum: 0
example: 220

Final price with taxes

date*string($date)
example: 2021-08-01

Reset (delete) reservations

Endpoint

http://console.okrate.it/api/v1/partners/accommodations/{hotelid}/reservations_reset     

Where {hotelid} is the hotel id of the hotel

Example php code

$curl = curl_init();

 

curl_setopt_array($curl, array(

  CURLOPT_URL => ‘http://console.okrate.it/api/v1/partners/accommodations/6/reservations_reset’,

  CURLOPT_RETURNTRANSFER => true,

  CURLOPT_ENCODING => ,

  CURLOPT_MAXREDIRS => 10,

  CURLOPT_TIMEOUT => 0,

  CURLOPT_FOLLOWLOCATION => true,

  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

  CURLOPT_CUSTOMREQUEST => ‘PATCH’,

  CURLOPT_POSTFIELDS =>,

  CURLOPT_HTTPHEADER => array(

    ‘Content-Type: application/json’,

    ‘Authorization: Bearer ‘.$token

  ),

));

 

$response = curl_exec($curl);

 

curl_close($curl);

echo $response;

Torna in alto