timotheus / ebaysdk-python

eBay API SDK for Python
https://developer.ebay.com/tools/sdks
Other
807 stars 327 forks source link

Calling Shopping API with ProductID #204

Open ackleyd1 opened 7 years ago

ackleyd1 commented 7 years ago

How can you format the data so you can search by productID? Im using findProducts in the Shopping API. I could do a call like this

from ebaysdk.exception import ConnectionError
from ebaysdk.shopping import Connection as Shopping
try:    
    api = Shopping(appid="APP_ID")
    response = api.execute('FindProducts', {'QueryKeywords': 'pokemon ruby', 'DomainName': 'Video Games'})
    print(response.dict())
except ConnectionError as e:
    print(e)
    print(e.response.dict())

instead I want to do something like this but I'm not exactly sure how it works

from ebaysdk.exception import ConnectionError
from ebaysdk.shopping import Connection as Shopping
try:    
    api = Shopping(appid="APP_ID")
    response = api.execute('FindProducts', {'ProductID': {'_type': 'ReferenceID', 'value': '10291'}, 'DomainName': 'Video Games'})
    print(response.dict())
except ConnectionError as e:
    print(e)
    print(e.response.dict())

has anyone had any success using the product id in the data?

brianwawok commented 6 years ago

@ackleyd1 way old response, but for future you.. you have to hack it a bit

    params = {'ProductID': {
        '#text': upc,
        '@attrs': {'type': 'UPC'}
    }}
response = api.execute('FindProducts', params)
ackleyd1 commented 6 years ago

@brianwawok Thanks! can you do the same with findCompletedItems?