Python client for the Magento 2 API
Project description
PyMagento
PyMagento is a Python client for the Magento 2 API. Its goal is to provide an easy-to-use Pythonic interface to the Magento 2 API, while being lightweight and extendable.
Features:
- Lightweight: entities are returned as plain dictionaries; there is no custom
Order
orProduct
class - Easy to extend: subclass
magento.Magento
and add your own methods - Transparent pagination: functions that make paginated queries return lazy iterables (generators)
- Fully typed: all functions have type hints if necessary
- Production-ready: at Bixoto, we use PyMagento in production since 2020
- Python 3.8+ support
- MIT license
Note: PyMagento is not affiliated to nor endorsed by Adobe or the Magento team.
Install
Pip
python -m pip install pymagento
Poetry
poetry add pymagento
Usage
import magento
client = magento.Magento(base_url="...", token="...", scope="all")
product = client.get_product("SKU123")
print(magento.get_custom_attribute(product, "description"))
# Get orders by status
for order in client.get_orders(status="processing"):
print(order["increment_id"], order["grand_total"])
# Make more complex queries
query = magento.make_search_query([
[("customer_email", "billgates@example.com", "eq")],
[("status", "complete", "eq")],
])
for order in client.get_orders(query=query, limit=10):
print(order["increment_id"], len(order["items"]))
For more information, read the docs.
Note: not all endpoints are implemented with dedicated methods. You can call them with
client.get_json_api("/V1/...")
for GET
endpoints and client.post_json_api("/V1/...", json=...)
.
License
Copyright 2020-2024 Bixoto. See the LICENSE
.
Other projects
- MyMagento: new project started in 2022; MyMagento didn’t exist when we started PyMagento. This is a more high-level API that can be a good fit if you’re not familiar with Magento’s API.
- PyMagento-REST (abandoned)
- bialecki/pymagento: Magento 1.x only (abandoned)
- python-magento: Magento 1.x only (abandoned)
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
File details
Details for the file pymagento-2.0.2.tar.gz
.
File metadata
- Download URL: pymagento-2.0.2.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.9.18 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90ded82347bae7af3cbfad72e71f715f6689a69830be417eddc7059a26127149 |
|
MD5 | 582ebec018e1028f99cb3dbcf2b5e919 |
|
BLAKE2b-256 | f4f2250f7bf1dfa90c1ff285947c1524cbab9dcba3558324e4cb5fd6da9341af |
File details
Details for the file pymagento-2.0.2-py3-none-any.whl
.
File metadata
- Download URL: pymagento-2.0.2-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.9.18 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0125d1e77a51188d2e684b43492fe496c11e410384b4cb772cd0f6c005a98fe4 |
|
MD5 | e0058e58e1cf930bd4f298d8563d4a30 |
|
BLAKE2b-256 | 3ef3fd2f6b6ac08a6a2fc399d91f996aebfd18ec52e0409852a2c867675deb7a |