> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://helpcenter.superhote.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Intégrer l'api REST de SuperHote pour récupérer les disponibilités ou créer des réservations ?

#### Pour intégrer l'api REST de SuperHote pour récupérer les disponibilités ou créer des réservations, il y a 2 modes d'intégration:

**1-**  Par **iframe**

Veuillez vous référer à l'article ci-dessous:

[Comment intégrer le moteur de réservations SuperHote sur n'importe quel site internet](https://help.superhote.com/a/solutions/articles/150000053075)

**2- Par API**

call REST JSON pour ajouter des réservations, récupérer les disponibilités des appartements\*\*.\*\*

Voici le tutoriel  :

${frame}[](https://www.loom.com/embed/e3a95f9e078849d59d1390ca65ed8941)

*Voici des exemples d'intégration :*

iframe : [https://cosysejour.com/reservation/](https://cosysejour.com/reservation/)

### Endpoints API utiles:

* **Pour récupérer les disponibilités dans SuperHote (e\*\*\*\*n POST)**: [https://app.superhote.com/api/v2/get-availabilities](https://app.superhote.com/api/v2/get-availabilities)

* **Pour créer un booking dans SuperHote (en POST) avec prix pareil que dans SuperHote:**  
[https://app.superhote.com/api/v2/create-booking](https://app.superhote.com/api/v2/create-booking)

* **Pour créer un booking dans SuperHote (en POST) peu importe le prix:**  
[https://app.superhote.com/api/v2/create-reservation](https://app.superhote.com/api/v2/create-reservation)

### Structure Body JSON Exemple:

POUR [https://app.superhote.com/api/v2/get-availabilities:](https://app.superhote.com/api/v2/get-availabilities:)

```
{

"api_key":"[METTRE VOTRE CLÉ API]",  
  "property_key":"[METTRE LA PROPERTY KEY]",  
  "start_date":"2022-11-04",  
  "end_date":"2022-11-07",  
  "nbr_adults":"2",  
  "nbr_children":"0"

}
```

Pour [https://app.superhote.com/api/v2/create-booking](https://app.superhote.com/api/v2/create-booking)

```
{  
    "api_key":"[METTRE VOTRE CLÉ API]",  
    "property_key":"[METTRE LA PROPERTY KEY]",  
    "checking":"2022-11-04",  
    "checkout":"2022-11-07",  
    "nbr_adults":"2",  
    "nbr_children":"0",  
    "first_name":"Test",  
    "last_name":"Mat",  
    "phone":"0607080910",  
    "email":"email@gmail.com",  
    "zip_code":"75000",  
    "city":"Paris",  
    "address":"1 Rue de la Location Courte Durée",  
    "country":"FR",  
    "status":"2",  
    "price":"286.00" // Attention le prix doit être cohérent par rapport ce qu'il y a dans SuperHote pour les dates sélectionnées

}
```

Pour [https://app.superhote.com/api/v2/create-reservation](https://app.superhote.com/api/v2/create-reservation)

```
{  
    "api_key":"[METTRE VOTRE CLÉ API]",  
    "property_key":"[METTRE LA PROPERTY KEY]",  
    "checking":"2022-11-04",  
    "checkout":"2022-11-07",  
    "nbr_adults":"2",  
    "nbr_children":"0",  
    "first_name":"Test",  
    "last_name":"Mat",  
    "phone":"0607080910",  
    "email":"email@gmail.com",  
    "zip_code":"75000",  
    "city":"Paris",  
    "address":"1 Rue de la Location Courte Durée",  
    "country":"FR",  
    "status":"2",  
    "price":"286.00"

}
```

### Voici un exemple de code d'intégration en PHP :
```
/*  
Custom code for SuperHote API Integration  
*/

// CALLED to get availabilities of each rental  
if( !function_exists('get_availabilities') ){  
	function get_availabilities($apiKey, $propKey, $roomId, $checkin, $checkout, $numAdult, $numChild ){

$data = array();  
    $data["start_date"] = $checkin;  
    $data["end_date"] = $checkout;  
    $data["property_key"] = $propKey;  
    $data["api_key"] = $apiKey;  
    $data["nbr_adults"] = $numAdult;  
    $data["nbr_children"] = $numChild;

$json = json_encode($data);

$url = "https://app.superhote.com/api/v2/get-availabilities";

$ch=curl_init();  
    curl_setopt($ch, CURLOPT_POST, 1) ;  
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
    curl_setopt($ch, CURLOPT_URL, $url);  
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);  
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));   
    $result = curl_exec($ch);  
    curl_close ($ch);

return $result;

}  
}

if( !function_exists('create_booking') ){  
    	function create_booking( $apiKey, $propKey, $contact_info, $booking_data, $price, $roomId ){

$checkin = $booking_data["gdlr-check-in"];  
        $lastNight = $booking_data["gdlr-check-out"];  
        $nbNights = intval($booking_data["gdlr-night"]);  
        $daytoadd = 0;

/*if($nbNights == 1)  
          $lastNight = $checkin;  
        else {  
          $daytoadd = $nbNights - 1;  
          $lastNight = date( "Y-m-d", strtotime("+".$daytoadd." day", strtotime($checkin)));  
        }*/

$checkout = date( "Y-m-d", strtotime("+".$nbNights." day", strtotime($checkin)));

$data = array();  
        $data['api_key'] = $apiKey;  
        $data['property_key'] = $propKey;  
        $data["checking"] = $checkin;  
        $data["checkout"] = $checkout;  
        $data["nbr_adults"] = $booking_data["gdlr-adult-number"][0];  
        $data["nbr_children"] = $booking_data["gdlr-children-number"][0];  
        $data["first_name"] = $contact_info["first_name"];  
        $data["last_name"] = $contact_info["last_name"];  
        $data["phone"] = $contact_info["phone"];  
        $data["email"] = $contact_info["email"];  
        $data["address"] = $contact_info["address"];  
       // $data["comments"] = $contact_info["additional-note"];  
        $data["status"] = "1";  
        $data["price"] = $price;

/*  
              {  
          "first_name": "Test",  
          "last_name": "SuperHote",  
          "api_key": "[METTRE CLÉ API]",  
          "checking": "2021-07-01",  
          "checkout": "2021-07-02",  
          "booking_date": "2021-07-01",  
          "property_key": "[METTRE PROPERTY KEY]",  
          "price": "120",  
          "nbr_adults": "2",  
          "nbr_children": "3",  
          "status": "2",  
          "email": "test@superhote.com",  
          "phone": "+33[METTRE TÉLÉPHONE]",  
          "time_in": "14:00",  
          "time_out": "15:00",  
          "cleaning": "3",  
          "city_taxes": "5",  
          "alternative_email": "test@superhote.com",  
          "zip_code": "1212",  
          "address": "Test Address",  
          "city": "Test",  
          "country": "FR",  
          "channel_id": "3",  
          "follow_up": 0  
      }*/

$json = json_encode($data);

$url = "https://app.superhote.com/api/v2/create-booking";

$ch=curl_init();  
        curl_setopt($ch, CURLOPT_POST, 1) ;  
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
        curl_setopt($ch, CURLOPT_URL, $url);  
        curl_setopt($ch, CURLOPT_POSTFIELDS, $json);  
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));   
        $result = curl_exec($ch);  
        curl_close ($ch);

return $result;

}  
    }

?>
```

---

**LIENS UTILES:**

**Nouveau** dans SuperHote ? Veuillez vous référer aux articles pour [BIEN DEMARRER AVEC SUPERHOTE](https://help.superhote.com/support/solutions/150000130871)

Vous souhaitez être contacté pour un **diagnostic stratégique gratuit** ? Réservez votre appel stratégique [en cliquant ici](https://superhote.com/appel)

Vous souhaitez voir des **démonstrations et replay de nos conférences** ? Visitez notre chaîne [Youtube](https://www.youtube.com/channel/UCGWsV5hVQp_oma9XqNz6GbQ)

Vous avez raté l'un de nos ateliers de **coaching** ? Vous pouvez [visionner les replay ici](https://help.superhote.com/support/solutions/150000122116)

Vous cherchez un sujet lié au **centre d’aide en ligne** ? Veuillez visiter notre [Help Center](https://help.superhote.com/support/home)

Vous voulez connaître les **dernières nouvelles et mises à jour** de SuperHote ? Visitez [la page officielle des nouveautés](https://help.superhote.com/support/solutions/150000130872)

**Restons connectés ?**

Visitez notre [site web](https://superhote.com/)

Suivez-nous sur [Instagram](https://www.instagram.com/matsuperhote/)

Aimez notre page sur [Facebook](https://www.facebook.com/groups/superhote/)

Abonnez-vous à notre chaine officielle [Youtube](https://www.youtube.com/channel/UCGWsV5hVQp_oma9XqNz6GbQ)

**Besoin d’en savoir plus et voir les retours d'autres clients ?**

Nous vous invitons à regarder les épisodes de notre série "**J'irai louer chez vous**" [en cliquant ici](https://www.youtube.com/watch?v=2pgfGOpls9w&list=PLbdYq7NnH1oZmA5VCTvUSeJOBTT4dYSwY)

Vous souhaitez en savoir d’avantage, contactez-nous via le chat ou sur [support@superhote.com](mailto:support@superhote.com)