Skip to content

Instantly share code, notes, and snippets.

@davidtsadler
Last active February 19, 2024 03:06
Show Gist options
  • Select an option

  • Save davidtsadler/6993747 to your computer and use it in GitHub Desktop.

Select an option

Save davidtsadler/6993747 to your computer and use it in GitHub Desktop.
A very simple example showing how to make an eBay Finding API request with the ebaysdk-python (https://github.com/timotheus/ebaysdk-python). The example will do a keyword search for 'laptops' across the UK eBay site and restrict the search to the two categories Apple Laptops(111422) and PC Laptops & Netbooks(177). In addition the results are fil…
import ebaysdk
from ebaysdk import finding
api = finding(siteid='EBAY-GB', appid='<REPLACE WITH YOUR OWN APPID>')
api.execute('findItemsAdvanced', {
'keywords': 'laptop',
'categoryId' : ['177', '111422'],
'itemFilter': [
{'name': 'Condition', 'value': 'Used'},
{'name': 'MinPrice', 'value': '200', 'paramName': 'Currency', 'paramValue': 'GBP'},
{'name': 'MaxPrice', 'value': '400', 'paramName': 'Currency', 'paramValue': 'GBP'}
],
'paginationInput': {
'entriesPerPage': '25',
'pageNumber': '1'
},
'sortOrder': 'CurrentPriceHighest'
})
dictstr = api.response_dict()
for item in dictstr['searchResult']['item']:
print "ItemID: %s" % item['itemId'].value
print "Title: %s" % item['title'].value
print "CategoryID: %s" % item['primaryCategory']['categoryId'].value
@tdowgielewicz
Copy link
Copy Markdown

Great example. Thank you!

@AustinJim
Copy link
Copy Markdown

Thanks for this post. I have been trying to find out how to retrieve page 2, 3, etc up to the last page. I can't find any examples of doing this. Could you (or anyone) expand this example slightly to show how to iterate through all the pages?
Thanks!

@QuantMaverick
Copy link
Copy Markdown

QuantMaverick commented Dec 8, 2016

Hi there, I seem to encounter an error that reads "TypeError: 'ResponseDataObject' object is not subscriptable" . See below:

for item in dictstr['searchResult']['item']:
print("ItemID: %s" % item['itemId'].value)
print("Title: %s" % item['title'].value)
print("CategoryID: %s" % item['primaryCategory']['categoryId'].value)


TypeError Traceback (most recent call last)
in ()
----> 1 for item in dictstr['searchResult']:
2 print("Title: %s" % item['title'].value)

TypeError: 'ResponseDataObject' object is not subscriptable

@ChristopherJD
Copy link
Copy Markdown

ChristopherJD commented Jan 28, 2017

In ebaysdk-python/connection.py it was stated that response_dict() is DEPRECATED and to use response.dict() or response.reply instead. I used response.dict() and everything seemed to be working.

EDIT: I forgot to mention, item['itemId'].value should now be just item['itemId'].

@eddywebs
Copy link
Copy Markdown

eddywebs commented Feb 17, 2017

Ive been getting the below errors, any ideas why ?

ImportError: SDK import must be changed as follows:

- from ebaysdk import finding
+ from ebaysdk.finding import Connection as finding

Changing the line as suggested (+ from ebaysdk.finding import Connection as finding) also ends up in an error below
Traceback (most recent call last): File "ebayFind.py", line 2, in <module> from ebaysdk import Connection as finding ImportError: cannot import name Connection

@pratibhajagnere
Copy link
Copy Markdown

Hi, it is very good script. Can you please tell me how to retrieve the results after 25 items?

@Cartman0
Copy link
Copy Markdown

hi, it is good code. do you have example that run "get user" with Trading API?

@wowan90
Copy link
Copy Markdown

wowan90 commented Aug 5, 2017

HI, thanks for the script, but i get following error:

File "C:/Users/Rana/Documents/Python Scripts/untitled1.py", line 14, in
api = finding(siteid='EBAY-GB', appid='myapiid')

TypeError: 'module' object is not callable

Iam using python Python 3.6.1 |Anaconda 4.4.0 (64-bit)| with ebaysdk 2.1.4

Any idea?

@RichardEllicott
Copy link
Copy Markdown

This script seems to need several changes,

  • from ebaysdk import finding
  • from ebaysdk.finding import Connection as finding

as per previous advice, but also i cannot iterate the object:
dictstr = api.response_dict()

whatever though, i can seem to print that thing and it has the results in it somewhere, thanks for the code 👍 example but why the hell do these sites keep changing the data presentation, is it just to keep devs in work?

@caffeinatedMike
Copy link
Copy Markdown

caffeinatedMike commented Nov 25, 2017

Have you tried using api.response.dict() instead as the comment above states? According to the comment api.response_dict() is deprecated.

@tamerz
Copy link
Copy Markdown

tamerz commented Mar 12, 2018

Here is a more updated one that works for me:

from ebaysdk.finding import Connection


api = Connection(siteid='EBAY-GB', appid='<REPLACE WITH YOUR OWN APPID>', config_file=None)

api.execute('findItemsAdvanced', {
    'keywords': 'laptop',
    'categoryId': ['177', '111422'],
    'itemFilter': [
        {'name': 'Condition', 'value': 'Used'},
        {'name': 'MinPrice', 'value': '200', 'paramName': 'Currency', 'paramValue': 'GBP'},
        {'name': 'MaxPrice', 'value': '400', 'paramName': 'Currency', 'paramValue': 'GBP'}
    ],
    'paginationInput': {
        'entriesPerPage': '25',
        'pageNumber': '1'
    },
    'sortOrder': 'CurrentPriceHighest'
})

dictstr = api.response.dict()

for item in dictstr['searchResult']['item']:
    print('ItemID: {}'.format(item['itemId']))
    print('Title: {}'.format(item['title']))
    print('CategoryID: {}'.format(item['primaryCategory']['categoryId']))

@macdonjo
Copy link
Copy Markdown

@tamerz - I also get this error with yours too.

TypeError: 'ResponseDataObject' object has no attribute '__getitem__'

@psongm01
Copy link
Copy Markdown

Thanks for the example! On the 'itemFilter', can we have more than one conditions? e.g., Used and Very Good

@fernandofot
Copy link
Copy Markdown

HI guys, thanks for the script, I get some error.

Traceback (most recent call last):
File "finding.py", line 2, in
from ebaysdk.finding import Connection as finding
ModuleNotFoundError: No module named 'ebaysdk'

@josjaf
Copy link
Copy Markdown

josjaf commented Aug 9, 2019

I don't think anybody answered the pagination question. Any ideas?

@snehilchopra
Copy link
Copy Markdown

I keep getting the following error, whenever i try to run any of the examples above. Any clues as to what might be the issue?

'findItemsAdvanced: Internal Server Error, Domain: Security, Severity: Error, errorId: 10001, Service call has exceeded the number of times the operation is allowed to be called'

@josjaf
Copy link
Copy Markdown

josjaf commented Aug 24, 2019

Sounds like you are out of API calls

@ggg22
Copy link
Copy Markdown

ggg22 commented Feb 9, 2020

This was asked before but no reply and wonder if somebody can assist since documentation is not clear on this.

{'name': 'Condition', 'value': 'Used'},

how to add another value above. This is a more general question and not only related to the Condition filter. There are many filters that support multiple values and I wish there are examples how to do this in this SDK since it's pretty basic feature. All examples are showing a single value only.

@fsmosca
Copy link
Copy Markdown

fsmosca commented Mar 31, 2020

I don't think anybody answered the pagination question. Any ideas?

Perhaps put the whole thing in the function and make the page a variable.

def find_item_advanced(page_num):
    api = Connection( ...
    ....
    'pageNumber': page_num
    ...

def main():
    total_pages = 8  # Input
    total_pages = min(total_pages, 100)

    for p in range(1, total_pages + 1):
        find_item_advanced(p)

if __name__ == '__main__':
    main()

Ref: https://developer.ebay.com/DevZone/finding/CallRef/findItemsIneBayStores.html#Request.paginationInput

...
You can return up to the first 100 pages of the result set by issuing multiple requests and specifying, in sequence, the pages to return.
Min: 1. Max: 100. Default: 1.

@Dhairya40
Copy link
Copy Markdown

Hi every one can any one please show me how to change ebay order status python api? Please

@fsmosca
Copy link
Copy Markdown

fsmosca commented Apr 3, 2020

Hi every one can any one please show me how to change ebay order status python api? Please

I saw orders.py from ebaysdk-python. This might help in what your are trying to achieve.
https://github.com/timotheus/ebaysdk-python/blob/master/ebaysdk/poller/orders.py

@carlcrott
Copy link
Copy Markdown

Anyone know of a replacement for the dump module for python3?

@brianmcaudill
Copy link
Copy Markdown

#This file contains all the above fixes and is working for me as of 09-June-2020

import ebaysdk
from ebaysdk.finding import Connection as finding

api = finding(domain='svcs.sandbox.ebay.com', debug=True, appid='YOUR_APP_ID', config_file=None)

api.execute('findItemsAdvanced', {
'keywords': 'laptop',
'categoryId' : ['177', '111422'],
'itemFilter': [
{'name': 'Condition', 'value': 'Used'},
{'name': 'MinPrice', 'value': '200', 'paramName': 'Currency', 'paramValue': 'GBP'},
{'name': 'MaxPrice', 'value': '400', 'paramName': 'Currency', 'paramValue': 'GBP'}
],
'paginationInput': {
'entriesPerPage': '25',
'pageNumber': '1'
},
'sortOrder': 'CurrentPriceHighest'
})

dictstr = api.response.dict()

for item in dictstr['searchResult']['item']:
print("ItemID: %s" % item['itemId'])
print("Title: %s" % item['title'])
print("CategoryID: %s" % item['primaryCategory']['categoryId'])

@Dhairya40
Copy link
Copy Markdown

Dhairya40 commented Jun 12, 2020 via email

@PhilipPhil
Copy link
Copy Markdown

How to filter out sellers you don't like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment