openapi: 3.0.0
info:
  title: Google Hotels Photos API
  description: |
    The Google Hotels Photos API returns the photo gallery of a hotel or vacation rental on Google Hotels, with its photo categories, filters by category, source and media type, and pagination through the gallery.

    Each photo comes with its thumbnail, full-size image, media type (photo, video or 360) and source (owner, visitor, partner site or Google Street View). Its original dimensions, contributor or partner listing, posted date and the property location Google attaches to it come when Google has them.

    The first page also lists the property's photo categories and, for hotels, the owner, visitor and 360 totals. These totals are the counts Google displays for the property. A gallery or category can end before its total, so page until `pagination.next_page_token` is absent.

    **Cross-linking**: Pass the `property_token` returned by the Google Hotels API (`properties[].property_token`, hotels and vacation rentals) or the Google Hotels Property API (`property.property_token`) as the `property_token` parameter. The `category_id` values returned in `categories` can be passed back as the `category_id` parameter.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Google Hotels Photos Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Must be set to google_hotels_photos
          schema:
            type: string
            enum: ["google_hotels_photos"]
        - name: property_token
          in: query
          required: true
          description: Token of the hotel or vacation rental, from Google Hotels API results (hotels and vacation rentals) or the Google Hotels Property API
          schema:
            type: string
            pattern: "^[A-Za-z0-9_-]{1,64}$"
            maxLength: 64
        - name: category_id
          in: query
          required: false
          description: Photo category to return, from categories[].category_id
          schema:
            type: string
            enum: ["1", "6", "8", "5", "22", "3", "4"]
        - name: source
          in: query
          required: false
          description: Return only the photos posted by the property's owner or by its visitors
          schema:
            type: string
            enum: ["owner", "visitor"]
        - name: media_type
          in: query
          required: false
          description: Return only still photos or only 360 photos
          schema:
            type: string
            enum: ["photo", "360"]
        - name: num
          in: query
          required: false
          description: Number of photos per page
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: next_page_token
          in: query
          required: false
          description: Token for the next page of photos, from pagination.next_page_token
          schema:
            type: string
            pattern: "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
            maxLength: 8449
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchResponse"
        "400":
          description: Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "503":
          description: Timeout. We could not retrieve results in 90 seconds.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          $ref: "#/components/schemas/SearchMetadata"
        search_parameters:
          $ref: "#/components/schemas/SearchParameters"
        categories:
          type: array
          description: Photo categories of the property, counted for the requested source and media type
          items:
            $ref: "#/components/schemas/Category"
        sources:
          type: array
          description: Photo counts of the whole gallery by who posted the photos
          items:
            $ref: "#/components/schemas/Source"
        media_types:
          type: array
          description: Number of 360 photos in the whole gallery
          items:
            $ref: "#/components/schemas/MediaType"
        photos:
          type: array
          description: Photos of the property, in the order Google shows them
          items:
            $ref: "#/components/schemas/Photo"
        pagination:
          $ref: "#/components/schemas/Pagination"
        error:
          type: string
          description: Error message explaining why no photos were returned
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: "Unique identifier for the search request"
        status:
          type: string
          description: "Status of the search request"
        created_at:
          type: string
          format: date-time
          description: "Timestamp when the search was created"
        request_time_taken:
          type: number
          description: "Time taken to make the request in seconds"
        parsing_time_taken:
          type: number
          description: "Time taken to parse the results in seconds"
        total_time_taken:
          type: number
          description: "Total time taken for the search in seconds"
        request_url:
          type: string
          description: "Google Hotels Photos URL for this search"
        html_url:
          type: string
          description: "URL to view HTML results"
        json_url:
          type: string
          description: "URL to view JSON results"
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Engine used for the search
        property_token:
          type: string
          description: Token of the property whose photos were returned
        category_id:
          type: string
          description: Photo category used for the search
        source:
          type: string
          description: Source filter used for the search
        media_type:
          type: string
          description: Media type filter used for the search
        num:
          type: integer
          description: Number of photos per page
        next_page_token:
          type: string
          description: Token of the page that was returned
    Category:
      type: object
      required: [category_id, title, total, thumbnail]
      properties:
        category_id:
          type: string
          enum: ["1", "6", "8", "5", "22", "3", "4"]
          description: ID of the category, accepted by the category_id parameter
        title:
          type: string
          description: Name of the category
        total:
          type: integer
          description: Number of photos Google displays for the category, a capped count on very large galleries
        thumbnail:
          type: string
          description: URL of the category's cover photo
    Source:
      type: object
      required: [source, total, thumbnail]
      properties:
        source:
          type: string
          enum: ["owner", "visitor"]
          description: Who posted the photos, accepted by the source parameter
        total:
          type: integer
          description: Number of photos Google displays for this source
        thumbnail:
          type: string
          description: URL of a cover photo for this source
    MediaType:
      type: object
      required: [media_type, total, thumbnail]
      properties:
        media_type:
          type: string
          enum: ["360"]
          description: Media type of the photos, accepted by the media_type parameter
        total:
          type: integer
          description: Number of photos Google displays for this media type
        thumbnail:
          type: string
          description: URL of a cover photo for this media type
    Photo:
      type: object
      required: [position, media_type, source, thumbnail, original]
      properties:
        position:
          type: integer
          description: Position of the photo in the gallery
        photo_id:
          type: string
          description: ID of the photo or video, accepted by the Google Maps Photo Meta API
        media_type:
          type: string
          enum: ["photo", "video", "360"]
          description: Media type of the item
        source:
          type: string
          enum: ["owner", "visitor", "partner", "google"]
          description: Who posted the photo, where partner is a booking or listing site and google is Google Street View
        description:
          type: string
          description: Caption of the photo
        thumbnail:
          type: string
          description: URL of the photo's thumbnail
        original:
          type: string
          description: URL of the full-size image
        video:
          type: string
          description: Short-lived URL of the highest-resolution video file
        width:
          type: integer
          description: Width of the original photo in pixels
        height:
          type: integer
          description: Height of the original photo in pixels
        user:
          $ref: "#/components/schemas/User"
        partner:
          $ref: "#/components/schemas/Partner"
        date:
          type: string
          format: date
          description: Date the photo was posted, in YYYY-MM-DD format
        capture_date:
          type: string
          description: Date the photo was taken, in YYYY-MM-DD or YYYY-MM format
        gps_coordinates:
          $ref: "#/components/schemas/GPSCoordinates"
    User:
      type: object
      required: [name, link, contributor_id, thumbnail]
      properties:
        name:
          type: string
          description: Name of the contributor who posted the photo
        link:
          type: string
          description: URL of the contributor's Google Maps profile
        contributor_id:
          type: string
          description: Google Maps contributor ID of the user
        thumbnail:
          type: string
          description: URL of the contributor's profile picture
        is_owner:
          type: boolean
          description: Whether the property's owner posted the photo
    Partner:
      type: object
      required: [name]
      properties:
        name:
          type: string
          description: Name of the site the photo comes from
        link:
          type: string
          description: URL of the property's page on that site
    GPSCoordinates:
      type: object
      required: [latitude, longitude]
      properties:
        latitude:
          type: number
          description: Latitude of the property location Google attaches to the photo
        longitude:
          type: number
          description: Longitude of the property location Google attaches to the photo
    Pagination:
      type: object
      properties:
        next_page_token:
          type: string
          description: Token to pass as next_page_token for the next page of photos
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
