An eBay API client which respects (XSD) schema* and talks SOAP, but doesn't use Suds.
With a clean and simple interface and low memory usage.
>>> from dirtyebay import ShoppingAPI >>> client = ShoppingAPI() >>> r = client.GetSingleItem(ItemID='321021906488', IncludeSelector='ItemSpecifics') >>> r.Item.ItemID 321647696835
- First you need to get yourself some developer keys from eBay here
- You need to make an
ebay.conffile in the root of your project (or
export DIRTYEBAY_CONFIG_PATH=<path to conf>in your shell)
- Easiest way is to copy
ebay.conf-examplefrom this repo and fill in the blanks.
site_idis the code of the eBay site your profile is on.
- Make an
ebay.sandbox.conffile in the root of your project (or
export DIRTYEBAY_SANDBOX_CONFIG_PATH=<path to conf>in your shell) if you want to use the ebay api sandbox
That's it. Well, you need to read the docs (eg here's the Trading API) to see how to make the calls you want.
All of the API classes take a
sandbox kwarg. This is mostly only useful on the Trading API where your calls can have real effects! This will cause dirtyebay to use your sandbox conf file and the eBay sandbox API endpoints.
from dirtyebay import TradingAPI client = TradingAPI(sandbox=True) client.GetItem(ItemID="321021906488")
Why the name?
I previously made this: https://github.com/anentropic/ebaysuds
I thought it was nice that eBay provided a WSDL and Python had Suds and by putting the two together you get a very nice interface where responses are intelligently deserialized into appropriate python objects etc.
However the eBay TradingAPI WSDL is enormous (> 5MB) and the resulting memory usage of Suds was unacceptable (> 360MB). So ... no Suds => dirtyebay
There is an official eBay Python SDK which you should probably just use instead:
They have a pretty nice interface and avoid using Suds and SOAP so memory usage is fine (~ 20MB on comparable calls). The trade-off is they don't make any use of the schema so deserialization is (necessarily) best-effort and a bit crufty.
Why make this then?
eBay provide an XSD for some services, and anyway a WSDL file typically contains a whole XSD schema embedded in it (along with descriptions of endpoints and possible calls)... so I started playing around with that and found to my surprise that using
lxml.objectify in conjunction with the XSD schema* gives you all the nice deserialization like Suds did, but with < 10% the memory usage (~ 30-35MB). And it's pretty fast too.
This seemed like a good compromise. Also, I'd already made some stuff on top of
ebaysuds, so I decided to do a rewrite that preserves the interface but uses XSD schema instead of Suds+WSDL hell.
* for what this actually gives in practice see: http://lxml.de/objectify.html#asserting-a-schema