{"id":37265777,"url":"https://github.com/rickwest/laravel-wordpress-api","last_synced_at":"2026-01-16T00:14:13.483Z","repository":{"id":45793419,"uuid":"509857175","full_name":"rickwest/laravel-wordpress-api","owner":"rickwest","description":"A Laravel read-only client for the WordPress REST API (v2)","archived":false,"fork":false,"pushed_at":"2026-01-12T03:37:59.000Z","size":225,"stargazers_count":37,"open_issues_count":5,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-14T15:49:00.619Z","etag":null,"topics":["api-client","laravel","php","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/rickwest.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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-07-02T20:39:20.000Z","updated_at":"2026-01-12T03:37:57.000Z","dependencies_parsed_at":"2024-06-09T01:25:42.088Z","dependency_job_id":"205bc940-c97f-4342-86d1-195f7243a228","html_url":"https://github.com/rickwest/laravel-wordpress-api","commit_stats":{"total_commits":27,"total_committers":4,"mean_commits":6.75,"dds":0.2592592592592593,"last_synced_commit":"5456eae21df1ae37a09af3dee38c00ad73851604"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/rickwest/laravel-wordpress-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickwest%2Flaravel-wordpress-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickwest%2Flaravel-wordpress-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickwest%2Flaravel-wordpress-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickwest%2Flaravel-wordpress-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rickwest","download_url":"https://codeload.github.com/rickwest/laravel-wordpress-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickwest%2Flaravel-wordpress-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28474474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T00:03:33.697Z","status":"ssl_error","status_checked_at":"2026-01-15T23:58:36.859Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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-client","laravel","php","wordpress"],"created_at":"2026-01-16T00:14:12.708Z","updated_at":"2026-01-16T00:14:13.473Z","avatar_url":"https://github.com/rickwest.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cimg src=\"./art/social-image.png\"  alt=\"\"/\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/rickwest/laravel-wordpress-api.svg?style=flat-square)](https://packagist.org/packages/rickwest/laravel-wordpress-api)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/rickwest/laravel-wordpress-api/run-tests.yml?branch=main\u0026label=tests)](https://github.com/rickwest/laravel-wordpress-api/actions/workflows/run-tests.yml)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/rickwest/laravel-wordpress-api/php-cs-fixer.yml?branch=main\u0026label=code%20style)](https://github.com/rickwest/laravel-wordpress-api/actions/workflows/php-cs-fixer.yml)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/rickwest/laravel-wordpress-api/phpstan.yml?branch=main\u0026label=static%20analysis)](https://github.com/rickwest/laravel-wordpress-api/actions/workflows/php-cs-fixer.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/rickwest/laravel-wordpress-api.svg?style=flat-square)](https://packagist.org/packages/rickwest/laravel-wordpress-api)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n\nAn unambitious read-only client for the WordPress REST API (v2). This package is the by-product of a side project, having found that I wanted a more expressive, fluent, Laravel-esque way of querying the WordPress API.\n\n```php\n// Without the package 👎\nHttp::get('https://example.com/wp-json/wp/v2/posts', [\n    'search' =\u003e 'potatoes',\n    '_embed' =\u003e 1,\n    'orderby' =\u003e 'date',\n    'order' =\u003e 'desc'\n    '_fields' =\u003e 'title',\n]);\n\n\n// Using the package 👌\nWordPress::posts()\n    -\u003esearch('potatoes')\n    -\u003eembed()\n    -\u003elatest()\n    -\u003eget('title');\n```\n\nAs well as the fluent query builder, you also benefit from a nicely formatted response, including pagination information.\n\n```php\n// Without the package 👎\n$response = Http::get('https://example.com/wp-json/wp/v2/posts');\n$data = $response-\u003ejson();\n$pages = $response-\u003eheader('X-WP-TotalPages');\n$total = $response-\u003eheader('X-WP-Total');\n\n\n// Using the package 👌\n$posts = WordPress::posts()-\u003eget();\n\n// $posts\n[\n    'data' =\u003e [...],\n    'meta' =\u003e [\n        'pages' =\u003e 1,\n        'total' =\u003e 10,\n    ],\n],\n\n```\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require rickwest/laravel-wordpress-api\n```\n\nThen you need to add your WordPress url to your `.env` file:\n\n```dotenv\nWORDPRESS_URL=https://example.com\n```\n\n## Usage\n\nThis package binds a singleton to the Laravel service container, so you can easily resolve the WordPress client directly from the container, or via dependency injection. \nAlternatively, the package also exposes both a Facade and a helper function should you prefer a shorter more expressive option.\n\nCurrently, the package has support for the following WordPress resources: *categories, comments, media, pages, posts, users*. \nAdding support for further resources is really easy, but these are the only ones that I need for now! For a list of all available resources please see https://developer.wordpress.org/rest-api/reference. I'm happy to accept PR's for any additions.\n\n```php\n// Resolve service directly from container and access the Posts API\napp(WordPress::class)-\u003eposts();\n\n// Resolve via Facade and access the Posts API\nWordPress::posts(); \n\n// Resolve service via helper and access the Posts API\nwordpress()-\u003eposts();\n\n// Supported resources\nWordPress::categories(); // Access the Categories API\nWordPress::comments(); // Access the Comments API\nWordPress::media(); // Access the Media API\nWordPress::pages(); // Access the Pages API\nWordPress::posts(); // Access the Posts API\nWordPress::users(); // Access the Users API\nWordpress::tags(); // Access the Tags API\nWordpress::plugins(); // Access the Plugins API\n\n// You can also access resources as properties\nwordpress()-\u003eposts\n```\n\n ### Retrieve a single resource\n\nCall the `find` method on a resource class in order to get a single resource by ID:\n\n```php\nWordPress::posts()-\u003efind(1);\n\n// All WordPress resources share a handful of global parameters. https://developer.wordpress.org/rest-api/using-the-rest-api/global-parameters/ \n// You can use the relevant fluent builder methods to add these to your query\nWordPress::posts()-\u003eembed()-\u003efields('title')-\u003efind(1);\n\n// Some resources also accept a limited number of resource specific parameters. These can be passed as a second argument to the find method\nWordPress::posts()-\u003efind(1, ['password' =\u003e 'pa55w0rd']);\n```\n\n### Retrieve a collection of resources\n\nCall the `get` method on a resource to retrieve a collection of resources. The response you receive can be controlled and filtered using various parameters, https://developer.wordpress.org/rest-api/reference/.\nThis package provides some fluent builder methods in order to easily and expressively build your desired query. Collection responses are then nicely formatted and include useful pagination information. \n\n```php\nWordPress::posts()-\u003eget();\n\n// All WordPress resources share a handful of global parameters, https://developer.wordpress.org/rest-api/using-the-rest-api/global-parameters/,\n// along with a number of filtering, ordering and pagination options. You can use the relevant fluent builder methods to build your query.\nWordPress::posts()\n    -\u003eembed(array|string $relations) // Embed linked resources into response. Reduces need for extra HTTP requests for related resources\n    -\u003efields(array|string $fields) // Specify a subset fields to return in a response\n    -\u003ewith(array|string $fields) // Alias for fields method above\n    -\u003epage(int $page) // Current page of the collection\n    -\u003eperPage(int $perPage) // Maximum number of items to be returned in result set\n    -\u003esearch(string $term) // Limit results to those matching a string\n    -\u003eoffset(int $offset) // Offset the result set by a specific number of items\n    -\u003eexlclude(int|array $ids) // Ensure result set excludes specific IDs\n    -\u003einlude(int|array $ids) // Limit result set to specific IDs\n    -\u003eorderBy(string $field, string $direction) // Sort collection by object attribute, either ascending or descending\n    \n    // Resources with authors  \n    -\u003eauthor() // Limit result set to resources assigned to specific authors\n    -\u003eauthorExclude() // Ensure result set excludes resources assigned to specific authors\n    \n    // Resources with dates\n    -\u003eafter(Carbon $after) // Limit response to resources published after a given ISO8601 compliant date\n    -\u003ebefore(Carbon $before) // Limit response to resources published before a given ISO8601 compliant date\n    -\u003elatest() // Order by date, descending\n    -\u003eoldest() // Order by date, ascending\n    \n    // Resources with slugs\n    -\u003eslug(string $slug)\n    \n    // When a utility doesn't exist for the parameter\n    -\u003eparameter(string $key, mixed $value) // Add a custom parameter to the query\n    \n    // Send it!        \n    -\u003eget();\n\n// Conditionally adding parameters\nWordPress::posts()\n    -\u003ewhen($onlyIncludeTitle, function($query) {\n        $query-\u003efields('title');\n    })\n    -\u003eget();\n```\n\n### Creating, updating and deleting resources\n\nWhilst this package is primarily intended for reading data from the WordPress API, it is possible to perform write operations using the `send` method on a resource class.\n\n```php\nWordPress::posts()-\u003esend(string $method, int $id, array $options);\n\n// For example, updating a post might look like...\nWordPress::posts()-\u003esend('POST', 1, [\n    'json' =\u003e ['title' =\u003e 'My New Title'],\n]);\n\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Rick West](https://github.com/rickwest)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickwest%2Flaravel-wordpress-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickwest%2Flaravel-wordpress-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickwest%2Flaravel-wordpress-api/lists"}