openapi: 3.0.0
info:
  title: Facebook Marketplace Item API
  description: |
    The Facebook Marketplace Item API returns one Facebook Marketplace listing: an item for sale, a vehicle, a home
    or room, or a listing by a partner of Facebook such as eBay.

    Pass the number in the item's link as `item_id`, or the link itself as `url`. Share links are accepted. The
    response carries the price, description, condition, location, photos, videos, seller and, where Facebook has
    them, vehicle details, home details, shipping and related searches.

    An item Facebook does not show, and a share link that opens something other than a Marketplace item, answer 200
    with an `error` and cost a credit.

    **Cross-linking**: `organic_results[].item_id` from the Facebook Marketplace API is a valid `item_id` here, and
    `item.location.id` and `item.category.id` are a valid `location_id` and `category_id` there.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Facebook Marketplace Item
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["facebook_marketplace_item"]
            default: "facebook_marketplace_item"
        - name: item_id
          in: query
          required: false
          description: >-
            Number in the link of a Facebook Marketplace item, or organic_results[].item_id from the Facebook
            Marketplace API. Required unless url is provided.
          schema:
            type: string
            maxLength: 19
            pattern: '^[1-9][0-9]{0,18}$'
        - name: url
          in: query
          required: false
          description: >-
            Link of a Facebook Marketplace item, or a Facebook share link that opens one. Pass it in place of item_id.
          schema:
            type: string
            maxLength: 2048
      responses:
        '200':
          description: >-
            Successful response. When Facebook does not show the item, or the share link opens something else, the
            body carries `error` naming the reason in place of `item`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: >-
            Validation Error. There is an issue with query parameters, such as a link that is not a Marketplace item
            or an item_id that is not a number. The search is not billed.
          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, or Facebook answered but returned nothing usable. The search is not billed.
          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'
        item:
          $ref: '#/components/schemas/Item'
        error:
          type: string
          description: Message naming why there is no item to show
    Item:
      type: object
      required: [item_id, title, link, type]
      properties:
        item_id:
          type: string
          description: Numeric Facebook id of the item
        title:
          type: string
          description: Title of the listing
        link:
          type: string
          format: uri
          description: URL of the item on Facebook Marketplace
        type:
          type: string
          description: Kind of listing, such as for_sale, vehicle, real_estate or partner_listing
        price:
          type: string
          description: Price as Facebook shows it
        extracted_price:
          type: number
          description: Price as a number, 0 for a free item
        currency:
          type: string
          description: ISO 4217 code of the price's currency
        original_price:
          type: string
          description: Price before the seller lowered it, as Facebook shows it
        extracted_original_price:
          type: number
          description: Price before the seller lowered it, as a number
        condition:
          type: string
          description: Condition of the item, such as new, used_like_new, used_good or used_fair, or used for a vehicle
        condition_label:
          type: string
          description: Condition as Facebook shows it
        description:
          type: string
          description: Text of the listing
        attributes:
          type: array
          description: Details the seller filled in, such as condition, brand or size
          items:
            $ref: '#/components/schemas/Attribute'
        iso_date:
          type: string
          format: date-time
          description: Time the item was listed, in UTC
        category:
          $ref: '#/components/schemas/Category'
        location:
          $ref: '#/components/schemas/Location'
        delivery_options:
          type: array
          description: >-
            Ways to get the item, among in_person, public_meetup, door_pickup, door_dropoff, shipping_onsite and
            shipping_offsite
          items:
            type: string
        shipping:
          $ref: '#/components/schemas/Shipping'
        quantity:
          type: integer
          description: Number of items on offer
        is_live:
          type: boolean
          description: Whether the listing is live
        is_sold:
          type: boolean
          description: Whether the item is sold
        is_pending:
          type: boolean
          description: Whether a sale of the item is pending
        has_buy_now:
          type: boolean
          description: Whether the item can be bought on Facebook
        has_purchase_protection:
          type: boolean
          description: Whether Facebook protects the purchase
        badges:
          type: array
          description: Badges Facebook shows on the listing
          items:
            type: string
        vehicle:
          $ref: '#/components/schemas/Vehicle'
        property:
          $ref: '#/components/schemas/Property'
        partner:
          $ref: '#/components/schemas/Partner'
        images:
          type: array
          description: Photos of the item
          items:
            $ref: '#/components/schemas/Image'
        videos:
          type: array
          description: Videos of the item
          items:
            $ref: '#/components/schemas/Video'
        seller:
          $ref: '#/components/schemas/Seller'
        hashtags:
          type: array
          description: Tags of the listing
          items:
            type: string
        related_searches:
          type: array
          description: Searches Facebook suggests beside the listing
          items:
            $ref: '#/components/schemas/RelatedSearch'
        similar_items:
          type: array
          description: Listings Facebook suggests beside the listing
          items:
            $ref: '#/components/schemas/SimilarItem'
    Attribute:
      type: object
      required: [name]
      properties:
        name:
          type: string
          description: Name of the detail
        value:
          type: string
          description: Value of the detail
    Category:
      type: object
      properties:
        id:
          type: string
          description: Numeric Facebook id of the category
        name:
          type: string
          description: Name of the category
        slug:
          type: string
          description: Category name in Marketplace links
    Location:
      type: object
      description: Where the item is
      properties:
        id:
          type: string
          description: City name or numeric Facebook id of the place
        name:
          type: string
          description: Place as Facebook shows it
        address:
          type: string
          description: Address of a home
        city:
          type: string
          description: City of a home
        state:
          type: string
          description: State or region code of a home
        latitude:
          type: number
          description: Latitude Facebook shows on the map
        longitude:
          type: number
          description: Longitude Facebook shows on the map
    Shipping:
      type: object
      description: Shipping as Facebook quotes it to its default destination in San Francisco
      required: [label]
      properties:
        label:
          type: string
          description: Shipping cost as Facebook shows it
        extracted_price:
          type: number
          description: Shipping cost as a number, 0 for free shipping
        carrier:
          type: string
          description: Carrier and service
        delivery:
          type: string
          description: Delivery estimate of a partner's listing
        delivery_from:
          type: string
          format: date
          description: Earliest delivery date
        delivery_to:
          type: string
          format: date
          description: Latest delivery date
    Vehicle:
      type: object
      description: Details of a vehicle
      properties:
        make:
          type: string
          description: Make
        model:
          type: string
          description: Model
        trim:
          type: string
          description: Trim
        mileage:
          type: integer
          description: Distance driven, in mileage_unit
        mileage_unit:
          type: string
          description: Unit of the mileage, such as miles or kilometers
        exterior_color:
          type: string
          description: Exterior color
        interior_color:
          type: string
          description: Interior color
        fuel_type:
          type: string
          description: Fuel, such as gasoline or diesel
        transmission:
          type: string
          description: Transmission, such as automatic or manual
        condition:
          type: string
          description: Condition the seller gives, such as excellent or very_good
        title_status:
          type: string
          description: Status of the vehicle's title, such as clean
        owners:
          type: string
          description: Number of owners, such as one or two
        is_paid_off:
          type: boolean
          description: Whether the vehicle is paid off
        seller_type:
          type: string
          description: Kind of seller, such as private_seller
        specifications:
          type: array
          description: Specifications of the vehicle's model
          items:
            $ref: '#/components/schemas/Specification'
    Specification:
      type: object
      required: [name, value]
      properties:
        name:
          type: string
          description: Name of the specification, such as gas_mileage_city
        value:
          type: string
          description: Value of the specification
        unit:
          type: string
          description: Unit of the value
    Property:
      type: object
      description: Details of a home or room
      properties:
        home_type:
          type: string
          description: Kind of home, such as Apartment or House
        rooms:
          type: string
          description: Beds and baths as Facebook shows them
        beds:
          type: number
          description: Number of beds
        baths:
          type: number
          description: Number of baths
        area:
          type: string
          description: Living area as Facebook shows it
        extracted_area:
          type: number
          description: Living area as a number
        features:
          type: array
          description: Features of the home, such as heating, laundry and parking
          items:
            type: string
        listed:
          type: string
          description: How long the home has been listed, as Facebook shows it
        walk_score:
          type: integer
          description: Walk score of the address
        transit_score:
          type: integer
          description: Transit score of the address
        bike_score:
          type: integer
          description: Bike score of the address
        nearby_transit:
          type: array
          description: Transit stops nearby
          items:
            $ref: '#/components/schemas/TransitStop'
    TransitStop:
      type: object
      required: [name]
      properties:
        name:
          type: string
          description: Name of the stop
        type:
          type: string
          description: Kind of stop, such as bus
        distance:
          type: string
          description: Distance to the stop
        routes:
          type: array
          description: Routes that serve the stop
          items:
            type: string
    Partner:
      type: object
      description: The partner that lists the item
      properties:
        name:
          type: string
          description: Name of the partner
        link:
          type: string
          format: uri
          description: URL of the item on the partner's site
        listing_type:
          type: string
          description: Kind of listing, such as fixed_price
        return_policy:
          type: string
          description: Return policy
        guarantee:
          type: string
          description: Title of the guarantee displayed for the partner listing
        seller:
          $ref: '#/components/schemas/PartnerSeller'
    PartnerSeller:
      type: object
      description: Seller on the partner's site
      properties:
        name:
          type: string
          description: Name of the seller
        reviews:
          type: integer
          description: Number of reviews of the seller
        positive_feedback_percent:
          type: number
          description: Share of positive reviews, in percent
        joined_year:
          type: integer
          description: Year the seller joined the partner's site
    Image:
      type: object
      required: [image]
      properties:
        id:
          type: string
          description: Numeric Facebook id of the photo
        image:
          type: string
          format: uri
          description: URL of the photo
        width:
          type: integer
          description: Width in pixels
        height:
          type: integer
          description: Height in pixels
        accessibility_caption:
          type: string
          description: Facebook's description of the photo
    Video:
      type: object
      required: [link]
      properties:
        id:
          type: string
          description: Numeric Facebook id of the video
        link:
          type: string
          format: uri
          description: URL of the video file in the best quality offered
        hd_link:
          type: string
          format: uri
          description: URL of the HD video file
        sd_link:
          type: string
          format: uri
          description: URL of the SD video file
        thumbnail:
          type: string
          format: uri
          description: URL of the video's cover image
        width:
          type: integer
          description: Width in pixels
        height:
          type: integer
          description: Height in pixels
    Seller:
      type: object
      description: Who lists the item, as Facebook shows them
      required: [type]
      properties:
        id:
          type: string
          description: Numeric Facebook id of a Page
        name:
          type: string
          description: First name on the seller's profile, or the name of a Page
        link:
          type: string
          format: uri
          description: URL of a Page on Facebook
        type:
          type: string
          description: user for a profile, page for a Page
        rating:
          type: number
          description: Average rating, out of 5
        reviews:
          type: integer
          description: Number of ratings
        joined_year:
          type: integer
          description: Year the seller joined Facebook
    RelatedSearch:
      type: object
      required: [query]
      properties:
        query:
          type: string
          description: Suggested search
    SimilarItem:
      type: object
      required: [item_id, link]
      properties:
        item_id:
          type: string
          description: Numeric Facebook id of the item
        link:
          type: string
          format: uri
          description: URL of the item on Facebook Marketplace
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: Unique identifier for the search request, absent when zero_retention is set
        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: Facebook URL of the item
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
    SearchParameters:
      type: object
      required: [engine]
      properties:
        engine:
          type: string
          description: Search engine identifier
        item_id:
          type: string
          description: Item id the item was requested with
        url:
          type: string
          description: Link the item was requested with
        zero_retention:
          type: boolean
          description: Whether zero data retention was requested
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
