🚀 Coming soon: API v2 with nearby airports for hotels and nearby hotels for airports.

Hotels API Documentation

Access comprehensive hotel data from over 1 million properties worldwide. Our API provides GPS coordinates, ratings, amenities, and advanced search capabilities.

Fast Response

Average response time under 100ms

Global Coverage

1M+ hotels in 200+ countries

GPS Coordinates

Precise lat and lng data

Reliable

99.9% uptime SLA

Authentication

All API requests require authentication using an API key. Include your API key in the X-API-KEY header.

Get Your API Key

Sign up for a free account to get your API key: Create Account

Example Request
curl -H "X-API-KEY: your_api_key_here" \
  "https://api.hotels-api.com/v1/hotels/search?city=Madrid"

Quick Start

Get started with the Hotels API in minutes. Here's a simple example to search for hotels in a city:

cURL
curl -X GET "https://api.hotels-api.com/v1/hotels/search?city=Madrid&limit=10" \
  -H "X-API-KEY: your_api_key_here"
JavaScript (Fetch API)
const apiKey = 'your_api_key_here';
const baseURL = 'https://api.hotels-api.com/v1';

async function searchHotels(city) {
  const response = await fetch(`${baseURL}/hotels/search?city=${city}&limit=10`, {
    method: 'GET',
    headers: {
      'X-API-KEY': apiKey
    }
  });
  
  const data = await response.json();
  
  if (data.success) {
    console.log('Hotels found:', data.data.length);
    data.data.forEach(hotel => {
      console.log(`${hotel.name} - ${hotel.city}, ${hotel.country}`);
    });
  } else {
    console.error('Error:', data.error);
  }
}

searchHotels('Madrid');
Python (requests)
import requests

API_KEY = 'your_api_key_here'
BASE_URL = 'https://api.hotels-api.com/v1'

def search_hotels(city, limit=10):
    headers = {
        'X-API-KEY': API_KEY
    }
    
    params = {
        'city': city,
        'limit': limit
    }
    
    response = requests.get(
        f'{BASE_URL}/hotels/search',
        headers=headers,
        params=params
    )
    
    data = response.json()
    
    if data['success']:
        print(f"Hotels found: {len(data['data'])}")
        for hotel in data['data']:
            print(f"{hotel['name']} - {hotel['city']}, {hotel['country']}")
    else:
        print(f"Error: {data['error']}")

# Example usage
search_hotels('Madrid')
PHP (cURL)
<?php

$apiKey = 'your_api_key_here';
$baseURL = 'https://api.hotels-api.com/v1';

function searchHotels($city, $limit = 10) {
    global $apiKey, $baseURL;
    
    $url = $baseURL . '/hotels/search?' . http_build_query([
        'city' => $city,
        'limit' => $limit
    ]);
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'X-API-KEY: ' . $apiKey
    ]);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    $data = json_decode($response, true);
    
    if ($data['success']) {
        echo "Hotels found: " . count($data['data']) . "\n";
        foreach ($data['data'] as $hotel) {
            echo "{$hotel['name']} - {$hotel['city']}, {$hotel['country']}\n";
        }
    } else {
        echo "Error: " . $data['error'] . "\n";
    }
}

// Example usage
searchHotels('Madrid');

?>

Base URL

All API requests should be made to:

https://api.hotels-api.com/v1

Response Format

All API responses are returned in JSON format with a consistent structure:

Success Response

200 OK
{
  "success": true,
  "data": [...],
  "message": null,
  "timestamp": 1768924228
}

Error Response

400 Bad Request
{
  "success": false,
  "error": "City parameter is required"
}

Response Fields

Field Type Description
success boolean Indicates if the request was successful
data array Array of hotel objects (on success)
error string Error message (on failure)
message string|null Additional message information
timestamp integer Unix timestamp of the response

Error Codes

The API uses standard HTTP status codes to indicate success or failure:

Code Status Description
200 OK Request succeeded
400 Bad Request Invalid parameters or missing required fields
401 Unauthorized Invalid or missing API key
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Something went wrong on our end

Rate Limits

API rate limits depend on your subscription plan:

Starter (Free)

500

requests/month

Business

1,500,000

requests/month

Enterprise

Custom

unlimited requests

Rate Limit Headers

Each response includes headers showing your current usage and limits

Search Hotels

Search for hotels using flexible filters like city, country, name, or rating.

GET /hotels/search

Query Parameters

Parameter Type Required Description
city string Optional City name to search
country string Optional Country name to search
country_code string Optional ISO 3166-1 alpha-2 country code (e.g., "ES", "US")
name string Optional Search by hotel name (partial match)
rating integer Optional Filter by exact star rating (0-5)
min_rating integer Optional Filter by minimum star rating (0-5)
limit integer Optional Number of results (default: 20, max: 500)
page integer Optional Page number for pagination (default: 1)

Example Request

Request
curl -X GET "https://api.hotels-api.com/v1/hotels/search?city=Madrid&limit=5" \\\n  -H "X-API-KEY: your_api_key_here"

Hotel Object Fields

Field Type Description
id integer Unique hotel identifier
name string Hotel name
city string City name
country string Country name
country_code string ISO 3166-1 alpha-2 country code (e.g., "ES", "US")
address string Full street address
rating integer Star rating (0-5)
lat float GPS lat coordinate
lng float GPS lng coordinate
amenities array List of available amenities (e.g., "wifi", "parking", "pool")

Example Response

200 OK
{
  "success": true,
  "data": [
    {
      "id": 698731,
      "name": "NH Collection Madrid Abascal",
      "city": "Madrid",
      "country": "Spain",
      "country_code": "ES",
      "address": "José Abascal 47 28003 Madrid",
      "rating": 4,
      "lat": 40.438236,
      "lng": -3.695222,
      "amenities": ["bar", "free_wifi", "front_desk_24h", "gym", "parking", "spa"]
    },
    {
      "id": 698733,
      "name": "Hyatt Regency Hesperia Madrid",
      "city": "Madrid",
      "country": "Spain",
      "country_code": "ES",
      "address": "Paseo Castellana 57 28046 Madrid",
      "rating": 5,
      "lat": 40.438854,
      "lng": -3.69141,
      "amenities": ["airport_shuttle", "bar", "free_wifi", "gym", "restaurant", "spa"]
    }
  ],
  "message": null,
  "timestamp": 1768924228
}

Search Hotels

The /hotels/search endpoint supports multiple filter combinations. You can search by city, country, country code, hotel name, or rating.

Common Use Cases

  • Search by city: ?city=Madrid
  • Search by country: ?country=Spain
  • Search by country code: ?country_code=ES
  • Search hotels with minimum rating: ?city=Madrid&min_rating=4
  • Search by name: ?name=Hilton
  • Combine filters: ?country=Spain&min_rating=5&limit=10
Flexible Filtering

All parameters are optional. You can combine multiple filters to narrow down your search results.

Nearby Hotels (Geo Search)

Find hotels near specific GPS coordinates.

Pro Feature

Geo search is available on Pro, Business, and Enterprise plans.

GET /hotels/nearby

Query Parameters

Parameter Type Required Description
lat float Required lat coordinate
lng float Required lng coordinate
radius integer Optional Search radius in kilometers (default: 10, max: 500)
limit integer Optional Number of results (default: 20, max: 500)

Example Request

Request
curl -X GET "https://api.hotels-api.com/v1/hotels/nearby?lat=40.4168&lng=-3.7038&radius=5&limit=10" \
  -H "X-API-KEY: your_api_key_here"

Example Response

200 OK
{
  "success": true,
  "data": [
    {
      "id": 698752,
      "name": "Insignia Hotel Dosa",
      "city": "Madrid",
      "country": "Spain",
      "country_code": "ES",
      "address": "C/ De las Heras 96-98 28723 Pedrezuela Madrid",
      "rating": 3,
      "lat": 40.4167754,
      "lng": -3.7037902,
      "amenities": ["parking", "wheelchair_access", "pets_allowed"]
    },
    {
      "id": 698818,
      "name": "Hostal Victoria I",
      "city": "Madrid",
      "country": "Spain",
      "country_code": "ES",
      "address": "Carretas 7 2º 2 Floor 28012 Madrid",
      "rating": 0,
      "lat": 40.41635,
      "lng": -3.70319,
      "amenities": ["air_conditioning", "free_wifi", "front_desk_24h"]
    }
  ],
  "message": null,
  "timestamp": 1768924239
}

Code Examples

JavaScript (Node.js with Axios)

hotels-api.js
const axios = require('axios');

class HotelsAPI {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.baseURL = 'https://api.hotels-api.com/v1';
  }

  async searchByCity(city, options = {}) {
    try {
      const response = await axios.get(`${this.baseURL}/hotels/search`, {
        headers: {
          'X-API-KEY': this.apiKey
        },
        params: {
          city,
          limit: options.limit || 20,
          page: options.page || 1
        }
      });
      return response.data;
    } catch (error) {
      console.error('Error:', error.response?.data || error.message);
      throw error;
    }
  }

  async findNearby(lat, lng, radius = 10) {
    try {
      const response = await axios.get(`${this.baseURL}/hotels/nearby`, {
        headers: {
          'X-API-KEY': this.apiKey
        },
        params: { lat, lng, radius }
      });
      return response.data;
    } catch (error) {
      console.error('Error:', error.response?.data || error.message);
      throw error;
    }
  }
}

// Usage
const api = new HotelsAPI('your_api_key_here');

// Search hotels in Madrid
api.searchByCity('Madrid', { limit: 10 })
  .then(data => {
    console.log(`Found ${data.data.length} hotels`);
    data.data.forEach(hotel => {
      console.log(`- ${hotel.name} (${hotel.rating}⭐)`);
    });
  });

// Find nearby hotels
api.findNearby(40.4168, -3.7038, 5)
  .then(data => {
    console.log(`Found ${data.data.length} hotels within 5km`);
  });

Python Class Implementation

hotels_api.py
import requests
from typing import Optional, Dict, List

class HotelsAPI:
    def __init__(self, api_key: str):
        self.api_key = api_key
        self.base_url = 'https://api.hotels-api.com/v1'
        self.headers = {'X-API-KEY': api_key}
    
    def search_by_city(self, city: str, limit: int = 20, page: int = 1) -> Dict:
        """Search hotels by city name"""
        params = {
            'city': city,
            'limit': limit,
            'page': page
        }
        
        response = requests.get(
            f'{self.base_url}/hotels/search',
            headers=self.headers,
            params=params
        )
        response.raise_for_status()
        return response.json()
    
    def find_nearby(self, lat: float, lng: float, radius: int = 10, limit: int = 20) -> Dict:
        """Find hotels near GPS coordinates"""
        params = {
            'lat': lat,
            'lng': lng,
            'radius': radius,
            'limit': limit
        }
        
        response = requests.get(
            f'{self.base_url}/hotels/nearby',
            headers=self.headers,
            params=params
        )
        response.raise_for_status()
        return response.json()

# Usage example
if __name__ == '__main__':
    api = HotelsAPI('your_api_key_here')
    
    # Search hotels in Madrid
    result = api.search_by_city('Madrid', limit=10)
    if result['success']:
        print(f"Found {len(result['data'])} hotels")
        for hotel in result['data']:
            print(f"- {hotel['name']} ({hotel['rating']}⭐)")
    
    # Find nearby hotels
    nearby = api.find_nearby(40.4168, -3.7038, radius=5)
    if nearby['success']:
        print(f"\nFound {len(nearby['data'])} hotels within 5km")

PHP Class Implementation

HotelsAPI.php
<?php

class HotelsAPI {
    private $apiKey;
    private $baseURL;
    
    public function __construct($apiKey) {
        $this->apiKey = $apiKey;
        $this->baseURL = 'https://api.hotels-api.com/v1';
    }
    
    private function makeRequest($endpoint, $params = []) {
        $url = $this->baseURL . $endpoint;
        
        if (!empty($params)) {
            $url .= '?' . http_build_query($params);
        }
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
            'X-API-KEY: ' . $this->apiKey
        ]);
        
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        
        if ($httpCode !== 200) {
            throw new Exception("API request failed with code $httpCode");
        }
        
        return json_decode($response, true);
    }
    
    public function searchByCity($city, $limit = 20, $page = 1) {
        return $this->makeRequest('/hotels/search', [
            'city' => $city,
            'limit' => $limit,
            'page' => $page
        ]);
    }
    
    public function findNearby($lat, $lng, $radius = 10, $limit = 20) {
        return $this->makeRequest('/hotels/nearby', [
            'lat' => $lat,
            'lng' => $lng,
            'radius' => $radius,
            'limit' => $limit
        ]);
    }
}

// Usage example
$api = new HotelsAPI('your_api_key_here');

// Search hotels
$result = $api->searchByCity('Madrid', 10);
if ($result['success']) {
    echo "Found " . count($result['data']) . " hotels\n";
    foreach ($result['data'] as $hotel) {
        echo "- {$hotel['name']} ({$hotel['rating']}⭐)\n";
    }
}

// Find nearby
$nearby = $api->findNearby(40.4168, -3.7038, 5);
if ($nearby['success']) {
    echo "\nFound " . count($nearby['data']) . " hotels within 5km\n";
}

?>