Unofficial client for the BigCommerce API
Project description
bigc
An unofficial Python client for the BigCommerce API.
Installation
pip install bigc
Usage
To authenticate, you'll need the BigCommerce store's hash and an access token.
from bigc import BigCommerceAPI
store_hash = '000000000'
access_token = '0000000000000000000000000000000'
bigcommerce = BigCommerceAPI(store_hash, access_token)
order = bigcommerce.orders_v2.get(101)
list_of_orders = list(bigcommerce.orders_v2.all(params={'customer_id': 1}))
The following resources are currently supported:
carts_v3categories_v3checkouts_v3currencies_v2customers_v3customer_groups_v2orders_v2orders_v3pricing_v3products_v3product_variants_v3webhooks_v3
Exceptions
If a request is not successful, bigc will raise an exception inheriting from BigCommerceException. The full exception hierarchy is available in bigc.exceptions. Most exceptions correspond to a specific status code (e.g. DoesNotExistError will be raised for 404s).
If BigCommerce provides an error message in its response, it will be available as exc.message. More detailed error information may be available as exc.errors.
Timeouts
A timeout may be set on individual requests, or a default may be set for all requests. This specifies the maximum amount of time, in seconds, that may pass between receiving data from the server.
If a request times out, a GatewayTimeoutError will be raised.
from bigc import BigCommerceAPI
bigcommerce = BigCommerceAPI('store_hash', 'access_token', timeout=7)
bigcommerce.checkouts_v3.create_order('checkout_id', timeout=16)
Automatic Retries
bigc can automatically retry requests that fail due to network problems or certain types of server errors. You can specify the maximum number of retries as a default for all GET requests, or on a per-request basis.
from bigc import BigCommerceAPI
bigcommerce = BigCommerceAPI('store_hash', 'access_token', get_retries=2)
bigcommerce.customers_v3.get(1, retries=5)
Direct API Access
For resources that aren't officially supported yet, bigc also includes a flexible API client that can be used to make direct requests to the BigCommerce API.
from bigc import BigCommerceAPI
bigcommerce = BigCommerceAPI('store_hash', 'access_token')
product = bigcommerce.api_v3.get('/products/77', params={'include': 'videos'})
order_messages = list(bigcommerce.api_v2.get_many('/orders/101/messages'))
Utilities
Some extra utility functions that don't interact with the BigCommerce API are available in bigc.utils.
bigc.utils.parse_rfc2822_date: Convert an RFC-2822 date (used by some BigCommerce APIs) to adatetime
Constants
For convenience, some constants are made available in bigc.data.
bigc.data.BigCommerceOrderStatus: AnIntEnumof order statuses and their IDs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bigc-1.0.0.tar.gz.
File metadata
- Download URL: bigc-1.0.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a3f9500b40cd1da19bf4ddebf96a810fc45b45546b2807d1afdb3738af25f7e
|
|
| MD5 |
af4a4106d17b2bcbf02400afdd4572ae
|
|
| BLAKE2b-256 |
36b7fca26fb487b0f5d826a307dce89ff152639a1d9e8390c8edea9c6fe8268b
|
File details
Details for the file bigc-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bigc-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
550b434bbafe19341c00ca8a07b9341f486d4c7ab1ec711038545a870903dbb9
|
|
| MD5 |
112c08779a2c4ef01ec27f7b5ca6b4f1
|
|
| BLAKE2b-256 |
77d94e0c1a9e5aa1611ac828d87298e3b285846752291aec1e3d6088a60bb4dc
|