Skip to main content

Python client for the Magento 2 API

Project description

PyMagento

PyPI version PyPI downloads

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 or Product 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


Download files

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

Source Distribution

pymagento-2.0.1.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

pymagento-2.0.1-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file pymagento-2.0.1.tar.gz.

File metadata

  • Download URL: pymagento-2.0.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.18 Linux/6.8.0-1014-azure

File hashes

Hashes for pymagento-2.0.1.tar.gz
Algorithm Hash digest
SHA256 2ec7660b4041a48f892a685dfedff0ad1edd78e0a5c3252fb9dc0fc0bcd934ef
MD5 fb75063b091e54636ee7824f6aeb29a8
BLAKE2b-256 b7b2f467f904e690fcbba06cd40da84f2a7cca740b7893be0b2b298f5a96bceb

See more details on using hashes here.

File details

Details for the file pymagento-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: pymagento-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.18 Linux/6.8.0-1014-azure

File hashes

Hashes for pymagento-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4a04b7c03aa1f688bb0f990ffd5f3963af68b3b7450f3abd17c427a91ad0e07
MD5 ae4a2c6c03cc8c07a273e82c126880a4
BLAKE2b-256 b37b7066e69884ef1dc7d99c015787751df52767fdb168df088dc4e244607f90

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