{"id":25817552,"url":"https://github.com/metaline/wp-api-client","last_synced_at":"2026-04-16T17:02:36.319Z","repository":{"id":62527394,"uuid":"449774993","full_name":"metaline/wp-api-client","owner":"metaline","description":"A PHP client for the WordPress REST API.","archived":false,"fork":false,"pushed_at":"2024-07-25T07:51:37.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T12:46:39.399Z","etag":null,"topics":["api","api-client","php","rest","rest-api","woocommerce","wordpress"],"latest_commit_sha":null,"homepage":"","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/metaline.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2022-01-19T16:44:06.000Z","updated_at":"2024-07-25T07:51:40.000Z","dependencies_parsed_at":"2025-02-28T06:59:43.719Z","dependency_job_id":"a842027f-9a5a-4a97-8fab-e0cec34de8c2","html_url":"https://github.com/metaline/wp-api-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/metaline/wp-api-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metaline%2Fwp-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metaline%2Fwp-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metaline%2Fwp-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metaline%2Fwp-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metaline","download_url":"https://codeload.github.com/metaline/wp-api-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metaline%2Fwp-api-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31895650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T11:36:10.202Z","status":"ssl_error","status_checked_at":"2026-04-16T11:36:09.652Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","api-client","php","rest","rest-api","woocommerce","wordpress"],"created_at":"2025-02-28T06:54:32.664Z","updated_at":"2026-04-16T17:02:36.274Z","avatar_url":"https://github.com/metaline.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP API Client\n\n![Test library](https://github.com/metaline/wp-api-client/actions/workflows/test-library.yml/badge.svg)\n\nA PHP client for the WordPress REST API, based on [Guzzle](https://guzzlephp.org/).\n\n## Installation\n\nThe recommended way to install this library is through [Composer](https://getcomposer.org/).\n\n```\ncomposer require metaline/wp-api-client\n```\n\n## Documentation\n\n### Create the client\n\nYou can create the client instance through the `ClientFactory`. At the moment, only WooCommerce credentials are supported:\n\n```php\nuse MetaLine\\WordPressAPIClient\\ClientFactory;\n\n$factory = new ClientFactory();\n$client = $factory-\u003ecreateFromWooCommerceCredentials(\n    $customerKey,\n    $customerSecret,\n    $apiUrl\n);\n```\n\nIf you need to access to the WordPress REST API through the WooCommerce API credentials, you need this hook in YOUR installation of WordPress:\n\n```php\nadd_filter('woocommerce_rest_is_request_to_rest_api', function ($enabled) {\n\tif (!$enabled) {\n        $rest_prefix = trailingslashit(rest_get_url_prefix());\n        $request_uri = esc_url_raw(wp_unslash($_SERVER['REQUEST_URI']));\n        $enabled = false !== strpos($request_uri, $rest_prefix . 'wp/');\n    }\n\n    return $enabled;\n});\n```\n\n### Fetch data from REST API\n\nThrough the client instance you can fetch data from the WordPress REST API. For example:\n\n```php\n$customers = $client-\u003erequest('GET', 'wc/v3/customers');\n```\n\nPlease, 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.\n\n### Helper methods\n\nThe client has five helper methods, one for each REST verb: `get()`, `post()`, `put()`, `patch()` and `delete()`.\n\n| HTTP verb | Helper method                   |\n|-----------|---------------------------------|\n| GET       | `$client-\u003eget($uri, $query)`    |\n| POST      | `$client-\u003epost($uri, $params)`  |\n| PUT       | `$client-\u003eput($uri, $params)`   |\n| PATCH     | `$client-\u003epatch($uri, $params)` |\n| DELETE    | `$client-\u003edelete($uri, $query)` |\n\n- `$uri` is the endpoint of the call;\n- `$query` is an array of variables to put in query string;\n- `$params` is an array of data to put in the body request;\n\n### Upload files\n\nA special case is the [media](https://developer.wordpress.org/rest-api/reference/media/) endpoints, which allow us to upload a file:\n\n```php\n$data = [\n\t'file' =\u003e new SplFileObject('/path/to/file.zip'),\n];\n\n$client-\u003epost('wp/v2/media', $data);\n```\n\n## License\n\nThis project is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetaline%2Fwp-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetaline%2Fwp-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetaline%2Fwp-api-client/lists"}