Skip to main content

Wrapper for the bol.com Retailer API (v5)

Project description

python-bol-retailer-api

Wrapper for the bol.com Retailer API (v5)

Install

This package is published on PyPi: https://pypi.org/project/python-bol-retailer-api/

Install with pip

pip install python-bol-retailer-api

Usage

Usage at this point is minimal. I will extend this package as I go and as I need.

Current usage is limited to Orders.

Create connection

You will need a Client ID and Client Secret generated by Bol. Generate these here: https://partner.bol.com/sdd/settings.html#!/services/api

Create a new API connection

from bol.api import BolAPI
api = BolAPI(clientId, clientSecret)

Access token is automatically stored for later use. In the event that an access token is expired, a new access token will be requested and the initial request will be resend. This should ensure that the connection is never cut off.

The API keeps in account the rate limits that bol.com apply. In the event that the rate limit is almost exhausted within a timeframe, the API will stall until a new timeframe with new rate limits is available.

Orders

Get all orders

By default all orders will be returned

orderlist = api.orders.list()

You can specify the method and status yourself. Standard method is FBR and standard status is ALL.

orderlist = api.orders.list(method='FBB', status='OPEN')

This will return an OrderList object. You can loop over the orders like so:

for order in orderlist.orders:
    print(order.orderId)

Each order contains a list of OrderItem objects:

 for item in order.orderItems:
      print(item.orderItemId)

Get specific order

To get more info about an order, you can get the specific details of an order by its ID.

order = api.orders.get(id)

This will return an Order object.

Ship an order

There are two ways to ship an order: you either ship an item of the order, or you ship the whole order at once. When shipping an item, an OrderItem object is expected. When shipping an order, an Order object is expected. Optionally you can add the shipmentReference, shippingLabelId, transporterCode and trackAndTrace. Consult the Bol documentation to know what is expected.

There is a list of transportercodes that you can use.

api.orders.shipItem(item, transporterCode=api.transporters.GLS, trackAndTrace='XXXXXX')
api.orders.ship(order, transporterCode=api.transporters.UPS, trackAndTrace='XXXXXX')

Cancel an order

There are two ways to cancel an order: you either cancel an item of the order, or you cancel the whole order at once. when cancelling an item, an OrderItem object is expected. When cancelling an order, an Order object is expected. A cancellation expects a reason for the cancellation. There is a list of reasons that you can use.

api.orders.cancelItem(item, reason=api.reasons.OUT_OF_STOCK)
api.orders.cancel(order, reason=api.reasons.NOT_AVAIL_IN_TIME)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-bol-retailer-api-0.5.0.tar.gz (21.6 kB view details)

Uploaded Source

File details

Details for the file python-bol-retailer-api-0.5.0.tar.gz.

File metadata

  • Download URL: python-bol-retailer-api-0.5.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.4

File hashes

Hashes for python-bol-retailer-api-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a4e84ac132b5a7f05b42c9e75d308d2fd8807ec1247fc275b45de1acd4639465
MD5 e0c4e15e12b802f24c647018259c554c
BLAKE2b-256 62511a1e0acbe8404cd63f7fe38b0f76a8ce4cce3426513e5dadee0e2ed4bcb3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page