# eBay Search API

The `eBay Search API` endpoint will retrieve products for a specified search term from an eBay search page and transform it into usable JSON.

{% tabs %}
{% tab title="cURL" %}

```bash
curl --request GET \
--url "https://api.scraperapi.com/structured/ebay/search/v2?\
api_key=API_KEY&query=QUERY&country_code=COUNTRY_CODE&tld=TLD"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

payload = {
    'api_key': 'APIKEY',
    'query': 'QUERY',
    'country_code': 'COUNTRY_CODE',
    'tld': 'TLD'
}

r = requests.get('https://api.scraperapi.com/structured/ebay/search/v2',params=payload)

print(r.text)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import fetch from 'node-fetch';

fetch(`https://api.scraperapi.com/structured/ebay/search/v2?api_key=API_KEY&query=QUERY&country_code=COUNTRY_CODE&tld=TLD`)
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://api.scraperapi.com/structured/ebay/search/v2?api_key=API_KEY&query=QUERY&country_code=COUNTRY_CODE&tld=TLD";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

$response = curl_exec($ch);
curl_close($ch);

print_r($response);
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'

params = {
  :api_key => "API_KEY",
  :query => "QUERY",
  :country_code => "COUNTRY_CODE",
  :tld => "TLD"
}

uri = URI('https://api.scraperapi.com/structured/ebay/search/v2')
uri.query = URI.encode_www_form(params)

website_content = Net::HTTP.get(uri)
print(website_content)
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "API_KEY";
            String query   = "QUERY";
            String country_code = "COUNTRY_CODE";
            String tld = "TLD";

            String urlStr = "https://api.scraperapi.com/structured/ebay/search/v2?api_key=" 
                            + apiKey + "&query=" + query + "&country_code=" + country_code + "&tld=" + tld;

            URL url = new URL(urlStr);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");

            int responseCode = conn.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                StringBuilder response = new StringBuilder();
                String line;
                while ((line = in.readLine()) != null) {
                    response.append(line);
                }
                in.close();
                System.out.println(response.toString());
            } else {
                System.out.println("Error in API Call. Response code: " + responseCode);
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Supported Parameters**

<table><thead><tr><th width="376">Parameters</th><th>Details</th></tr></thead><tbody><tr><td><code>API_KEY</code> (required)</td><td>Your API Key.</td></tr><tr><td><code>QUERY</code> (required)</td><td>Search query. Example: <code>iPhone</code></td></tr><tr><td><code>TLD</code></td><td><p>Top-level Ebay domain to scrape. This is an optional argument and defaults to “com” (ebay.com). Valid values include: </p><p><strong>com</strong> (ebay.com)</p><p><strong>co.uk</strong> (ebay.co.uk)</p><p><strong>com.au</strong> (ebay.com.au)</p><p><strong>de</strong> (ebay.de)</p><p><strong>ca</strong> (ebay.ca)</p><p><strong>fr</strong> (ebay.fr)</p><p><strong>it</strong> (ebay.it)</p><p><strong>es</strong> (ebay.es)</p><p><strong>at</strong> (ebay.at)</p><p><strong>ch</strong> (ebay.ch)</p><p><strong>com.sg</strong> (ebay.com.sg)</p><p><strong>com.my</strong> (ebay.com.my)</p><p><strong>ph</strong> (ebay.ph)</p><p><strong>ie</strong> (ebay.ie)</p><p><strong>pl</strong> (ebay.pl)</p><p><strong>nl</strong> (ebay.nl)</p></td></tr><tr><td><code>COUNTRY_CODE</code></td><td><strong><code>country_code</code></strong> influences the language and the currency of the page. The TLD should be set to ‘com’ if you are using languages that are not used by the TLDs listed above.</td></tr><tr><td><code>OUTPUT_FORMAT</code></td><td><p>For structured data methods we offer CSV and JSON output. JSON is default if parameter is not added. Options:</p><ul><li>csv</li><li>json (default)</li></ul></td></tr><tr><td><code>SORT_BY</code></td><td><p>Instructs the API to sort the results. Supported values:</p><p><br>ending_soonest<br>newly_listed<br>price_lowest<br>price_highest<br>distance_nearest<br>best_match</p></td></tr><tr><td><code>PAGE</code></td><td>Page number</td></tr><tr><td><code>ITEMS_PER_PAGE</code></td><td>Number of items returned. Supported values:<br>60, 120, 240<br></td></tr><tr><td><code>SELLER_ID</code></td><td>The ‘name’ of the seller. This is a textual id, for example ‘gadget-solutions’</td></tr><tr><td><strong>Filter options</strong></td><td></td></tr><tr><td><code>CONDITON</code></td><td><p>Condition of the products. Supported values:</p><p><br>'new', 'used', 'open_box', 'refurbished', 'for_parts', 'not_working’<br><br><strong>Note: These categories don’t have the same name for all products.</strong> </p><p></p><p>For example <code>open_box</code> is sometimes called ‘without tag’ on the eBay results page. Please ensure that you are always using the values from the supported list when sending request to the API.<br><br><strong>Note2:</strong> Multiple options can be used here. So if you want to search for new and open_box products you can use the query param:<br>’used,open_box’ in an URL encoded form like<br>&#x26;condition=used%2Copen_box<br></p></td></tr><tr><td><code>BUYING_FORMAT</code></td><td><p>Buying format. Supported values:</p><p><br>buy_it_now<br>auction<br>accepts_offers<br><br><strong>Note:</strong> You can specify multiple options just as with the <code>condition</code> parameter.</p></td></tr><tr><td><code>SHOW_ONLY</code></td><td><p>Additional filters for search. Supported values:</p><p><br>returns_accepted<br>authorized_seller<br>completed_items<br>sold_items<br>sale_items<br>listed_as_lots<br>search_in_description<br>benefits_charity<br>authenticity_guarantee<br><br><strong>Note:</strong> Multiple options can be used here. So if you want to search for a product where returns are accepted and it’s from an authorized seller the query param:<br>’returns_accepted,authorized_seller’ in an URL encoded form like<br>&#x26;show_only=returns_accepted%2Cauthorized_seller</p></td></tr></tbody></table>

### Sample Response

```json
[
  {
    "product_title": "Apple iPhone SE 2nd Gen (Great Cond) Unlocked AT&T TMobile Verizon 64 128 256 GBOpens in a new window or tab",
    "image": "https://i.ebayimg.com/images/g/GJMAAOSw3bBmaHw2/s-l500.webp",
    "product_url": "https://www.ebay.com/itm/226358814412",
    "condition": "Pre-Owned",
    "item_price": {
      "from": {
        "value": 147.99,
        "currency": "USD"
      },
      "to": {
        "value": 264.99,
        "currency": "USD"
      }
    },
    "extra_info": "Buy It Now",
    "free_returns": "Free returns",
    "watchers": 19,
    "seller_name": "cocosprinkles",
    "seller_rating_count": 32530,
    "seller_rating": 99.8,
    "seller_has_top_rated_plus": true
  },
  {
    "product_title": "Apple iPhone 8 (Great Condition) Unlocked AT&T Verizon T-Mobile 64GB 128GB 256GBOpens in a new window or tab",
    "image": "https://i.ebayimg.com/images/g/NXoAAOSwNIdmZw4e/s-l500.webp",
    "product_url": "https://www.ebay.com/itm/226358808865",
    "condition": "Pre-Owned",
    "item_price": {
      "from": {
        "value": 134.99,
        "currency": "USD"
      },
      "to": {
        "value": 214.99,
        "currency": "USD"
      }
    },
    "extra_info": "Buy It Now",
    "free_returns": "Free returns",
    "items_sold": 59,
    "seller_name": "cocosprinkles",
    "seller_rating_count": 32530,
    "seller_rating": 99.8,
    "seller_has_top_rated_plus": true
  },
  {
    "product_title": "Apple iPhone SE 2nd Gen 2020 64GB Unlocked Verizon At&t T-Mobile Fair ConditionOpens in a new window or tab",
    "image": "https://i.ebayimg.com/images/g/gg4AAOSw735mRYIO/s-l140.webp",
    "product_url": "https://www.ebay.com/itm/226378701013",
    "condition": "Pre-Owned · Apple iPhone SE (2nd Generation) · 64 GB · Unlocked",
    "item_price": {
      "value": 90,
      "currency": "USD"
    },
    "extra_info": "Buy It Now",
    "shipping_cost": "Free shipping",
    "watchers": 10,
    "seller_name": "esupplytech",
    "seller_rating_count": 4156,
    "seller_rating": 97.8
  },
  {
    "product_title": "Apple iPhone XR Black 128GB A1984 MT362LL/A Verizon Clean ESN Good (JF)Opens in a new window or tab",
    "image": "https://i.ebayimg.com/images/g/GAgAAOSwxDRitG-z/s-l140.webp",
    "product_url": "https://www.ebay.com/itm/195161489925",
    "condition": "Good - Refurbished · Apple iPhone XR · 128 GB · Verizon",
    "item_price": {
      "value": 143.96,
      "currency": "USD"
    },
    "extra_info": "Buy It Now",
    "free_returns": "Free returns",
    "seller_name": "auditmacstech",
    "seller_rating_count": 12440,
    "seller_rating": 99.2,
    "seller_has_top_rated_plus": true
  },
 ............................
]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.scraperapi.com/structured-data-endpoints/e-commerce/ebay/ebay-search-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
