Git Product home page Git Product logo

python-bol-api's Introduction

python-bol-api

A Python wrapper for the bol.com API. Currently rather incomplete, as it offers only those methods required for my own projects so far.

Open API

Instantiate the API:

>>> from bol.openapi.api import OpenAPI
>>> api = OpenAPI('api_key')

Invoke a method:

>>> data = api.catalog.products((['1004004011187773', '1004004011231766'])

JSON data is returned "as is":

>>> data['products'][0]['ean'] u'0093155141650'

Plaza API

Instantiate the API:

>>> from bol.plaza.api import PlazaAPI
>>> api = PlazaAPI('public_key', 'private_key', test=True)

Invoke a method:

>>> open_orders = api.orders.open()

Fields are derived 1:1 from the bol.com API XML, including CamelCase conventions:

>>> open_orders[0].Buyer.BillingDetails.Streetname
'Billingstraat'

Fields are properly typed:

>>> open_orders[0].Paid
True
>>> open_orders[0].OpenOrderItems[0].TransactionFee
Decimal('19.12')
>>> open_orders[0].DateTimeDropShipper
datetime.datetime(2014, 2, 10, 12, 7, 7)

Access the underlying XML:

>>> from xml.etree import ElementTree
>>> ElementTree.tostring(open_orders[0].Buyer.BillingDetails.xml)
'<ns0:BillingDetails xmlns:ns0="http://plazaapi.bol.com/services/xsd/plazaapiservice-1.0.xsd"><ns0:SalutationCode>02</ns0:SalutationCode><ns0:FirstName>Jans</ns0:FirstName><ns0:Surname>Janssen</ns0:Surname><ns0:Streetname>Billingstraat</ns0:Streetname><ns0:Housenumber>1</ns0:Housenumber><ns0:HousenumberExtended>a</ns0:HousenumberExtended><ns0:AddressSupplement>Onder de brievanbus huisnummer 1</ns0:AddressSupplement><ns0:ZipCode>5000 ZZ</ns0:ZipCode><ns0:City>Amsterdam</ns0:City><ns0:CountryCode>NL</ns0:CountryCode><ns0:Email>[email protected]</ns0:Email><ns0:Telephone>67890</ns0:Telephone><ns0:Company>Bol.com</ns0:Company></ns0:BillingDetails>'

Running the tests

First, make sure that you have tox installed on your system:

pip install tox

Then, just run the tox:

tox

python-bol-api's People

Contributors

pennersr avatar

Watchers

Vincent van Leeuwen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.