Skip to main content

Python Magento 2 REST API Wrapper

Project description

Magento Logo

A Python package that wraps and extends the Magento 2 REST API

Explore the docs »

PyPI Version GitHub Repository https://static.pepy.tech/personalized-badge/my-magento?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads Documentation Status

About MyMagento

MyMagento simplifies interaction with the Magento 2 REST API

If you’ve worked with the Magento 2 API, you’ll know that not all endpoints are created equally.

MyMagento aims to streamline your workflow by simplifying a variety of commonly needed API operations.

Main Components

Available Endpoints

The following endpoints are currently wrapped with a Model and SearchQuery subclass

Endpoint

Client Attribute

SearchQuery Subclass

Model Subclass

orders

Client.orders

OrderSearch

Order

orders/items

Client.order_items

OrderItemSearch

OrderItem

invoices

Client.invoices

InvoiceSearch

Invoice

products

Client.products

ProductSearch

Product

products/attributes

Client.product_attributes

ProductAttributeSearch

ProductAttribute

categories

Client.categories

CategorySearch

Category

Installation

Documentation

Full documentation can be found on ReadTheDocs

QuickStart: Login with MyMagento

💡 Tip

See logging-in for full details on generating an access token

Setting the Login Credentials

The credentials of your Magento 2 admin account are used to initialize and authenticate() a Client

>> domain = 'website.com'
>> username ='username'
>> password = 'password'

If you’re using a local installation of Magento, your domain should look like this:

>> domain = '127.0.0.1/path/to/magento'

Getting a Client

MyMagento uses the Client in one of two ways

Method 1: Initialize a Client

from magento import Client

>>> api = Client(domain, username, password)

|[ MyMagento | website_username ]|:  Authenticating username on website.com...
|[ MyMagento | website_username ]|:  Logged in to username

Method 2: Initialize a Client with get_api()

The get_api() method uses the same keyword arguments as the Client, but will try using environment variable values if the domain, username, or password are missing

import magento

>>> api = magento.get_api()

|[ MyMagento | website_username ]|:  Authenticating username on website.com...
|[ MyMagento | website_username ]|:  Logged in to username

Now let’s start interacting with the api

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

my-magento-2.1.0.tar.gz (33.8 kB view hashes)

Uploaded Source

Built Distributions

my_magento-2.1.0-py3.10.egg (88.0 kB view hashes)

Uploaded Source

my_magento-2.1.0-py3-none-any.whl (36.8 kB view hashes)

Uploaded Python 3

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