{"id":18459380,"url":"https://github.com/joeybeninghove/json-api-wp-client","last_synced_at":"2026-05-12T07:39:03.889Z","repository":{"id":57000815,"uuid":"81159078","full_name":"joeybeninghove/json-api-wp-client","owner":"joeybeninghove","description":"WordPress client library for consuming APIs adhering to the JSON API 1.0 spec","archived":false,"fork":false,"pushed_at":"2017-02-07T22:10:52.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-25T06:13:24.565Z","etag":null,"topics":["json","json-api","jsonapi","wordpress","wordpress-php-library"],"latest_commit_sha":null,"homepage":null,"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/joeybeninghove.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}},"created_at":"2017-02-07T02:53:21.000Z","updated_at":"2024-06-07T08:44:07.000Z","dependencies_parsed_at":"2022-08-21T14:10:26.779Z","dependency_job_id":null,"html_url":"https://github.com/joeybeninghove/json-api-wp-client","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeybeninghove%2Fjson-api-wp-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeybeninghove%2Fjson-api-wp-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeybeninghove%2Fjson-api-wp-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeybeninghove%2Fjson-api-wp-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeybeninghove","download_url":"https://codeload.github.com/joeybeninghove/json-api-wp-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239149223,"owners_count":19589943,"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","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":["json","json-api","jsonapi","wordpress","wordpress-php-library"],"created_at":"2024-11-06T08:22:56.837Z","updated_at":"2026-05-12T07:39:03.847Z","avatar_url":"https://github.com/joeybeninghove.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON API WordPress Client\n\nThis library is an opinionated, resource-based JSON API client for WordPress that strives to adhere to the offical [JSON API 1.0 spec](http://jsonapi.org).\n\n## Requirements\n\n* WordPress\n\n## Usage\n\n### Define a resource\n* `base_url` is specified as the root URL used when interacting with the API.\n* `type` is the [JSON API type](http://jsonapi.org/format/#document-resource-objects) for the current resource\n\n```php\nclass Invoice extends Json_Api_Wp_Resource\n{\n    public function __construct()\n    {\n        parent::__construct(\n            \"https://api.site.com/v1/\", // base URL\n            \"invoices\" // type\n        )\n    }\n}\n```\n\n### Set up HTTP Authentication\nThe `username` is required, but the `password` is optional and defaults to blank.\n```php\nJson_Api_Wp_Resource::auth( \"jdoe\", \"secret\" );\n```\n\n#### API Key example\nIf you're using a typical API key over HTTP Authentication, here is an example\nof using a base class to abstract that away.\n```php\nclass Base extends Json_Api_Wp_Resource\n{\n    public function __construct( $type )\n    {\n        parent::__construct( \"http://api.site.come/v1/\", $type );\n    }\n\n    public static function set_api_key( $api_key )\n    {\n        parent::auth( $apiKey );\n    }\n}\n\nclass Invoice extends Base\n{\n    public function __construct()\n    {\n        parent::__construct( \"invoices\" );\n    }\n}\n\nBase::set_api_key( \"some secret key\" );\n$invoices = Invoice::get_all();\n```\n\n### Create a resource\n```php\n$invoice = Invoice::create([\n    \"description\" =\u003e \"T-Shirt\",\n    \"total\" =\u003e 10.95\n]);\n```\n\n### Update a resource\nThis library does not yet support updating of resources because of the lack of\n`PATCH` support in the WordPress HTTP library.\n\n### Get a single resource\n```php\n$invoice = Invoice::get_one( \"invoice_123\" );\n```\n\n### Get all resources\n```php\n$invoices = Invoice::get_all();\n```\n\n### Delete a resource\nThis library does not yet support updating of resources because of the lack of\n`DELETE` support in the WordPress HTTP library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeybeninghove%2Fjson-api-wp-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeybeninghove%2Fjson-api-wp-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeybeninghove%2Fjson-api-wp-client/lists"}