Skip to content
Seifollahi edited this page Aug 31, 2020 · 15 revisions

The eBay Trading API offers secure, authenticated access to private eBay data. Use the eBay Trading API to build applications such as selling and post-sales management applications, manage User information, and initiate the item purchase flow on eBay.

Usage

from ebaysdk.trading import Connection as Trading
from ebaysdk.exception import ConnectionError

try:    
    api = Trading(appid="YOUR_APPID", devid="YOUR_DEVID", certid="YOUR_CERTID", token="YOUR_AUTH_TOKEN", config_file=None)
    response = api.execute('GetUser', {})
    print(response.dict())
    print(response.reply)
except ConnectionError as e:
    print(e)
    print(e.response.dict())

Usage With YAML

Place a YAML file in your home or /etc/ directory and reference that filename when constructing the object. The default YAML filename is "ebay.yaml". If you use this name, it will automatically get picked up.

from ebaysdk.trading import Connection as Trading
api = Trading(config_file='myfile.yaml')
response = api.execute('GetUser', {})
print(response.dict())
print(response.reply)

Sandbox Usage

from ebaysdk.trading import Connection as Trading
api = Trading(domain='api.sandbox.ebay.com', 
              appid="YOUR_APPID", devid="YOUR_DEVID", certid="YOUR_CERTID", token="YOUR_AUTH_TOKEN")
response = api.execute('GetUser', {})
print(response.dict())
print(response.reply)

Public Methods

Trading(**kwargs)

Keyword arguments to Trading() constructor

domain        -- API endpoint (default: api.ebay.com)
config_file   -- YAML defaults (default: ebay.yaml)
debug         -- debugging enabled (default: False)
warnings      -- warnings enabled (default: False)
errors        -- warnings enabled (default: True)
uri           -- API endpoint uri (default: /ws/api.dll)
appid         -- eBay application id
devid         -- eBay developer id
certid        -- eBay cert id
token         -- eBay application/user token
siteid        -- eBay country site id (default: 0 (US))
compatibility -- version number (default: 648)
https         -- execute of https (default: True)
proxy_host    -- proxy hostname
proxy_port    -- proxy port number
timeout       -- HTTP request timeout (default: 20)
parallel      -- ebaysdk parallel object
response_encoding -- API encoding (default: XML)
request_encoding  -- API encoding (default: XML)

execute(verb, data)

Execute the HTTP request.

response = api.execute('GetUser', {})

error()

Returns a string of the HTTP call errors

if api.error():
    print "has errors: %s" % api.error()

response.dom()

Return a DOM object (lxml dom) of the HTTP response content.

response.dict()

Return a dictionary of the HTTP response content.

response.content

Return the string content from the HTTP response call.

response.reply

Return a response data object.

response_code()

Return the HTTP response code.

response_status()

Return the HTTP response status.

response_codes()

Return an array of eBay response codes.

API Use Cases

  • Unpaid Item Disputes
  • Listing Items
  • Retrieving the Category Hierarchy for a Site
  • Retrieving the Data for One Item
  • Retrieving the Order Line Items for a Single Item
  • Retrieving the Order Line Items for a Specific Seller
  • Retrieving User Information
  • Searching for Items
  • Working with Seller Events

see more

More Examples

see samples