BrennanR
BrennanR

Reputation: 3

EBAY Finding API Date Filtering

I am trying to return a list of completed items in a given category using the ebay API. My code seems to be working however the results seem to be very limited (about 100). I was assuming there would be some limitation on how far back the api would go but even just a few days should return thousands of results for this category. Am I missing something in the code or is this just a limitation of the ebay API? I did make sure I was using production and not the sandbox.

So I have realized now that there are multiple pages to my query up to the 100 item / 100 page max. I am now running into issues with the date filtering. I see the filter reference material on site but I am still not getting the result I expect. In the updated query I am trying to pull only items completed yesterday but when running I am getting stuff from today. Is there a better way to input the date filters?

from ebaysdk.finding import Connection as finding
from bs4 import BeautifulSoup
import os
import csv

api = finding(appid=<my appid>,config_file=None)

response = api.execute(
             'findCompletedItems', {
                        'categoryId': '214',
                        'keywords' : 'prizm', 
                        'endTimeFrom' : '2020-02-03T00:00:00.000Z',
                        'endTimeTo' : '2020-02-04T00:00:00.000Z' ,
                        'paginationInput': {
                                'entriesPerPage': '100',
                                'pageNumber': '1'
                                            },
                        'sortOrder': 'EndTimeSoonest'
                                    }
                        )

soup = BeautifulSoup(response.content , 'lxml')

totalitems = int(soup.find('totalentries').text)
items = soup.find_all('item')

for item in response.reply.searchResult.item:
    print(item.itemId)
    print(item.listingInfo.endTime)

Upvotes: 0

Views: 307

Answers (1)

BrennanR
BrennanR

Reputation: 3

I finally figured this out. I needed to add additional code for the item filters. The working code is below.

from ebaysdk.finding import Connection as finding from bs4 import BeautifulSoup import os import csv

api = finding(appid=<my appid>,config_file=None)

response = api.execute(
             'findCompletedItems', {
                        'categoryId': '214',
                        'keywords' : 'prizm',
                         'itemFilter': [
                                        {'name': 'EndTimeFrom', 'value': '2020-02-03T00:00:00.000Z'},
                                        {'name': 'EndTimeTo', 'value': '2020-02-04T00:00:00.000Z'}
                                        #{'name': 'MinPrice', 'value': '200', 'paramName': 'Currency', 'paramValue': 'GBP'},
                                        #{'name': 'MaxPrice', 'value': '400', 'paramName': 'Currency', 'paramValue': 'GBP'}
                                       ],
                        'paginationInput': {
                                'entriesPerPage': '100',
                                'pageNumber': '100'
                                            },
                        'sortOrder': 'EndTimeSoonest'
                                    }
                        )

soup = BeautifulSoup(response.content , 'lxml')

totalitems = int(soup.find('totalentries').text)
items = soup.find_all('item')

for item in response.reply.searchResult.item:
    print(item.itemId)
    print(item.listingInfo.endTime)

Upvotes: 0

Related Questions