openapi: 3.0.0
info:
  title: Yellow Pages Search API
  description: >-
    Search US businesses on Yellow Pages by search term and location. Each result has its place_id, name, categories,
    phone, address, website, open state, opening hours, Yellow Pages and Tripadvisor ratings, years in business and
    the listing's own offers and links. The response also has the ads Yellow Pages shows with the results, the filter
    facets of the search with the token each option takes in the filters parameter, related categories and the next
    page. Yellow Pages shows 30 results per page and up to 100 pages. Pass a result's place_id to the Yellow Pages
    Place API to get the full business page with its reviews.
  version: 1.0.0
servers:
- url: https://www.searchapi.io/api/v1
paths:
  "/search":
    get:
      summary: Yellow Pages Search
      security:
      - ApiKeyAuth: []
      - ApiKeyQuery: []
      parameters:
      - name: engine
        in: query
        required: true
        description: Set to yellowpages_search.
        schema:
          type: string
          enum: ["yellowpages_search"]
      - name: q
        in: query
        required: true
        description: Search term, such as a business type, a cuisine or a business name. HTML tags are not accepted.
        schema:
          type: string
      - name: location
        in: query
        required: true
        description: US city and state, ZIP code, neighborhood or state to search in. HTML tags are not accepted.
        schema:
          type: string
      - name: sort_by
        in: query
        required: false
        description: Order of the results.
        schema:
          type: string
          enum: ["relevance", "distance", "highest_rating", "name"]
          default: "relevance"
      - name: category
        in: query
        required: false
        description: Category to narrow the results to, as a title from the Category filter.
        schema:
          type: string
      - name: price
        in: query
        required: false
        description: Price levels from 1 to 4, comma-separated, to narrow restaurant results to.
        schema:
          type: string
          pattern: "^[1-4](,[1-4])*$"
      - name: neighborhood
        in: query
        required: false
        description: Neighborhood to narrow the results to, as a title from the Neighborhoods filter.
        schema:
          type: string
      - name: filters
        in: query
        required: false
        description: >-
          Comma-separated filter tokens from the value of the response's filters options. Options of one filter match
          any of them, and different filters must all match.
        schema:
          type: string
      - name: is_open_24_hours
        in: query
        required: false
        description: Set to true to return only businesses open 24 hours.
        schema:
          type: boolean
      - name: page
        in: query
        required: false
        description: Page of results, 30 per page.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 1
      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"
        search_information:
          "$ref": "#/components/schemas/SearchInformation"
        ads:
          type: array
          description: Ads Yellow Pages shows above the results and in the right rail.
          items:
            "$ref": "#/components/schemas/Ad"
        local_results:
          type: array
          description: Businesses matching the search, in the order of the page.
          items:
            "$ref": "#/components/schemas/LocalResult"
        filters:
          type: array
          description: Filter facets of the search.
          items:
            "$ref": "#/components/schemas/Filter"
        related_categories:
          type: array
          description: Categories related to the search.
          items:
            "$ref": "#/components/schemas/Category"
        pagination:
          "$ref": "#/components/schemas/Pagination"
        error:
          type: string
          description: Message returned instead of results when nothing matches the search or the location is unknown.
    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: Yellow Pages 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
          enum: ["yellowpages_search"]
          description: Set to yellowpages_search.
        q:
          type: string
          description: Search term.
        location:
          type: string
          description: Location searched in.
        sort_by:
          type: string
          enum: ["relevance", "distance", "highest_rating", "name"]
          description: Order of the results.
        category:
          type: string
          description: Category the results are narrowed to.
        price:
          type: string
          pattern: "^[1-4](,[1-4])*$"
          description: Price levels the results are narrowed to.
        neighborhood:
          type: string
          description: Neighborhood the results are narrowed to.
        filters:
          type: string
          description: Filter tokens applied.
        is_open_24_hours:
          type: string
          enum: ["true", "false"]
          description: Whether only businesses open 24 hours were asked for.
        page:
          type: integer
          description: Page of results.
    SearchInformation:
      type: object
      required:
      - query_displayed
      - location_displayed
      - location
      properties:
        query_displayed:
          type: string
          description: Search term Yellow Pages searched for.
        location_displayed:
          type: string
          description: Location Yellow Pages searched in, as it names it.
        total_results:
          type: integer
          description: Number of results Yellow Pages reports for the search, an estimate that can change between pages.
        location:
          "$ref": "#/components/schemas/Location"
    Location:
      type: object
      required:
      - type
      - state
      - gps_coordinates
      properties:
        type:
          type: string
          description: Kind of place the location resolved to, such as city, zip, neighborhood or state.
        neighborhood:
          type: string
          description: Neighborhood the location resolved to.
        city:
          type: string
          description: City the location resolved to.
        state:
          type: string
          description: Two-letter state code of the location.
        postal_code:
          type: string
          description: ZIP code the location resolved to.
        gps_coordinates:
          "$ref": "#/components/schemas/GpsCoordinates"
    GpsCoordinates:
      type: object
      required:
      - latitude
      - longitude
      properties:
        latitude:
          type: number
          description: Latitude of the center of the location.
        longitude:
          type: number
          description: Longitude of the center of the location.
    LocalResult:
      type: object
      required:
      - position
      - place_id
      - title
      - link
      properties:
        position:
          type: integer
          description: Position of the result on the page, starting at 1.
        place_id:
          type: string
          description: Numeric id of the business on Yellow Pages, the place_id of the Yellow Pages Place API.
        title:
          type: string
          description: Name of the business.
        link:
          type: string
          description: Yellow Pages page of the business.
        categories:
          type: array
          description: Yellow Pages categories of the business.
          items:
            "$ref": "#/components/schemas/Category"
        rating:
          type: number
          description: Average Yellow Pages rating, from 1 to 5.
        reviews:
          type: integer
          description: Number of Yellow Pages reviews.
        web_reviews:
          type: array
          description: Ratings of the business on other review sites.
          items:
            "$ref": "#/components/schemas/WebReview"
        phone:
          type: string
          description: Main phone number.
        address:
          type: string
          description: Address as the page shows it.
        street_address:
          type: string
          description: Street line of the address.
        city:
          type: string
          description: City of the business.
        state:
          type: string
          description: Two-letter state code of the business.
        postal_code:
          type: string
          description: ZIP code of the business.
        website:
          type: string
          description: Website of the business.
        open_state:
          type: string
          description: Whether the business is open at the time of the search, as the page words it.
        opening_hours:
          type: array
          description: Opening hours in schema.org format, such as Mo-Fr 08:00-17:00.
          items:
            type: string
        years_in_business:
          type: integer
          description: Number of years the business has operated.
        years_with_yp:
          type: integer
          description: Number of years the business has advertised with Yellow Pages.
        price:
          type: string
          description: Price level of the business, from $ to $$$$.
        amenities:
          type: array
          description: Amenities the result shows, such as wheelchair access.
          items:
            type: string
        description:
          type: string
          description: Excerpt of the business's own description.
        review_snippet:
          type: string
          description: Excerpt of a review of the business.
        links:
          type: array
          description: The listing's own links, such as coupons, special offers or a video.
          items:
            "$ref": "#/components/schemas/Link"
        special_offer:
          "$ref": "#/components/schemas/Offer"
        coupon:
          "$ref": "#/components/schemas/Offer"
        distance:
          type: string
          description: Distance from the searched location, as the page shows it.
        extracted_distance:
          type: number
          description: Distance from the searched location as a number.
        thumbnail:
          type: string
          description: Photo of the business.
        is_paid_listing:
          type: boolean
          description: Whether the business pays Yellow Pages for higher placement in the default order.
    Ad:
      type: object
      required:
      - position
      - block
      - place_id
      - title
      - link
      properties:
        position:
          type: integer
          description: Position of the ad within its block, starting at 1.
        block:
          type: string
          enum: ["top", "bottom", "right"]
          description: Where the ad is shown, above the results, below them or in the right rail.
        place_id:
          type: string
          description: Numeric id of the business on Yellow Pages, the place_id of the Yellow Pages Place API.
        title:
          type: string
          description: Name of the business.
        link:
          type: string
          description: Yellow Pages page of the business.
        categories:
          type: array
          description: Yellow Pages categories of the business.
          items:
            "$ref": "#/components/schemas/Category"
        rating:
          type: number
          description: Average Yellow Pages rating, from 1 to 5.
        reviews:
          type: integer
          description: Number of Yellow Pages reviews.
        phone:
          type: string
          description: Main phone number.
        address:
          type: string
          description: Address as the ad shows it.
        street_address:
          type: string
          description: Street line of the address.
        city:
          type: string
          description: City of the business.
        state:
          type: string
          description: Two-letter state code of the business.
        postal_code:
          type: string
          description: ZIP code of the business.
        website:
          type: string
          description: Website of the business.
        opening_hours:
          type: array
          description: Opening hours in schema.org format, such as Mo-Fr 08:00-17:00.
          items:
            type: string
        years_in_business:
          type: integer
          description: Number of years the business has operated.
        links:
          type: array
          description: The ad's own links, such as coupons, special offers or a video.
          items:
            "$ref": "#/components/schemas/Link"
        slogan:
          type: string
          description: Slogan the ad shows.
        thumbnail:
          type: string
          description: Photo of the business.
    Category:
      type: object
      required:
      - title
      - link
      properties:
        title:
          type: string
          description: Name of the category.
        link:
          type: string
          description: Yellow Pages page of the category in a city.
    WebReview:
      type: object
      required:
      - title
      - rating
      properties:
        title:
          type: string
          description: Name of the review site.
        rating:
          type: number
          description: Average rating on that site, from 1 to 5.
        reviews:
          type: integer
          description: Number of reviews on that site.
    Link:
      type: object
      required:
      - title
      - link
      properties:
        title:
          type: string
          description: Text of the link.
        link:
          type: string
          description: Address the link points to.
    Offer:
      type: object
      properties:
        text:
          type: string
          description: Text of the offer.
        link:
          type: string
          description: Page of the offer.
    Filter:
      type: object
      required:
      - options
      properties:
        title:
          type: string
          description: Name of the filter, such as Category, Price or Neighborhoods.
        options:
          type: array
          description: Options of the filter.
          items:
            "$ref": "#/components/schemas/FilterOption"
    FilterOption:
      type: object
      required:
      - value
      properties:
        title:
          type: string
          description: Name of the option.
        value:
          type: string
          description: Token that applies the option in the filters parameter.
        count:
          type: integer
          description: Number of results Yellow Pages estimates for the option.
        is_selected:
          type: boolean
          description: Whether the search applied the option.
    Pagination:
      type: object
      required:
      - current
      properties:
        current:
          type: integer
          description: Page Yellow Pages served.
        next:
          type: string
          description: Yellow Pages URL of the next page.
    ErrorResponse:
      type: object
      required:
      - error
      properties:
        error:
          type: string
          description: Error message describing what went wrong
