PHPackages                             metaline/wp-api-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. [API Development](/categories/api)
4. /
5. metaline/wp-api-client

ActiveLibrary[API Development](/categories/api)

metaline/wp-api-client
======================

A PHP client for the WordPress REST API, based on Guzzle.

026PHP

Since Mar 28Pushed 1y ago2 watchersCompare

[ Source](https://github.com/metaline/wp-api-client)[ Packagist](https://packagist.org/packages/metaline/wp-api-client)[ RSS](/packages/metaline-wp-api-client/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

WP API Client
=============

[](#wp-api-client)

[![Test library](https://github.com/metaline/wp-api-client/actions/workflows/test-library.yml/badge.svg)](https://github.com/metaline/wp-api-client/actions/workflows/test-library.yml/badge.svg)

A PHP client for the WordPress REST API, based on [Guzzle](https://guzzlephp.org/).

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

[](#installation)

The recommended way to install this library is through [Composer](https://getcomposer.org/).

```
composer require metaline/wp-api-client

```

Documentation
-------------

[](#documentation)

### Create the client

[](#create-the-client)

You can create the client instance through the `ClientFactory`. At the moment, only WooCommerce credentials are supported:

```
use MetaLine\WordPressAPIClient\ClientFactory;

$factory = new ClientFactory();
$client = $factory->createFromWooCommerceCredentials(
    $customerKey,
    $customerSecret,
    $apiUrl
);
```

If you need to access to the WordPress REST API through the WooCommerce API credentials, you need this hook in YOUR installation of WordPress:

```
add_filter('woocommerce_rest_is_request_to_rest_api', function ($enabled) {
	if (!$enabled) {
        $rest_prefix = trailingslashit(rest_get_url_prefix());
        $request_uri = esc_url_raw(wp_unslash($_SERVER['REQUEST_URI']));
        $enabled = false !== strpos($request_uri, $rest_prefix . 'wp/');
    }

    return $enabled;
});
```

### Fetch data from REST API

[](#fetch-data-from-rest-api)

Through the client instance you can fetch data from the WordPress REST API. For example:

```
$customers = $client->request('GET', 'wc/v3/customers');
```

Please, refer to the [WordPress](https://developer.wordpress.org/rest-api/reference/) and [WooCommerce](https://woocommerce.github.io/woocommerce-rest-api-docs/) REST API documentation, for all available methods.

### Helper methods

[](#helper-methods)

The client has five helper methods, one for each REST verb: `get()`, `post()`, `put()`, `patch()` and `delete()`.

HTTP verbHelper methodGET`$client->get($uri, $query)`POST`$client->post($uri, $params)`PUT`$client->put($uri, $params)`PATCH`$client->patch($uri, $params)`DELETE`$client->delete($uri, $query)`- `$uri` is the endpoint of the call;
- `$query` is an array of variables to put in query string;
- `$params` is an array of data to put in the body request;

### Upload files

[](#upload-files)

A special case is the [media](https://developer.wordpress.org/rest-api/reference/media/) endpoints, which allow us to upload a file:

```
$data = [
	'file' => new SplFileObject('/path/to/file.zip'),
];

$client->post('wp/v2/media', $data);
```

License
-------

[](#license)

This project is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e4eea69ef91ca47852c5e64286d2e60c684cad223fde908d19fc987ab7f40e8c?d=identicon)[metaline](/maintainers/metaline)

---

Top Contributors

[![pongho](https://avatars.githubusercontent.com/u/1329964?v=4)](https://github.com/pongho "pongho (9 commits)")[![omoikane](https://avatars.githubusercontent.com/u/145311?v=4)](https://github.com/omoikane "omoikane (1 commits)")

---

Tags

apiapi-clientphprestrest-apiwoocommercewordpress

### Embed Badge

![Health badge](/badges/metaline-wp-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/metaline-wp-api-client/health.svg)](https://phpackages.com/packages/metaline-wp-api-client)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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