> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stophy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# eBay eBay Search API

> Scrape eBay search results. Call the eBay eBay Search API and get JSON back in one request. 1 credit per call. Failed calls cost nothing.

Scrape eBay search results.

## Request

`query` is required.

<CodeGroup>
  ```typescript TypeScript icon="https://mintcdn.com/sirathic/7E4w9-IC4ysabjfc/images/icons/typescript.svg?fit=max&auto=format&n=7E4w9-IC4ysabjfc&q=85&s=d8272a85e64145620f1fbbfcf7932986" theme={null}
  import { Stophy } from "stophy";

  const stophy = new Stophy({ apiKey: process.env.STOPHY_API_KEY });
  const result = await stophy.ebay.search({ query: "nintendo switch oled" });
  console.log(result.data.results);
  ```

  ```python Python icon="python" theme={null}
  from stophy import Stophy

  stophy = Stophy()  # reads STOPHY_API_KEY
  result = stophy.ebay.search(query="nintendo switch oled")
  print(result["data"]["results"])
  ```

  ```bash cURL icon="terminal" theme={null}
  curl -X POST https://api.stophy.dev/v1/ebay/search \
    -H "Authorization: Bearer $STOPHY_API_KEY" \
    -H "content-type: application/json" \
    -d '{"query":"nintendo switch oled"}'
  ```

  ```bash CLI icon="square-terminal" theme={null}
  stophy ebay search "nintendo switch oled"
  ```
</CodeGroup>

## Response

If successful, the response body contains the standard envelope. `data.results[]` contains the items, each with its price, shipping cost, total price, condition and location.

The following example is a real response, truncated: each list shows one item and long strings are cut.

```json theme={null}
{
  "success": true,
  "data": {
    "total": 6400,
    "results": [
      {
        "itemId": "326350933758",
        "itemUrl": "https://www.ebay.com/itm/326350933758",
        "title": "Nintendo Switch OLED 64GB White Joy-Con 2021 Newest - Japan Import with US plug",
        "imageUrl": "https://i.ebayimg.com/images/g/Z94AAOSwTTJnQ-Bl/s-l500.jpg",
        "price": 350.99,
        "isPriceHidden": false,
        "priceCurrency": "USD",
        "shippingCost": 0,
        "isPickupOnly": false,
        "totalPrice": 350.99,
        "condition": "Brand New",
        "isAuction": false,
        "hasBestOffer": false,
        "itemLocation": "United States",
        "quantitySold": 71,
        "sellerName": "bestsellerssince1977",
        "sellerFeedbackPercent": 99.7,
        "sellerFeedbackScore": 4800
      }
    ],
    "page": 1
  },
  "creditsUsed": 1,
  "requestId": "2fe9dbad-fc48-4890-9751-0b24b596035b"
}
```

| Field | Type | Description |
| - | - | - |
| `page` | integer | The page number of this response. |
| `total` | integer | The total number of matching results, across all pages. |

For every field, see the response schema on this page.

## Optional parameters

| Parameter | Type | Description |
| - | - | - |
| `condition` | string | Restricts results to `new` or only `used` items. Acceptable values are `new` and `used`. |
| `auctionsOnly` | boolean | Restricts results to auctions. With sort `endingSoonest` this lists auctions about to end; [eBay eBay Item](/api-reference/endpoint/ebay-item) then returns what each one sold for. If unset, defaults to `false`. |
| `minPrice` | number | The minimum price. |
| `maxPrice` | number | The maximum price. |
| `sort` | string | `priceLow` and `priceHigh` return each page in order of `totalPrice`: price plus shipping to New York 10001. Across pages the order is `eBay`'s, so a listing can belong on the neighbouring page. Listings with no `totalPrice` come last on their page: the price is hidden (`isPriceHidden`), the variation range is outside the price filter, or it is pickup only outside the United States. Acceptable values are `bestMatch`, `priceLow`, `priceHigh` and `endingSoonest`. If unset, defaults to `bestMatch`. |
| `page` | integer | The page to return. Pages are numbered from 1. Must be between 1 and 100. If unset, defaults to `1`. |

## Billing

Each successful request consumes 1 credit, regardless of the number of items returned. Requests that fail, or that return no items, are not billed.

## Pagination

Results are paginated. To retrieve the next page, increment `page`. An empty `data.results` indicates the last page. The maximum value of `page` is 100.

## Related methods

* [eBay eBay Item](/api-reference/endpoint/ebay-item): Accepts `itemUrl`. Scrape an eBay item page.


## OpenAPI

````yaml api-reference/openapi.json POST /v1/ebay/search
openapi: 3.1.0
info:
  title: Stophy API
  version: '1'
  description: >-
    Every endpoint is a POST that takes its input as a JSON object body. Unknown
    fields are rejected with 400.


    Responses leave out empty values: null, empty strings, empty objects and
    empty nested lists are not sent.


    Text comes back whole. To get shorter responses, add
    ?maxTextLength=<characters> to the URL. Every text value longer than that is
    cut and ends with …. A screenshot is never cut, and a page whose text was
    cut has isTruncated set to true.


    x-credits is what one call costs. Every call costs the same, whatever it
    returns, unless an operation's description says it costs per 10 results, or
    per second of audio. Then x-credits is the lowest price and x-credits-max
    the most one call can cost. Where an operation takes limit, send it to
    return fewer results and pay for fewer.


    When a response has a cursor, send it back unchanged with the same input to
    get the next page. When it has a page, send the next page number.
servers:
  - url: https://api.stophy.dev
security:
  - apiKey: []
paths:
  /v1/ebay/search:
    post:
      summary: Scrape eBay search results
      description: Costs 1 credit per call. Pages with page.
      operationId: ebaySearch
      parameters:
        - $ref: '#/components/parameters/MaxTextLength'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  minLength: 1
                  maxLength: 300
                condition:
                  type: string
                  enum:
                    - new
                    - used
                auctionsOnly:
                  default: false
                  description: >-
                    Only auctions. With sort endingSoonest this lists auctions
                    about to end; ebay.item then returns what each one sold for.
                  type: boolean
                minPrice:
                  type: number
                  minimum: 0
                maxPrice:
                  type: number
                  minimum: 0
                sort:
                  default: bestMatch
                  description: >-
                    priceLow and priceHigh return each page in order of
                    totalPrice: price plus shipping to New York 10001. Across
                    pages the order is eBay's, so a listing can belong on the
                    neighbouring page. Listings with no totalPrice come last on
                    their page: the price is hidden (isPriceHidden), the
                    variation range is outside the price filter, or it is pickup
                    only outside the United States.
                  type: string
                  enum:
                    - bestMatch
                    - priceLow
                    - priceHigh
                    - endingSoonest
                page:
                  default: 1
                  description: Page number, starting at 1.
                  type: integer
                  minimum: 1
                  maximum: 100
              required:
                - query
              additionalProperties: false
            example:
              query: nintendo switch oled
      responses:
        '200':
          description: The data, and the credits this call used.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/RequestId'
            x-credits-used:
              $ref: '#/components/headers/CreditsUsed'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
            x-cache:
              $ref: '#/components/headers/Cache'
            x-cache-age:
              $ref: '#/components/headers/CacheAge'
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                  - creditsUsed
                  - requestId
                properties:
                  success:
                    const: true
                  data:
                    type: object
                    additionalProperties: false
                    properties:
                      total:
                        type: integer
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                      results:
                        type: array
                        items:
                          type: object
                          additionalProperties: false
                          properties:
                            itemId:
                              type: string
                            itemUrl:
                              type: string
                              format: uri
                            title:
                              type: string
                            imageUrl:
                              type: string
                              format: uri
                            price:
                              type: number
                              minimum: 0
                            priceMax:
                              type: number
                              minimum: 0
                            isPriceHidden:
                              type: boolean
                            originalPrice:
                              type: number
                              minimum: 0
                            priceCurrency:
                              type: string
                              pattern: ^[A-Z]{3}$
                              description: ISO 4217 currency code, e.g. USD.
                            shippingCost:
                              type: number
                              minimum: 0
                            isPickupOnly:
                              type: boolean
                            totalPrice:
                              type: number
                              minimum: 0
                            condition:
                              type: string
                            isAuction:
                              type: boolean
                            bids:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            timeLeft:
                              type: string
                            hasBestOffer:
                              type: boolean
                            itemLocation:
                              type: string
                            quantitySold:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            watchers:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            sellerName:
                              type: string
                            sellerFeedbackPercent:
                              type: number
                            sellerFeedbackScore:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                          required:
                            - itemUrl
                            - isPriceHidden
                            - isPickupOnly
                            - isAuction
                            - hasBestOffer
                      page:
                        type: integer
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                    required:
                      - results
                      - page
                  creditsUsed:
                    type: integer
                  requestId:
                    type: string
        4XX:
          $ref: '#/components/responses/Error'
        5XX:
          $ref: '#/components/responses/Error'
components:
  parameters:
    MaxTextLength:
      name: maxTextLength
      in: query
      required: false
      description: >-
        Cut every text value in the response to this many characters. A value
        that was cut ends with …, and a page whose text was cut has isTruncated
        set to true. A screenshot is never cut. Leave it out to get the full
        text.
      schema:
        type: integer
        minimum: 1
  headers:
    RequestId:
      description: The request id. Quote it when you report a problem.
      schema:
        type: string
    CreditsUsed:
      description: Credits this call used.
      schema:
        type: integer
    RateLimitLimit:
      description: Requests allowed in the current window.
      schema:
        type: integer
    RateLimitRemaining:
      description: Requests left in the current window.
      schema:
        type: integer
    RateLimitReset:
      description: Unix time in seconds when the current window resets.
      schema:
        type: integer
    Cache:
      description: hit if this result came from the cache, miss if it was fetched live.
      schema:
        type: string
    CacheAge:
      description: Seconds since the returned result was written to the cache.
      schema:
        type: integer
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  responses:
    Error:
      description: The request failed. retryable says whether trying again can help.
      headers:
        X-Request-ID:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - success
        - error
      properties:
        success:
          const: false
        error:
          type: object
          required:
            - code
            - message
            - retryable
            - requestId
          properties:
            code:
              type: string
              enum:
                - cliSessionCompleted
                - cliSessionExists
                - cliSessionNotFound
                - forbidden
                - insufficientCredits
                - internalError
                - inviteClaimed
                - inviteDisabled
                - inviteExpired
                - inviteUsedUp
                - invalidCliSession
                - invalidCliVerifier
                - invalidRequest
                - notFound
                - rateLimited
                - sourceChanged
                - sourceRefused
                - sourceTimeout
                - sourceUnavailable
                - tooManyInFlight
                - unauthorized
                - unsupportedMediaType
            message:
              type: string
            retryable:
              type: boolean
            retryAfterSeconds:
              type: integer
            requestId:
              type: string
            requiredCredits:
              type: number
            availableCredits:
              type: number
            billingUrl:
              type: string
              const: https://stophy.dev/billing
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.