{"id":13609274,"url":"https://github.com/woocommerce/wc-api-php","last_synced_at":"2025-10-13T18:48:06.079Z","repository":{"id":26823739,"uuid":"30282509","full_name":"woocommerce/wc-api-php","owner":"woocommerce","description":"WooCommerce REST API PHP Library","archived":false,"fork":false,"pushed_at":"2025-09-08T17:11:51.000Z","size":172,"stargazers_count":539,"open_issues_count":45,"forks_count":165,"subscribers_count":156,"default_branch":"trunk","last_synced_at":"2025-09-08T19:07:51.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/automattic/woocommerce","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/woocommerce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-02-04T05:08:32.000Z","updated_at":"2025-09-08T15:19:21.000Z","dependencies_parsed_at":"2024-06-18T10:59:30.254Z","dependency_job_id":"9cc1c187-fcce-402f-a18d-38cef285831e","html_url":"https://github.com/woocommerce/wc-api-php","commit_stats":{"total_commits":172,"total_committers":17,"mean_commits":"10.117647058823529","dds":0.5523255813953488,"last_synced_commit":"d3b292f04c0b3b21dced691ebad8be073a83b4ad"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/woocommerce/wc-api-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woocommerce%2Fwc-api-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woocommerce%2Fwc-api-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woocommerce%2Fwc-api-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woocommerce%2Fwc-api-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/woocommerce","download_url":"https://codeload.github.com/woocommerce/wc-api-php/tar.gz/refs/heads/trunk","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woocommerce%2Fwc-api-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016620,"owners_count":26085853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T19:01:33.762Z","updated_at":"2025-10-13T18:48:06.072Z","avatar_url":"https://github.com/woocommerce.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# WooCommerce API - PHP Client\n\nA PHP wrapper for the WooCommerce REST API. Easily interact with the WooCommerce REST API securely using this library. If using a HTTPS connection this library uses BasicAuth, else it uses Oauth to provide a secure connection to WooCommerce.\n\n[![CI status](https://github.com/woocommerce/wc-api-php/actions/workflows/ci.yml/badge.svg?branch=trunk)](https://github.com/woocommerce/wc-api-php/actions/workflows/ci.yml)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/woocommerce/wc-api-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/woocommerce/wc-api-php/?branch=master)\n[![PHP version](https://badge.fury.io/ph/automattic%2Fwoocommerce.svg)](https://packagist.org/packages/automattic/woocommerce)\n\n## Installation\n\n```\ncomposer require automattic/woocommerce\n```\n\n## Getting started\n\nGenerate API credentials (Consumer Key \u0026 Consumer Secret) following this instructions \u003chttp://docs.woocommerce.com/document/woocommerce-rest-api/\u003e\n.\n\nCheck out the WooCommerce API endpoints and data that can be manipulated in \u003chttps://woocommerce.github.io/woocommerce-rest-api-docs/\u003e.\n\n## Setup\n\nSetup for the new WP REST API integration (WooCommerce 2.6 or later):\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Automattic\\WooCommerce\\Client;\n\n$woocommerce = new Client(\n  'http://example.com',\n  'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',\n  'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',\n  [\n    'version' =\u003e 'wc/v3',\n  ]\n);\n```\n\n## Client class\n\n```php\n$woocommerce = new Client($url, $consumer_key, $consumer_secret, $options);\n```\n\n### Options\n\n| Option            | Type     | Required | Description                                |\n| ----------------- | -------- | -------- | ------------------------------------------ |\n| `url`             | `string` | yes      | Your Store URL, example: http://woo.dev/   |\n| `consumer_key`    | `string` | yes      | Your API consumer key                      |\n| `consumer_secret` | `string` | yes      | Your API consumer secret                   |\n| `options`         | `array`  | no       | Extra arguments (see client options table) |\n\n#### Client options\n\n| Option                   | Type     | Required | Description                                                                                                                                            |\n| ------------------------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `version`                | `string` | no       | API version, default is `wc/v3`                                                                                                                        |\n| `timeout`                | `int`    | no       | Request timeout, default is `15`                                                                                                                       |\n| `verify_ssl`             | `bool`   | no       | Verify SSL when connect, use this option as `false` when need to test with self-signed certificates, default is `true`                                 |\n| `follow_redirects`       | `bool`   | no       | Allow the API call to follow redirects                                                                                                                 |\n| `query_string_auth`      | `bool`   | no       | Force Basic Authentication as query string when `true` and using under HTTPS, default is `false`                                                       |\n| `oauth_timestamp`        | `string` | no       | Custom oAuth timestamp, default is `time()`                                                                                                            |\n| `oauth_only`             | `bool`   | no       | Only use oauth for requests, it will disable Basic Auth, default is `false`                                                                            |\n| `user_agent`             | `string` | no       | Custom user-agent, default is `WooCommerce API Client-PHP`                                                                                             |\n| `wp_api_prefix`          | `string` | no       | Custom WP REST API URL prefix, used to support custom prefixes created with the `rest_url_prefix` filter                                               |\n| `wp_api`                 | `bool`   | no       | Set to `false` in order to use the legacy WooCommerce REST API (deprecated and not recommended)                                                        |\n| `method_override_query`  | `bool`   | no       | If true will mask all non-GET/POST methods by using POST method with added query parameter `?_method=METHOD` into URL                                  |\n| `method_override_header` | `bool`   | no       | If true will mask all non-GET/POST methods (PUT/DELETE/etc.) by using POST method with added `X-HTTP-Method-Override: METHOD` HTTP header into request |\n\n## Client methods\n\n### GET\n\n```php\n$woocommerce-\u003eget($endpoint, $parameters = []);\n```\n\n### POST\n\n```php\n$woocommerce-\u003epost($endpoint, $data);\n```\n\n### PUT\n\n```php\n$woocommerce-\u003eput($endpoint, $data);\n```\n\n### DELETE\n\n```php\n$woocommerce-\u003edelete($endpoint, $parameters = []);\n```\n\n### OPTIONS\n\n```php\n$woocommerce-\u003eoptions($endpoint);\n```\n\n#### Arguments\n\n| Params       | Type     | Description                                                  |\n| ------------ | -------- | ------------------------------------------------------------ |\n| `endpoint`   | `string` | WooCommerce API endpoint, example: `customers` or `orders/12` |\n| `data`       | `array`  | Only for POST and PUT, data that will be converted to JSON   |\n| `parameters` | `array`  | Only for GET and DELETE, request query string                |\n\n#### Response\n\nAll methods will return arrays on success or throwing `HttpClientException` errors on failure.\n\n```php\nuse Automattic\\WooCommerce\\HttpClient\\HttpClientException;\n\ntry {\n  // Array of response results.\n  $results = $woocommerce-\u003eget('customers');\n  // Example: ['customers' =\u003e [[ 'id' =\u003e 8, 'created_at' =\u003e '2015-05-06T17:43:51Z', 'email' =\u003e ...\n  echo '\u003cpre\u003e\u003ccode\u003e' . print_r($results, true) . '\u003c/code\u003e\u003cpre\u003e'; // JSON output.\n\n  // Last request data.\n  $lastRequest = $woocommerce-\u003ehttp-\u003egetRequest();\n  echo '\u003cpre\u003e\u003ccode\u003e' . print_r($lastRequest-\u003egetUrl(), true) . '\u003c/code\u003e\u003cpre\u003e'; // Requested URL (string).\n  echo '\u003cpre\u003e\u003ccode\u003e' .\n    print_r($lastRequest-\u003egetMethod(), true) .\n    '\u003c/code\u003e\u003cpre\u003e'; // Request method (string).\n  echo '\u003cpre\u003e\u003ccode\u003e' .\n    print_r($lastRequest-\u003egetParameters(), true) .\n    '\u003c/code\u003e\u003cpre\u003e'; // Request parameters (array).\n  echo '\u003cpre\u003e\u003ccode\u003e' .\n    print_r($lastRequest-\u003egetHeaders(), true) .\n    '\u003c/code\u003e\u003cpre\u003e'; // Request headers (array).\n  echo '\u003cpre\u003e\u003ccode\u003e' . print_r($lastRequest-\u003egetBody(), true) . '\u003c/code\u003e\u003cpre\u003e'; // Request body (JSON).\n\n  // Last response data.\n  $lastResponse = $woocommerce-\u003ehttp-\u003egetResponse();\n  echo '\u003cpre\u003e\u003ccode\u003e' . print_r($lastResponse-\u003egetCode(), true) . '\u003c/code\u003e\u003cpre\u003e'; // Response code (int).\n  echo '\u003cpre\u003e\u003ccode\u003e' .\n    print_r($lastResponse-\u003egetHeaders(), true) .\n    '\u003c/code\u003e\u003cpre\u003e'; // Response headers (array).\n  echo '\u003cpre\u003e\u003ccode\u003e' . print_r($lastResponse-\u003egetBody(), true) . '\u003c/code\u003e\u003cpre\u003e'; // Response body (JSON).\n} catch (HttpClientException $e) {\n  echo '\u003cpre\u003e\u003ccode\u003e' . print_r($e-\u003egetMessage(), true) . '\u003c/code\u003e\u003cpre\u003e'; // Error message.\n  echo '\u003cpre\u003e\u003ccode\u003e' . print_r($e-\u003egetRequest(), true) . '\u003c/code\u003e\u003cpre\u003e'; // Last request data.\n  echo '\u003cpre\u003e\u003ccode\u003e' . print_r($e-\u003egetResponse(), true) . '\u003c/code\u003e\u003cpre\u003e'; // Last response data.\n}\n```\n\n## Release History\n\n- 2022-03-18 - 3.1.0 - Added new options to support `_method` and `X-HTTP-Method-Override` from WP, supports 7+, dropped support to PHP 5.\n- 2019-01-16 - 3.0.0 - Legacy API turned off by default, and improved JSON error handler.\n- 2018-03-29 - 2.0.1 - Fixed fatal errors on `lookForErrors`.\n- 2018-01-12 - 2.0.0 - Responses changes from arrays to `stdClass` objects. Added `follow_redirects` option.\n- 2017-06-06 - 1.3.0 - Remove BOM before decoding and added support for multi-dimensional arrays for oAuth1.0a.\n- 2017-03-15 - 1.2.0 - Added `user_agent` option.\n- 2016-12-14 - 1.1.4 - Fixed WordPress 4.7 compatibility.\n- 2016-10-26 - 1.1.3 - Allow set `oauth_timestamp` and improved how is handled the response headers.\n- 2016-09-30 - 1.1.2 - Added `wp_api_prefix` option to allow custom WP REST API URL prefix.\n- 2016-05-10 - 1.1.1 - Fixed oAuth and error handler for WP REST API.\n- 2016-05-09 - 1.1.0 - Added support for WP REST API, added method `Automattic\\WooCommerce\\Client::options` and fixed multiple headers responses.\n- 2016-01-25 - 1.0.2 - Fixed an error when getting data containing non-latin characters.\n- 2016-01-21 - 1.0.1 - Sort all oAuth parameters before build request URLs.\n- 2016-01-11 - 1.0.0 - Stable release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoocommerce%2Fwc-api-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwoocommerce%2Fwc-api-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoocommerce%2Fwc-api-php/lists"}