timotheus / ebaysdk-python

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

Get item's MPN #187

Open ysa7 opened 7 years ago

ysa7 commented 7 years ago

How can I get item's MPN?

I imagine it would be something along the lines below, but I don't know which arguments I have to provide and how.

api.execute('GetItem',{})

timotheus commented 7 years ago

What's MPN?

ysa7 commented 7 years ago

It stands for "Manufacturer Part Number".

You type it in when you create a listing like you type in a title, brand, price, subtitle...

This might be helpful: http://developer.ebay.com/devzone/xml/docs/Reference/ebay/types/BrandMPNType.html

If you could tell me how to get for example the title of the item with "GetItem" and the given ItemID, hopefully I will be able to figure it out.

timotheus commented 7 years ago

You can use the shopping API for this. Here's a test that show a GetSingleItem call.

https://github.com/timotheus/ebaysdk-python/blob/master/tests/test_errors.py#L23

ysa7 commented 7 years ago

Ok, here's what I tried:

api.execute('GetItem', {'ItemID':ItemID,'IncludeSelector':['Title']}) It returns: <ebaysdk.response.Response object at 0x03113C90> None

api.execute('GetSingleItem', {'ItemID':ItemID,'IncludeSelector':['Title']}) It gives an error: ebaysdk.exception.ConnectionError: 'GetSingleItem: Class: RequestError, Severity: Error, Code: 2, Unsupported API call. The API call "GetSingleItem" is invalid or not supported in this release.'

timotheus commented 7 years ago

Here are the docs

https://developer.ebay.com/devzone/shopping/docs/CallRef/index.html

Make sure you're using the shopping backend and not the trading backend.

ysa7 commented 7 years ago

I appreciate your help Tim.

The backend was set to trading and I changed it to shipping, but it still doesn't work.

Here is the code:

from ebaysdk.shopping import Connection as Shopping

api = Shopping(appid='&',certid='&',devid='&',token='&')
ItemID=&
a = print (api.execute('GetSingleItem',{'ItemID':ItemID,'IncludeSelector':['Title']}))
print(a)

The response:

<ebaysdk.response.Response object at 0x003A3B10> None

timotheus commented 7 years ago

Please enable debug and send the entire request/response.

Tim

Sent from my iPhone

On Apr 11, 2017, at 2:56 PM, ysa7 notifications@github.com wrote:

I appreciate your help Tim.

The backend was set to trading and i changed it to shipping, but it still doesn't work.

`from ebaysdk.shopping import Connection as Shopping

api = Shopping(appid='&',certid='&',devid='&',token='&')

ItemID=&

a = print (api.execute('GetSingleItem',{'ItemID':ItemID,'IncludeSelector':['Quantity']}))

print(a)`

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ysa7 commented 7 years ago

The code:

from ebaysdk.shopping import Connection as Shopping

api = Shopping(appid='&',certid='&',devid='&',token='&',debug=True)
ItemID=&
a = print (api.execute('GetSingleItem',{'ItemID':ItemID,'IncludeSelector':['Title']}))
print(a)

The response:

C:\Python36\python.exe C:/Users/Workshop/PycharmProjects/Ebay1/first.py
2017-04-12 10:22:00,055 ebaysdk [DEBUG]:execute: verb=GetSingleItem data={'ItemID': &, 'IncludeSelector': ['Title']}
2017-04-12 10:22:00,056 ebaysdk [DEBUG]:REQUEST (f1ff75e9-c3ef-4108-babe-ed71211f92ba): POST http://open.api.ebay.com/shopping
2017-04-12 10:22:00,056 ebaysdk [DEBUG]:headers={'X-EBAY-API-VERSION': '799', 'X-EBAY-API-APP-ID': 'VK-Lister-PRD-62442a3e5-ec3455ba', 'X-EBAY-API-SITE-ID': '0', 'X-EBAY-API-CALL-NAME': 'GetSingleItem', 'X-EBAY-API-REQUEST-ENCODING': 'XML', 'Content-Type': 'text/xml', 'User-Agent': 'eBaySDK/2.1.4 Python/3.6.0 Windows/7', 'X-EBAY-SDK-REQUEST-ID': 'f1ff75e9-c3ef-4108-babe-ed71211f92ba', 'Content-Length': '192'}
2017-04-12 10:22:00,056 ebaysdk [DEBUG]:body=b'<?xml version=\'1.0\' encoding=\'utf-8\'?><GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents"><IncludeSelector>Title</IncludeSelector><ItemID>192127984939</ItemID></GetSingleItemRequest>'
2017-04-12 10:22:00,522 ebaysdk [DEBUG]:RESPONSE (f1ff75e9-c3ef-4108-babe-ed71211f92ba):
2017-04-12 10:22:00,522 ebaysdk [DEBUG]:elapsed time=0:00:00.458027
2017-04-12 10:22:00,522 ebaysdk [DEBUG]:status code=200
2017-04-12 10:22:00,522 ebaysdk [DEBUG]:headers={'Content-Type': 'text/xml;charset=utf-8', 'Cache-Control': 'no-cache', 'Expires': 'Sat, 25 Dec 1999 00:00:00 GMT', 'GUID': '15b61415-0910-a566-9923-5ea3fdf627d0', 'Last-Modified': 'Wed, 12 Apr 2017 08:22:02 GMT', 'Pragma': 'no-cache', 'Server': 'Apache-Coyote/1.1', 'X-EBAY-API-BUILD-TAG': 'E981_CORE_APILW_4424327_R1', 'X-EBAY-API-POOL-NAME': '___cDRidW9rdGZpdWY=', 'X-EBAY-API-SERVER-NAME': '___ZW9nNGQ3MmYrZTMxZCgyNSg+NSs+Ni00NzU5PTY/Mw==', 'X-EBAY-REQUEST-ID': '15b61415-0910-a566-9923-5ea3fdf627d0!shopping!10.86.105.146!esbshopping[]', 'Date': 'Wed, 12 Apr 2017 08:22:01 GMT', 'Transfer-Encoding': 'chunked'}
2017-04-12 10:22:00,523 ebaysdk [DEBUG]:content=<?xml version="1.0" encoding="UTF-8"?>

  <GetSingleItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
   <Timestamp>2017-04-12T08:22:02.197Z</Timestamp>
   <Ack>Success</Ack>
   <Build>E981_CORE_APILW_4424327_R1</Build>
   <Version>981</Version>
   <Item>
    <ItemID>192127984939</ItemID>
    <EndTime>2017-04-13T09:36:06.000Z</EndTime>
    <ViewItemURLForNaturalSearch>http://www.ebay.com/itm/SERVOSTAR-610-Cable-SR6-6SMx7-6SM-10m-Mat-Nr-89952-CAB-I-157-/192127984939</ViewItemURLForNaturalSearch>
    <ListingType>FixedPriceItem</ListingType>
    <Location>Seoul</Location>
    <GalleryURL>http://thumbs4.ebaystatic.com/pict/1921279849398080_2.jpg</GalleryURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/j~IAAOSwzgBYx7k6/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/bNoAAOSwax5YxRsf/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/dDsAAOSwWxNYxRsq/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/O~IAAOSwuxFYxRsx/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/cA8AAOSwax5YxRs3/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/PTcAAOSwuxFYxRs7/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/kYQAAOSwzgBYxRs~/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/VnwAAOSwol5YxRtC/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/G0kAAOSwsW9Yx7kx/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/dXsAAOSw4A5Yx7k0/$_1.JPG?set_id=8800005007</PictureURL>
    <PictureURL>http://i.ebayimg.com/00/s/MTA2N1gxNjAw/z/b3IAAOSwWxNYx7k3/$_1.JPG?set_id=8800005007</PictureURL>
    <PrimaryCategoryID>181735</PrimaryCategoryID>
    <PrimaryCategoryName>Business &amp; Industrial:Automation, Motors &amp; Drives:Electric Motors:Other Electric Motors</PrimaryCategoryName>
    <BidCount>0</BidCount>
    <ConvertedCurrentPrice currencyID="USD">199.9</ConvertedCurrentPrice>
    <ListingStatus>Active</ListingStatus>
    <TimeLeft>P1DT1H14M4S</TimeLeft>
    <Title>SERVOSTAR 610 Cable SR6-6SMx7 6SM 10m Mat.Nr 89952 CAB-I-157</Title>
    <Country>KR</Country>
    <AutoPay>false</AutoPay>
    <ConditionID>3000</ConditionID>
    <ConditionDisplayName>Used</ConditionDisplayName>
    <ConditionDescription>It was removed from machine of good condition. But the parts has minor scratch and used marks. Review through the photo. Fortunately, keeps good working and cosmetic condition. Other stock&apos;s condition is almost same. If you want to review other, please contact us.</ConditionDescription>
   </Item>
  </GetSingleItemResponse>

2017-04-12 10:22:00,531 ebaysdk [DEBUG]:total time=0.47502732276916504
<ebaysdk.response.Response object at 0x00483B10>
None

Process finished with exit code 0
ysa7 commented 7 years ago

Still not working.

cpburnz commented 7 years ago

@ysa7 The problem is that you're assigning the result from print() (which will always be None) to a.

a = print(api.execute(...))
# <ebaysdk.response.Response object at 0x00483B10>
print(a)
# None

You should assign the response first, and then print it:

a = api.execute(...)
print(a)
# <ebaysdk.response.Response object at 0x00483B10>
chatlourd commented 6 years ago

The initial question was never answered so in order to get the MPN you need to request the ItemSpecifics with the IncludeSelector. More info can be found here if you scroll all the way down to Sample: Product Details and Item Condition

Here is a sample code that should get your all the itemspecifics (note that you need to change the ItemID to a valid one otherwise it will throw an error":

import ebaysdk
from ebaysdk.shopping import Connection as shopping

api = shopping(siteid='EBAY-FR', appid='YOUR-APP-ID')

response = api.execute('GetSingleItem', {
                'ItemID': '99999999999',
                'IncludeSelector': ['ItemSpecifics']
            })

print(response.dict())