Download the PHP package metaline/wp-api-client without Composer

On this page you can find all versions of the php package metaline/wp-api-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-api-client

WP API Client

Test library

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

Installation

The recommended way to install this library is through Composer.

Documentation

Create the client

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

The factory accepts an optional array of options, to customize the timeouts of the requests:

Option Default Description
timeout 120 Maximum number of seconds to wait for the whole request.
connect_timeout 10 Maximum number of seconds to wait while trying to connect.

Both options are passed to Guzzle, so you can refer to the Guzzle documentation for more details.

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

Fetch data from REST API

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

Please, refer to the WordPress and WooCommerce REST API documentation, for all available methods.

Helper methods

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

HTTP verb Helper method
GET $client->get($uri, $query)
POST $client->post($uri, $params)
PUT $client->put($uri, $params)
PATCH $client->patch($uri, $params)
DELETE $client->delete($uri, $query)

Upload files

A special case is the media endpoints, which allow us to upload a file:

Retries

A request is sent again, up to 5 times in total, when it fails at the transport level — the host cannot be resolved, the connection is refused or the server times out — and when the server answers with 500, 502, 503 or 504. The other server errors, such as 501 and 505, describe a server that will keep answering the same way, so they are not retried.

Only the methods that are idempotent by definition are retried: GET, HEAD, OPTIONS, TRACE, PUT and DELETE. A POST or a PATCH is sent once and never repeated, because neither a transport error nor a 500 tells us whether the server has already processed the request: a timeout on POST wc/v3/orders, or a fatal error raised by a hook after the order has been saved, may well leave an order behind, and retrying would create a second one.

Retries are sent one after the other, with no delay in between.

License

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


All versions of wp-api-client with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
ext-json Version *
guzzlehttp/guzzle Version ^7.4
psr/log Version ^1.0 || ^2.0 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package metaline/wp-api-client contains the following files

Loading the files please wait ...