# Hotel API - Search by City Name

API endpoint for this API is: `https://api.makcorps.com/citysearch`

### Guide

This API does not require a JWT token because you need your own personal API key to access this API. You can [contact us](https://share.hsforms.com/1A-iwjye2SwWRv4VHhQbBqg439wf) if you need API keys to this API.&#x20;

Here is the list of default parameters you have to use with this API:

| Parameters                                                              | Description                                                                          |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| <p>cityname<br><br><mark style="color:red;">required</mark></p>         | Name of the city                                                                     |
| <p>page<br><br><mark style="color:red;">required</mark></p>             | It is a page number. It starts with 0 and each page will provide you with 30 hotels. |
| <p>currency<br><br><mark style="color:red;">required</mark></p>         | It could be any currency like USD, INR, EUR, etc.                                    |
| <p>num\_of\_rooms<br><br><mark style="color:red;">required</mark></p>   | It is the number of rooms.                                                           |
| <p>num\_of\_adults<br><br><mark style="color:red;">required</mark></p>  | It is the number of adults.                                                          |
| <p>check\_in\_date<br><br><mark style="color:red;">required</mark></p>  | <p>It is the check-in date.<br><br>Format - YYYY-MM-DD</p>                           |
| <p>check\_out\_date<br><br><mark style="color:red;">required</mark></p> | <p>It is the check-out date.<br><br>Format - YYYY-MM-DD</p>                          |

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X GET "https://api.makcorps.com/citysearch/{cityname}/{page}/{currency}/{num_of_rooms}/{num_of_adults}/{check_in_date}/{check_out_date}?api_key=YOUR-API-KEY"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = 'https://api.makcorps.com/citysearch/{cityname}/{page}/{currency}/{num_of_rooms}/{num_of_adults}/{check_in_date}/{check_out_date}'
api_key = 'YOUR-API-KEY'

url = url.format(
    cityname='London',
    page='0',
    currency='USD',
    num_of_rooms='1',
    num_of_adults='3',
    check_in_date='2023-10-03',
    check_out_date='2023-10-04'
)

url_with_api_key = f"{url}?api_key={api_key}"

response = requests.get(url_with_api_key)

# Print the response
print(response.json())
```

{% endtab %}

{% tab title="Nodejs" %}

```javascript
const axios = require('axios');

const url = 'https://api.makcorps.com/citysearch/{cityname}/{page}/{currency}/{num_of_rooms}/{num_of_adults}/{check_in_date}/{check_out_date}';
const apiKey = 'YOUR-API-KEY';

const cityname = 'London';
const page = '0';
const currency = 'USD';
const num_of_rooms = '1';
const num_of_adults = '3';
const check_in_date = '2023-10-03';
const check_out_date = '2023-10-04';

const formattedUrl = url
  .replace('{cityname}', cityname)
  .replace('{page}', page)
  .replace('{currency}', currency)
  .replace('{num_of_rooms}', num_of_rooms)
  .replace('{num_of_adults}', num_of_adults)
  .replace('{check_in_date}', check_in_date)
  .replace('{check_out_date}', check_out_date);

const urlWithApiKey = `${formattedUrl}?api_key=${apiKey}`;

axios
  .get(urlWithApiKey)
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error(error);
  });

```

{% endtab %}
{% endtabs %}

### Response

The sample response of the API will look somewhat like this.

```json
{
                  "hotelName": "Hilton London Paddington",
                  "hotelId": "209371"
              },
              [
                  {
                      "price1": "279",
                      "tax1": "70",
                      "vendor1": "Prestigia.com"
                  },
                  {
                      "price2": "253",
                      "tax2": "51",
                      "vendor2": "eDreams"
                  },
                  {
                      "price3": "244",
                      "tax3": "48",
                      "vendor3": "Nustay.com"
                  },
                  {
                      "price4": null,
                      "tax4": null,
                      "vendor4": null
                  },
                  {
                      "price5": "253",
                      "tax5": "51",
                      "vendor5": "Tripadvisor"
                  }
              ]
          ],
          [
              {
                  "hotelName": "Park Grand London Hyde Park",
                  "hotelId": "3164384"
              },
              [
                  {
                      "price1": "263",
                      "tax1": "53",
                      "vendor1": "eDreams"
                  },
                  {
                      "price2": "263",
                      "tax2": "53",
                      "vendor2": "Booking.com"
                  },
                  {
                      "price3": "263",
                      "tax3": "53",
                      "vendor3": "Agoda.com"
                  },
                  {
                      "price4": null,
                      "tax4": null,
                      "vendor4": null
                  },
                  {
                      "price5": "263",
                      "tax5": "53",
                      "vendor5": "Tripadvisor"
                  }
              ]
          ],
          [
              {
                  "hotelName": "Park Plaza Westminster Bridge London",
                  "hotelId": "1657415"
              },
              [
                  {
                      "price1": "426",
                      "tax1": "85",
                      "vendor1": "eDreams"
                  },
                  {
                      "price2": "451",
                      "tax2": "113",
                      "vendor2": "Prestigia.com"
                  },
                  {
                      "price3": "415",
                      "tax3": "82",
                      "vendor3": "Nustay.com"
                  },
                  {
                      "price4": "455",
                      "tax4": "91",
                      "vendor4": "Agoda.com"
                  },
                  {
                      "price5": null,
                      "tax5": null,
                      "vendor5": null
                  }
              ]
          ],
          [
              {
                  "hotelName": "The Darlington Hyde Park",
                  "hotelId": "214639"
              },
              [
                  {
                      "price1": "252",
                      "tax1": "50",
                      "vendor1": "eDreams"
                  },
                  {
                      "price2": "252",
                      "tax2": "50",
                      "vendor2": "Booking.com"
                  },
                  {
                      "price3": "251",
                      "tax3": "50",
                      "vendor3": "Agoda.com"
                  },
                  {
                      "price4": null,
                      "tax4": null,
                      "vendor4": null
                  },
                  {
                      "price5": "252",
                      "tax5": "50",
                      "vendor5": "Tripadvisor"
                  }
              ]
  }
```

### Understand the Response

| Properties | Description                            |
| ---------- | -------------------------------------- |
| price      | Price offered by the vendor            |
| vendor     | Name of the vendor                     |
| tax        | Tax you will be charged at the booking |
| hotelName  | Name of the hotel                      |
| hotelId    | Id of the hotel in our system          |

{% hint style="info" %}
Each call in this pattern to our API will be counted as 1 API request. That means for every request to our API you will get 30 hotels in that target city.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hotelapi.co/hotel-api-search-by-city-name.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
