openapi: 3.0.0
info:
  title: Bing Images API
  description: |
    Bing Images API allows you to search for images on Bing. You can filter by size, color, type, usage rights, aspect ratio, and other criteria to find relevant images.

    **Cross-linking**: The images returned by this API contain direct links to the original images and source pages. No additional API calls are needed to access the images.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Bing Images Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Set to bing_images
          schema:
            type: string
            enum: ["bing_images"]
        - name: q
          in: query
          required: true
          description: Search query
          schema:
            type: string
        - name: device
          in: query
          required: false
          description: Device type for search results
          schema:
            type: string
            enum: ["desktop", "mobile", "tablet"]
            default: "desktop"
        - name: market_code
          in: query
          required: false
          description: Market code combining language and country (e.g., en-US, fr-FR)
          schema:
            type: string
            enum: ["es-ar", "en-au", "de-at", "nl-be", "fr-be", "pt-br", "en-ca", "fr-ca", "es-cl", "da-dk", "fi-fi", "fr-fr", "de-de", "zh-hk", "en-in", "en-id", "it-it", "ja-jp", "ko-kr", "en-my", "es-mx", "nl-nl", "en-nz", "no-no", "zh-cn", "pl-pl", "en-ph", "ru-ru", "en-za", "es-es", "sv-se", "fr-ch", "de-ch", "zh-tw", "tr-tr", "en-gb", "en-us", "es-us"]
        - name: country_code
          in: query
          required: false
          description: Country code (ISO 3166-1 alpha-2)
          schema:
            type: string
            enum: ["AR", "AU", "AT", "BE", "BR", "CA", "CL", "DK", "FI", "FR", "DE", "HK", "IN", "ID", "IT", "JP", "KR", "MY", "MX", "NL", "NZ", "NO", "PL", "PT", "PH", "RU", "SA", "ZA", "ES", "SE", "CH", "TW", "TR", "GB", "US", "CN"]
            default: "US"
        - name: language
          in: query
          required: false
          description: Language code for search results interface
          schema:
            type: string
            enum: ["ar", "eu", "bn", "bg", "ca", "zh-hans", "zh-hant", "hr", "cs", "da", "nl", "en", "en-gb", "et", "fi", "fr", "gl", "de", "gu", "he", "hi", "hu", "is", "it", "jp", "kn", "ko", "lv", "lt", "ms", "ml", "mr", "nb", "pl", "pt-br", "pt-pt", "pa", "ro", "ru", "sr", "sk", "sl", "es", "sv", "ta", "te", "th", "tr", "uk", "vi"]
        - name: safe_search
          in: query
          required: false
          description: SafeSearch setting for filtering adult content
          schema:
            type: string
            enum: ["off", "moderate", "strict"]
            default: "moderate"
        - name: size
          in: query
          required: false
          description: Filter images by size category
          schema:
            type: string
            enum: ["small", "medium", "large", "extra_large"]
        - name: min_size
          in: query
          required: false
          description: 'Minimum image dimensions in format "WidthxHeight" (e.g., "800x600")'
          schema:
            type: string
            pattern: '^\d+x\d+$'
        - name: color
          in: query
          required: false
          description: Filter images by color
          schema:
            type: string
            enum: ["black_and_white", "color", "red", "orange", "yellow", "green", "teal", "blue", "purple", "pink", "brown", "black", "gray", "white"]
        - name: image_type
          in: query
          required: false
          description: Filter images by type
          schema:
            type: string
            enum: ["clipart", "line_drawing", "gif", "photo", "transparent", "face", "head_and_shoulders"]
        - name: time_period
          in: query
          required: false
          description: Filter images by time period
          schema:
            type: string
            enum: ["last_day", "last_week", "last_month", "last_year"]
        - name: usage_rights
          in: query
          required: false
          description: Filter images by usage rights
          schema:
            type: string
            enum: ["public_domain", "creative_commons_licenses", "free_to_share_and_use", "free_to_share_and_use_commercial", "free_to_modify_share_and_use", "free_to_modify_share_and_use_commercial"]
        - name: aspect_ratio
          in: query
          required: false
          description: Filter images by aspect ratio
          schema:
            type: string
            enum: ["square", "wide", "tall"]
        - name: page
          in: query
          required: false
          description: Page number for pagination (1-indexed)
          schema:
            type: integer
            minimum: 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'
        suggestions:
          type: array
          items:
            $ref: '#/components/schemas/Suggestion'
        shopping_ads:
          type: array
          items:
            $ref: '#/components/schemas/ShoppingAd'
        images:
          type: array
          items:
            $ref: '#/components/schemas/Image'
        related_searches:
          type: array
          items:
            $ref: '#/components/schemas/RelatedSearch'
    SearchMetadata:
      type: object
      required: [id, 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: Bing Images 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: Search engine used
        q:
          type: string
          description: Search query
        device:
          type: string
          description: Device type used
        country_code:
          type: string
          description: Country code used
        market_code:
          type: string
          description: Market code used
        language:
          type: string
          description: Language used
        safe_search:
          type: string
          description: SafeSearch setting used
        size:
          type: string
          description: Size filter used
        color:
          type: string
          description: Color filter used
        image_type:
          type: string
          description: Image type filter used
        time_period:
          type: string
          description: Time period filter used
        usage_rights:
          type: string
          description: Usage rights filter used
        aspect_ratio:
          type: string
          description: Aspect ratio filter used
        min_size:
          type: string
          description: Minimum size filter used
        page:
          type: integer
          description: Page number
    SearchInformation:
      type: object
      properties:
        query_displayed:
          type: string
          description: Query displayed in the search box
        did_you_mean:
          type: string
          description: Alternative query suggestion
        including_results_for:
          type: string
          description: Autocorrected search query
        safe_search:
          type: string
          description: SafeSearch status displayed on the page
    Suggestion:
      type: object
      required: [title, link, thumbnail]
      properties:
        title:
          type: string
          description: Title of the suggestion
        link:
          type: string
          description: Link to the suggested search
        thumbnail:
          type: string
          description: Thumbnail image for the suggestion
    ShoppingAd:
      type: object
      required: [position, title, link, price, extracted_price, seller]
      properties:
        position:
          type: integer
          description: Position in the shopping ads list
        title:
          type: string
          description: Product title
        seller:
          type: string
          description: Seller name
        link:
          type: string
          description: Link to the product
        deal:
          type: string
          description: Deal information
        price:
          type: string
          description: Display price
        extracted_price:
          type: number
          description: Extracted numeric price value
        original_price:
          type: string
          description: Original price before discount
        extracted_original_price:
          type: number
          description: Extracted numeric original price value
        installment:
          type: object
          properties:
            down_payment:
              type: string
              description: Down payment amount
            extracted_down_payment:
              type: number
              description: Extracted numeric down payment value
            months:
              type: string
              description: Number of months
            extracted_months:
              type: integer
              description: Extracted numeric months value
            cost_per_month:
              type: string
              description: Cost per month
            extracted_cost_per_month:
              type: number
              description: Extracted numeric monthly cost value
        rating:
          type: number
          description: Product rating
        reviews:
          type: integer
          description: Number of reviews
        reviews_link:
          type: string
          description: Link to reviews
        delivery_price:
          type: string
          description: Delivery price
        extracted_delivery_price:
          type: number
          description: Extracted numeric delivery price value
        image:
          type: string
          description: Single product image (when only one image)
        images:
          type: array
          items:
            type: string
          description: Multiple product images (when multiple images)
    Image:
      type: object
      required: [position, title, source, original, thumbnail]
      properties:
        position:
          type: integer
          description: Position in the image results
        title:
          type: string
          description: Image title
        source:
          type: object
          required: [name, link]
          properties:
            name:
              type: string
              description: Source website name
            link:
              type: string
              description: Link to the source page
        original:
          type: object
          required: [link, width, height]
          properties:
            link:
              type: string
              description: Direct link to the original image
            width:
              type: string
              description: Original image width
            height:
              type: string
              description: Original image height
        tag:
          type: string
          description: Image tag (e.g., "GIF")
        thumbnail:
          type: string
          description: Thumbnail image URL
        related_thumbnails:
          type: array
          items:
            type: string
          description: Related thumbnail images
    RelatedSearch:
      type: object
      required: [query, link]
      properties:
        query:
          type: string
          description: Related search query
        link:
          type: string
          description: Link to the related search
        thumbnail:
          type: string
          description: Single thumbnail for the related search
        thumbnails:
          type: array
          items:
            type: string
          description: Multiple thumbnails for the related search
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong