PHPackages                             ptchr/magento2-rest-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. ptchr/magento2-rest-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ptchr/magento2-rest-client
==========================

Magento 2 rest api client

2.14(3y ago)31.3k3[1 PRs](https://github.com/lukevmk/magento2-rest-client/pulls)MITPHPPHP ^7.2|^8

Since Jul 6Pushed 2y ago3 watchersCompare

[ Source](https://github.com/lukevmk/magento2-rest-client)[ Packagist](https://packagist.org/packages/ptchr/magento2-rest-client)[ Docs](https://github.com/cmesptchr/magento2-rest-client)[ RSS](/packages/ptchr-magento2-rest-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (44)Used By (0)

Magento 2 rest api client
=========================

[](#magento-2-rest-api-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b34ef81927da8a787e27bafab301df12116100ca88d88df02c7030ff58f35baf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70746368722f6d6167656e746f322d726573742d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ptchr/magento2-rest-client)[![Tests](https://github.com/cmesptchr/magento2-rest-client/workflows/Tests/badge.svg)](https://github.com/cmesptchr/magento2-rest-client/workflows/Tests/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/0f1dbc7ee42fa7748c9f872a91ca9ef98e3c5e58a055e8f9b9c3c629ee277023/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70746368722f6d6167656e746f322d726573742d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cmesptchr/magento2-rest-client)

Installation
------------

[](#installation)

##### Streamlines API calls through the Magento 2 REST API

[](#streamlines-api-calls-through-the-magento-2-rest-api)

You can install the package via composer:

```
composer require ptchr/magento2-rest-client
```

Usage
-----

[](#usage)

Intitialize client
------------------

[](#intitialize-client)

```
$client = new Ptchr\Magento2RestClient\Client('BASE_URL', 'ADMIN_USERNAME', 'ADMIN_PASSWORD');
```

Search customer by email
------------------------

[](#search-customer-by-email)

```
$customer = $client->searchCustomerByEmail('john@example.com');
```

Search orders
-------------

[](#search-orders)

Magento docs:

```
$orders = $this->client->getOrders($currentPage, $resultsPerPage, $filters, $sort);
```

Create cart instance
--------------------

[](#create-cart-instance)

```
$quoteId = $client->createCart($customer['id']);
```

Add product to cart
-------------------

[](#add-product-to-cart)

```
$cart = $client->addProductToCart($quoteId, 'SKU', 3);
```

Estimate available shipping methods for cart
--------------------------------------------

[](#estimate-available-shipping-methods-for-cart)

```
$shippingMethods = $client->estimateAvailableShippingMethodsForCart($customer, $quoteId);
```

Add shipping information to cart
--------------------------------

[](#add-shipping-information-to-cart)

```
$shippingInfo = $client->addShippingInformationToCart($customer, $quoteId);
```

Add shipping information with selected shipping method
------------------------------------------------------

[](#add-shipping-information-with-selected-shipping-method)

```
$shippingMethods = $client->estimateAvailableShippingMethodsForCart($customer, $quoteId);
$shippingMethod = $shippingMethods[0];
$shippingInfo = $client->addShippingInformationToCart($customer, $quoteId, $shippingMethod['method_code'], $shippingMethod['carrier_code']);
```

Get available payment methods for cart
--------------------------------------

[](#get-available-payment-methods-for-cart)

```
$paymentMethods = $this->client->getAvailablePaymentMethodsForCart($quoteId);
```

Set payment information
-----------------------

[](#set-payment-information)

```
$this->client->setPaymentInformation($quoteId, $paymentMethod);
```

Set payment information with purchase order number
--------------------------------------------------

[](#set-payment-information-with-purchase-order-number)

```
$this->client->setPaymentInformation($quoteId, $paymentMethod, 'purchase_order_number');
```

Create order
------------

[](#create-order)

```
$orderId = $client->createOrder($quoteId, $paymentMethod);
```

With purchase order number
--------------------------

[](#with-purchase-order-number)

```
$orderId = $client->createOrder($quoteId, $paymentMethod, '123');
```

Create full invoice for order
-----------------------------

[](#create-full-invoice-for-order)

```
Paid:
$client->fullInvoiceOrder($orderId, true);

Not paid:
$client->fullInvoiceOrder($orderId, false);
```

Ship order
----------

[](#ship-order)

```
$orderId = $client->shipOrder($orderId);
```

Cancel order
------------

[](#cancel-order)

```
$client->cancelOrder($orderId);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Christiaan Mes](https://github.com/cmesptchr)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 80.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Recently: every ~173 days

Total

42

Last Release

1096d ago

Major Versions

0.9 → 1.02020-07-06

1.7 → 2.02020-07-22

PHP version history (3 changes)0.1PHP ^7.4

2.5.1PHP ^7.2

2.8PHP ^7.2|^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/3587ab212dfea1d7e3ecd95e45997238d834180c548d8a22f01281aa38cbe159?d=identicon)[cmesptchr](/maintainers/cmesptchr)

---

Top Contributors

[![cmesptchr](https://avatars.githubusercontent.com/u/61871906?v=4)](https://github.com/cmesptchr "cmesptchr (61 commits)")[![lukevmk](https://avatars.githubusercontent.com/u/27729273?v=4)](https://github.com/lukevmk "lukevmk (6 commits)")[![Ken-vdE](https://avatars.githubusercontent.com/u/15888558?v=4)](https://github.com/Ken-vdE "Ken-vdE (5 commits)")[![lukeptchr](https://avatars.githubusercontent.com/u/93133367?v=4)](https://github.com/lukeptchr "lukeptchr (4 commits)")

---

Tags

phpapirestmagento2

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ptchr-magento2-rest-client/health.svg)

```
[![Health](https://phpackages.com/badges/ptchr-magento2-rest-client/health.svg)](https://phpackages.com/packages/ptchr-magento2-rest-client)
```

###  Alternatives

[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.3M14](/packages/xeroapi-xero-php-oauth2)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[zenditplatform/zendit-php-sdk

PHP client for Zendit API

1204.3k](/packages/zenditplatform-zendit-php-sdk)[huaweicloud/huaweicloud-sdk-php

Huawei Cloud SDK for PHP

1829.2k2](/packages/huaweicloud-huaweicloud-sdk-php)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
