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
OrderorProductclass - Easy to extend: subclass
magento.Magentoand add your own methods - Transparent pagination: functions that make paginated queries return lazy iterables (generators)
- Fully typed: all functions have type hints
- 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-2025 Bixoto. See the LICENSE.
Other projects
- MyMagento: new project started in 2022 but not actively maintained as of May 2024. 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. See also OneSila’s fork.
- 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
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 pymagento-2.6.0.tar.gz.
File metadata
- Download URL: pymagento-2.6.0.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.9.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ac89fa2e6d136321913979d9c918b6de35e3685a803fcd47a88dd7ce73dcf02
|
|
| MD5 |
baa874a50d509b160c9f8cd8956cb732
|
|
| BLAKE2b-256 |
1539bf3903a5d4d00ad10bc9c91be7a77cba7efbf4b0b71199237ce0e6acc72d
|
File details
Details for the file pymagento-2.6.0-py3-none-any.whl.
File metadata
- Download URL: pymagento-2.6.0-py3-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.9.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3782306285436b8ca0f1dda01884c72f8028ebc8d3a5af3ea1291e5763ad0e71
|
|
| MD5 |
abc9d7753cddfc72ede35524598b320c
|
|
| BLAKE2b-256 |
52b03a7b8e3126f3762df6122dc8983cf732074f79ecb9f561341ec71a7cae2e
|