openapi: 3.0.0
info:
  title: eBay Shipping Calculator API
  description: |
    Retrieve seller-side postage estimates from eBay's public shipping rate calculator.

    Given a package (weight, dimensions) and an origin, the API returns the shipping
    services eBay quotes for it, each with the eBay-negotiated price, the carrier's
    retail price, estimated delivery window and included coverage.

    **Scope**: these are the rates a *seller* would pay to ship a package, not the
    shipping charged to a buyer on a specific listing. For buyer-facing shipping on a
    live item, use the eBay Product API with its `postal_code` parameter instead.

    **Marketplace coverage**: only six eBay marketplaces serve the calculator. The
    package ships from the country of the `ebay_domain` marketplace.

    **Price shapes**: on a domestic quote without `ship_to_zip`, a service whose price
    depends on the destination comes back as an estimate range, and exposes
    `extracted_price_range` with `is_price_range` set. A destination postcode, any
    international destination, or a UK quote (priced for mainland UK without a
    postcode) gets a single price per service.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: eBay Shipping Calculator
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Set to `ebay_shipping_calculator` to use this API
          schema:
            type: string
            enum: ["ebay_shipping_calculator"]
        - name: weight
          in: query
          required: true
          description: Package weight, in pounds when `unit_system` is imperial and kilograms when it is metric. With `unit_system` left out, pounds on `ebay.com` and kilograms on the other marketplaces. At most 150 lb or 68.03 kg.
          schema:
            type: number
            minimum: 0
            exclusiveMinimum: true
        - name: length
          in: query
          required: true
          description: Package length, in inches when `unit_system` is imperial and centimeters when it is metric. With `unit_system` left out, inches on `ebay.com` and centimeters on the other marketplaces. Under 130 in or 330 cm.
          schema:
            type: number
            minimum: 0
            exclusiveMinimum: true
        - name: width
          in: query
          required: true
          description: Package width, in inches when `unit_system` is imperial and centimeters when it is metric. With `unit_system` left out, inches on `ebay.com` and centimeters on the other marketplaces. Under 130 in or 330 cm.
          schema:
            type: number
            minimum: 0
            exclusiveMinimum: true
        - name: height
          in: query
          required: true
          description: Package height, in inches when `unit_system` is imperial and centimeters when it is metric. With `unit_system` left out, inches on `ebay.com` and centimeters on the other marketplaces. Under 130 in or 330 cm.
          schema:
            type: number
            minimum: 0
            exclusiveMinimum: true
        - name: ship_from_zip
          in: query
          required: true
          description: Postal code the package ships from. It must match the format of the origin country, which is taken from `ebay_domain`. A 5-digit ZIP or ZIP+4 on `ebay.com` (`10001`), a postal code on `ebay.ca` (`M5V 3L9`), a postcode on `ebay.co.uk` (`E1 6AN`), 4 digits on `ebay.com.au` (`2000`), and 5 digits on `ebay.de` and `ebay.fr` (`10115`, `75001`).
          schema:
            type: string
        - name: ebay_domain
          in: query
          required: false
          description: eBay marketplace to quote rates on. Also determines the origin country and the currency of every quote.
          schema:
            type: string
            enum: ["ebay.com", "ebay.ca", "ebay.co.uk", "ebay.com.au", "ebay.de", "ebay.fr"]
            default: "ebay.com"
        - name: unit_system
          in: query
          required: false
          description: Units for weight and dimensions. Imperial uses pounds and inches, metric uses kilograms and centimeters. Defaults to imperial on `ebay.com` and metric on the other marketplaces.
          schema:
            type: string
            enum: ["imperial", "metric"]
        - name: ship_to_country
          in: query
          required: false
          description: ISO 3166-1 alpha-2 destination country. Defaults to the origin country, which quotes domestic services. Each marketplace ships to its own subset of these countries (`ebay.de` mostly within Europe, `ebay.fr` only to BE, DE, ES, LU and PT), and an unsupported one returns an error listing the supported ones. On `ebay.com`, US territories such as Puerto Rico and Guam are quoted as domestic, with `ship_to_country` omitted and the territory's ZIP in `ship_to_zip`.
          schema:
            type: string
            enum: ["US", "CA", "GB", "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BA", "BW", "BR", "BN", "BG", "BF", "BI", "KH", "CM", "CV", "KY", "CF", "TD", "CL", "CN", "CO", "KM", "CD", "CG", "CK", "CR", "CI", "HR", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FJ", "FI", "FR", "GF", "PF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IE", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KR", "KW", "KG", "LA", "LV", "LB", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "MD", "MC", "MN", "MS", "MA", "MZ", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NO", "OM", "PK", "PW", "PA", "PG", "PY", "PE", "PH", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "SH", "KN", "LC", "PM", "VC", "SM", "SA", "SN", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "ES", "LK", "SR", "SZ", "SE", "CH", "TW", "TJ", "TZ", "TH", "TG", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "UY", "UZ", "VU", "VA", "VE", "VN", "VI", "WF", "EH", "WS", "YE", "FM", "ME", "RS", "ZM", "ZW"]
        - name: ship_to_zip
          in: query
          required: false
          description: Destination postal code. Omitting it on a domestic quote returns an estimate range instead of a single price for services whose price depends on the destination. International quotes return a single price either way. On `ebay.co.uk`, a quote without it is priced for mainland UK. When the destination is US, CA, GB, AU, DE or FR, the code must match that country's format, as for `ship_from_zip`.
          schema:
            type: string
        - name: irregular_package
          in: query
          required: false
          description: Whether the package is irregular or oversized, which carriers surcharge
          schema:
            type: boolean
            default: false
      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'
        shipping_services:
          type: array
          description: Shipping services eBay quotes for the package, in the order eBay's calculator returns them (not sorted by price)
          items:
            $ref: '#/components/schemas/ShippingService'
        error:
          type: string
          description: Why eBay returned no shipping services for the package
    ShippingService:
      type: object
      required: [position, carrier, service, service_code, price, currency]
      properties:
        position:
          type: integer
          description: 1-based position of the service in the response
        carrier:
          type: string
          description: Carrier code, for example USPS, UPS, FEDEX, DHL or AUP
        service:
          type: string
          description: Human-readable service name
        service_code:
          type: string
          description: eBay's shipping service code for the service
        service_group:
          type: string
          description: Group eBay assigns the service to
        price:
          type: string
          description: Price a seller pays, as a two-decimal amount or a range, at eBay's rate where the marketplace has one and the retail rate otherwise
        extracted_price:
          type: number
          description: Numeric form of `price`
        extracted_price_range:
          $ref: '#/components/schemas/PriceRange'
        is_price_range:
          type: boolean
          description: Whether `price` is a range rather than a single amount
        retail_price:
          type: string
          description: Carrier's undiscounted retail price, formatted to two decimals
        extracted_retail_price:
          type: number
          description: Numeric form of `retail_price`
        extracted_retail_price_range:
          $ref: '#/components/schemas/PriceRange'
        is_retail_price_range:
          type: boolean
          description: Whether `retail_price` is a range rather than a single amount
        currency:
          type: string
          description: ISO 4217 currency of the quoted prices
        has_tracking:
          type: boolean
          description: Whether the service includes tracking
        included_coverage:
          type: number
          description: Value of the insurance coverage included with the service
        estimated_delivery_min_hours:
          type: integer
          description: Lower bound of the estimated delivery window, in hours
        estimated_delivery_max_hours:
          type: integer
          description: Upper bound of the estimated delivery window, in hours
    PriceRange:
      type: object
      description: Low and high ends of an estimate range
      properties:
        from:
          type: number
          description: Low end of the range
        to:
          type: number
          description: High end of the range
    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"
        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
        ebay_domain:
          type: string
        weight:
          type: string
        length:
          type: string
        width:
          type: string
        height:
          type: string
        unit_system:
          type: string
        ship_from_country:
          type: string
          description: Origin country, derived from `ebay_domain`
        ship_from_zip:
          type: string
        ship_to_country:
          type: string
        ship_to_zip:
          type: string
        irregular_package:
          type: string
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
