https://github.com/adamlwgriffiths/woob
Pythonic Woo Commerce API wrapper
https://github.com/adamlwgriffiths/woob
python woocommerce woocommerce-api wrapper wrapper-api
Last synced: 11 months ago
JSON representation
Pythonic Woo Commerce API wrapper
- Host: GitHub
- URL: https://github.com/adamlwgriffiths/woob
- Owner: adamlwgriffiths
- License: bsd-2-clause
- Created: 2022-11-19T10:14:29.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-19T10:15:03.000Z (over 3 years ago)
- Last Synced: 2025-01-29T15:35:03.262Z (over 1 year ago)
- Topics: python, woocommerce, woocommerce-api, wrapper, wrapper-api
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Woob
Pythonic WooCommerce API wrapper.
## Usage
```
from woob import Woo
from datetime import datetime, timedelta
# either pass in your woocommerce credentials
woo = Woo(
url=url,
consumer_key=consumer_key,
consumer_secret=consumer_secret,
)
# or pass an existing api connection directly
# woo = Woo(api=existing_woo_api)
# collections support iteration
for order in woo.orders:
print(order)
for refund in order.refunds:
print(refund)
for customer in woo.customers:
print(customer)
for product in woo.products:
print(product)
# iterate taxes
for tax_rate in woo.taxes:
print(tax_rate)
# filter objects using woo api filters
end_date = datetime.now()
start_date = end_date - timedelta(days=7)
last_7_days = woo.orders.filter_by(
modified_after=start_date.isoformat(),
modified_before=end_date.isoformat()
)
# collections support access by id
# in this case, an order
order_id = '123'
order = woo.orders[order_id]
# all objects support serialisation
data = order.serialise()
# all collections support serialisation
orders = woo.orders.serialise()
# convenience functions / wrappers around filter_by
# get orders by customer
customer_id = '123'
for order in woo.orders.for_customer(customer_id):
print(order)
# orders after a certain date
for order in woo.orders.modified_after(start_date):
print(order)
```