pythonebay-api

Ebay Browse API Missing Some Auction Items


I built an application with python using the Ebay Browse API to retrieve and sort listings. It handles auction items returned, however for some items, some or all auction listings are missing from the returned results. The application works exactly as I want it to, but the underlying Browse API does not display ALL listings at all times, and unfortunately this is a requirement for my use case. It can't not show some items while displaying others.

An example of a product code that does not display all auction items is query="2198-H025-ERS" country="EBAY-US". There are two Allen Bradley bidding listings that do not appear. However, it gets all the other listings. They have been published for some time and are indexed. They appear if I go to ebay.com and search manually. Auction items will sometimes appear for other items, but not always.

Changing the sort option and shipping location does not seem to help.

Is there an option I can set, or another API I can use that is more accurate with returned results?

def make_api_call(self, query, country, token):
        api_url = "https://api.ebay.com/buy/browse/v1/item_summary/search?"
        country_code = country.replace("EBAY-", "")
        headers = {
            "Authorization": f"Bearer {token}",
            "Content-Type": "application/json",
            "Accept": "application/json",
        }

        # Include selected countries in the API call
        query_string = f"q={query}&limit=200"
        api_url += query_string
        headers["X-EBAY-C-MARKETPLACE-ID"] = f"{country}"
        

        # Make initial API call to get total results
        print(f"Sending query for {country}: {api_url}")
        response = requests.get(api_url, headers=headers)
        if country:  #  == "EBAY-US":  # @NOTE: DEBUG
            # Open a text file in write mode ('w')
            with open("response-debugging-all.txt", "a", encoding="utf-8") as file:
                # Write the string to the file
                file.write(str(response.text))
        if response.status_code == 200:
            data = response.json()
            total_results = data.get("total", 0)
            if total_results > 200:
                print("Total results exceed 200. Paginating...")
                all_items = []
                for offset in range(0, total_results, 200):
                    print(f"Fetching items with offset: {offset}")
                    api_url_with_offset = f"{api_url}&offset={offset}"
                    response = requests.get(api_url_with_offset, headers=headers)
                    if response.status_code == 200:
                        items_data = response.json()
                        all_items.append(items_data)
                    else:
                        print(f"Failed to fetch items with offset {offset}")
                return all_items, country
            else:
                return [data], country
        else:
            print(f"Failed to make API call for {country}")
            return None

Solution

  • The issue was that the ebay browse API only finds exact matches for the query. You can have a complete search query for an answer by using multiple keywords.

    For my case I am searching for specific SKUs, so it does not find all the listings since some of them have extra spaces in the title. The Browse API does not account for this, so I programmatically split each SKU into the different possible formats. This worked and I was able to retrieve the missing listings in a single API call.

    An example of how to get the same results as a search on ebay.com:

    https://api.ebay.com/buy/browse/v1/item_summary/search?q=(3RK1903-3AE00,3RK19033AE00,3 R K 1 9 0 3 3 A E 0 0,3RK1903 3AE00)&limit=200&