{"id":13581201,"url":"https://github.com/johnbillion/wp-json-schemas","last_synced_at":"2025-05-15T22:11:58.746Z","repository":{"id":39742049,"uuid":"266317404","full_name":"johnbillion/wp-json-schemas","owner":"johnbillion","description":"JSON schemas for WordPress PHP objects and REST  API responses","archived":false,"fork":false,"pushed_at":"2025-04-17T09:58:25.000Z","size":759,"stargazers_count":155,"open_issues_count":8,"forks_count":8,"subscribers_count":5,"default_branch":"trunk","last_synced_at":"2025-04-17T23:53:27.356Z","etag":null,"topics":["json-schema","rest-api","typescript","typescript-definitions","wordpress"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/wp-json-schemas","language":"TypeScript","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/johnbillion.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","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},"funding":{"github":"johnbillion"}},"created_at":"2020-05-23T10:55:45.000Z","updated_at":"2025-04-17T09:58:26.000Z","dependencies_parsed_at":"2024-01-16T20:43:33.256Z","dependency_job_id":"3e1f4e4a-7a39-4bdb-b205-e7c9601431d5","html_url":"https://github.com/johnbillion/wp-json-schemas","commit_stats":{"total_commits":594,"total_committers":3,"mean_commits":198.0,"dds":0.01683501683501687,"last_synced_commit":"2f44949544a8d065212c3ad5bcb7525f258db93f"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbillion%2Fwp-json-schemas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbillion%2Fwp-json-schemas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbillion%2Fwp-json-schemas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbillion%2Fwp-json-schemas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnbillion","download_url":"https://codeload.github.com/johnbillion/wp-json-schemas/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254430331,"owners_count":22069909,"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-schema","rest-api","typescript","typescript-definitions","wordpress"],"created_at":"2024-08-01T15:01:59.123Z","updated_at":"2025-05-15T22:11:53.722Z","avatar_url":"https://github.com/johnbillion.png","language":"TypeScript","funding_links":["https://github.com/sponsors/johnbillion"],"categories":["TypeScript"],"sub_categories":[],"readme":"[![](https://img.shields.io/badge/npm-wp--json--schemas-7700ee.svg?style=flat-square)](https://www.npmjs.com/package/wp-json-schemas)\n[![](https://img.shields.io/badge/npm-wp--types-7700ee.svg?style=flat-square)](https://www.npmjs.com/package/wp-types)\n[![](https://img.shields.io/github/actions/workflow/status/johnbillion/wp-json-schemas/test.yml?branch=trunk\u0026style=flat-square)](https://github.com/johnbillion/wp-json-schemas/actions)\n\n# WordPress JSON Schemas\n\nThis package provides well-documented JSON schemas that describe the shape of:\n\n* WordPress core PHP objects such as `WP_Post`, `WP_Term`, and `WP_User`\n* WordPress REST API responses such as those from `/wp/v2/posts`, `/wp/v2/categories`, and `/wp/v2/users`\n* Various property types and values of both\n\nThe schemas in this library are used to generate [the WordPress TypeScript definitions provided by the `wp-types` package](https://www.npmjs.com/package/wp-types).\n\nThe schemas were last updated for WordPress 6.7.\n\n## What's included?\n\n### PHP object schemas\n\n* `WP_Post`\n* `WP_Term`\n* `WP_User`\n* `WP_Comment`\n* `WP_Error`\n* `WP_Query`\n* `WP_Block`\n* `WP_Block_Type`\n* `WP_Block_Template`\n* `WP_Site`\n* `WP_Locale`\n* `WP_Taxonomy`\n* `WP_Post_Type`\n* `WP_Role`\n* `WP_Network`\n* `WP_Screen`\n\n### REST API response schemas\n\nRoute                                                   | Schema\n------------------------------------------------------- | ------\n/wp/v2/block-directory/search                           | `WP_REST_API_Block_Directory_Items`\n/wp/v2/block-patterns/categories                        | `WP_REST_API_Block_Pattern_Categories`\n/wp/v2/block-patterns/patterns                          | `WP_REST_API_Block_Patterns`\n/wp/v2/block-renderer/{name}                            | `WP_REST_API_Rendered_Block`\n/wp/v2/block-types                                      | `WP_REST_API_Block_Types`\n/wp/v2/block-types/{namespace}                          | `WP_REST_API_Block_Type`\n/wp/v2/block-types/{namespace}/{name}                   | `WP_REST_API_Block_Type`\n/wp/v2/blocks                                           | `WP_REST_API_Blocks`\n/wp/v2/blocks/{id}                                      | `WP_REST_API_Block`\n/wp/v2/blocks/{id}/autosaves                            | Todo\n/wp/v2/blocks/{parent}/autosaves/{id}                   | Todo\n/wp/v2/blocks/{parent}/revisions                        | `WP_REST_API_Revisions`\n/wp/v2/blocks/{parent}/revisions/{id}                   | `WP_REST_API_Revision`\n/wp/v2/categories                                       | `WP_REST_API_Categories`\n/wp/v2/categories/{id}                                  | `WP_REST_API_Category`\n/wp/v2/comments                                         | `WP_REST_API_Comments`\n/wp/v2/comments/{id}                                    | `WP_REST_API_Comment`\n/wp/v2/font-collections                                 | `WP_REST_API_Font_Collections`\n/wp/v2/font-collections/{slug}                          | `WP_REST_API_Font_Collection`\n/wp/v2/font-families                                    | `WP_REST_API_Font_Families`\n/wp/v2/font-families/{id}/                              | `WP_REST_API_Font_Family`\n/wp/v2/font-families/{parent}/font-faces                | `WP_REST_API_Font_Faces`\n/wp/v2/font-families/{parent}/font-faces/{id}           | `WP_REST_API_Font_Face`\n/wp/v2/global-styles/{id}                               | `WP_REST_API_Global_Style_Variation`\n/wp/v2/global-styles/{parent}/revisions                 | Todo\n/wp/v2/global-styles/{parent}/revisions/{id}            | Todo\n/wp/v2/global-styles/themes/{stylesheet}                | `WP_REST_API_Global_Style_Config`\n/wp/v2/global-styles/themes/{stylesheet}/variations     | `WP_REST_API_Global_Style_Variations`\n/wp/v2/media                                            | `WP_REST_API_Attachments`\n/wp/v2/media/{id}                                       | `WP_REST_API_Attachment`\n/wp/v2/media/{id}/edit                                  | Todo\n/wp/v2/media/{id}/post-process                          | Todo\n/wp/v2/menu-items                                       | `WP_REST_API_Menu_Items`\n/wp/v2/menu-items/{id}                                  | `WP_REST_API_Menu_Item`\n/wp/v2/menu-items/{id}/autosaves                        | Todo\n/wp/v2/menu-items/{parent}/autosaves/{id}               | Todo\n/wp/v2/menu-locations                                   | `WP_REST_API_Menu_Locations`\n/wp/v2/menu-locations/{location}                        | `WP_REST_API_Menu_Location`\n/wp/v2/menus                                            | `WP_REST_API_Menus`\n/wp/v2/menus/{id}                                       | `WP_REST_API_Menu`\n/wp/v2/navigation                                       | `WP_REST_API_Navigation_Menus`\n/wp/v2/navigation/{id}                                  | `WP_REST_API_Navigation_Menu`\n/wp/v2/navigation/{id}/autosaves                        | Todo\n/wp/v2/navigation/{parent}/autosaves/{id}               | Todo\n/wp/v2/navigation/{parent}/revisions                    | Todo\n/wp/v2/navigation/{parent}/revisions/{id}               | Todo\n/wp/v2/pages                                            | `WP_REST_API_Pages`\n/wp/v2/pages/{id}                                       | `WP_REST_API_Page`\n/wp/v2/pages/{id}/autosaves                             | Todo\n/wp/v2/pages/{parent}/autosaves/{id}                    | Todo\n/wp/v2/pages/{parent}/revisions                         | `WP_REST_API_Revisions`\n/wp/v2/pages/{parent}/revisions/{id}                    | `WP_REST_API_Revision`\n/wp/v2/pattern-directory/patterns                       | `WP_REST_API_Pattern_Directory_Patterns`\n/wp/v2/plugins                                          | `WP_REST_API_Plugins`\n/wp/v2/plugins/{plugin}                                 | `WP_REST_API_Plugin`\n/wp/v2/posts                                            | `WP_REST_API_Posts`\n/wp/v2/posts/{id}                                       | `WP_REST_API_Post`\n/wp/v2/posts/{id}/autosaves                             | Todo\n/wp/v2/posts/{parent}/autosaves/{id}                    | Todo\n/wp/v2/posts/{parent}/revisions                         | `WP_REST_API_Revisions`\n/wp/v2/posts/{parent}/revisions/{id}                    | `WP_REST_API_Revision`\n/wp/v2/search                                           | `WP_REST_API_Search_Results`\n/wp/v2/settings                                         | `WP_REST_API_Settings`\n/wp/v2/sidebars                                         | Todo\n/wp/v2/sidebars/{id}                                    | Todo\n/wp/v2/statuses                                         | `WP_REST_API_Statuses`\n/wp/v2/statuses/{status}                                | `WP_REST_API_Status`\n/wp/v2/tags                                             | `WP_REST_API_Tags`\n/wp/v2/tags/{id}                                        | `WP_REST_API_Tag`\n/wp/v2/taxonomies                                       | `WP_REST_API_Taxonomies`\n/wp/v2/taxonomies/{taxonomy}                            | `WP_REST_API_Taxonomy`\n/wp/v2/template-parts                                   | Todo\n/wp/v2/template-parts/{id}                              | Todo\n/wp/v2/template-parts/{id}/autosaves                    | Todo\n/wp/v2/template-parts/{parent}/autosaves/{id}           | Todo\n/wp/v2/template-parts/{parent}/revisions                | Todo\n/wp/v2/template-parts/{parent}/revisions/{id}           | Todo\n/wp/v2/template-parts/lookup                            | Todo\n/wp/v2/templates                                        | Todo\n/wp/v2/templates/{id}                                   | Todo\n/wp/v2/templates/{id}/autosaves                         | Todo\n/wp/v2/templates/{parent}/autosaves/{id}                | Todo\n/wp/v2/templates/{parent}/revisions                     | Todo\n/wp/v2/templates/{parent}/revisions/{id}                | Todo\n/wp/v2/templates/lookup                                 | Todo\n/wp/v2/themes                                           | Todo\n/wp/v2/themes/{stylesheet}                              | Todo\n/wp/v2/types                                            | `WP_REST_API_Types`\n/wp/v2/types/{type}                                     | `WP_REST_API_Type`\n/wp/v2/users                                            | `WP_REST_API_Users`\n/wp/v2/users/({id}\\|me)                                 | `WP_REST_API_User`\n/wp/v2/users/({id}\\|me)/application-passwords           | `WP_REST_API_Application_Passwords`\n/wp/v2/users/({id}\\|me)/application-passwords/{uuid}    | `WP_REST_API_Application_Password`\n/wp/v2/users/({id}\\|me)/application-passwords/introspect| `WP_REST_API_Application_Password`\n/wp/v2/widget-types                                     | Todo\n/wp/v2/widget-types/{id}                                | Todo\n/wp/v2/widget-types/{id}/encode                         | Todo\n/wp/v2/widget-types/{id}/render                         | Todo\n/wp/v2/widgets                                          | Todo\n/wp/v2/widgets/{id}                                     | Todo\n/wp/v2/wp_pattern_category                              | Todo\n/wp/v2/wp_pattern_category/{id}                         | Todo\nAny REST API error                                      | `WP_REST_API_Error`\n\nThe REST API schemas use JSON Hyper-Schema.\n\n### Property schemas\n\nSchemas are provided for various properties:\n\n* `WP_Error_Data`\n* `WP_Error_Messages`\n* `WP_Post_Type_Caps`\n* `WP_Post_Type_Labels`\n* `WP_Post_Type_Rewrite`\n* `WP_Taxonomy_Caps`\n* `WP_Taxonomy_Labels`\n* `WP_Taxonomy_Rewrite`\n* `WP_User_Cap_Name`\n* `WP_User_Caps`\n* `WP_User_Data`\n\n### Enums\n\nEnums are provided for various values:\n\n* `WP_Comment_Status_Name`\n* `WP_Comment_Type_Name`\n* `WP_HTTP_Status_Code`\n* `WP_Post_Comment_Status_Name`\n* `WP_Post_Format_Name`\n* `WP_Post_Status_Name`\n* `WP_Post_Type_Name`\n* `WP_Taxonomy_Name`\n* `WP_User_Role_Name`\n\n## Installation\n\n```sh\nnpm install wp-json-schemas\n```\n\n### Versioning\n\nThis package is versioned so that you can specify both the schema version and the WordPress branch version in a way that's compatible with semantic versioning. Given version `x.y.z`:\n\n* The major version number (`x`) indicates the schema version number, currently `4`\n* The minor version number (`y`) indicates the WordPress branch version number without its decimal place, eg. `67` for WordPress 6.7\n* The patch version number (`z`) indicates the schema patch version number\n\nExamples:\n\n* `^4.0.0` - Schema version 4 for the latest WordPress version\n* `~4.67.0` - Schema version 4 for WordPress 6.7\n* `~3.57.0` - Schema version 3 for WordPress 5.7\n\n## Breaking changes\n\nIf a breaking change is made to the schema then the major version number of this package will be incremented.\n\n* Version 4 switched to using JSON Schema `draft/2019-09`. Prior to this, `draft-07` was used.\n\n## Usage\n\nUsage depends on what you're doing with the schemas. You could use them for validation or just for understanding the shape of an object.\n\nIf you're using TypeScript, check out [the TypeScript definitions provided by the `wp-types` package](https://www.npmjs.com/package/wp-types).\n\n## Sponsors\n\n\u003cp align=\"center\"\u003eThe time that I spend maintaining this library and others is in part sponsored by:\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://automattic.com\"\u003e\u003cimg src=\"https://cdn.jsdelivr.net/gh/johnbillion/johnbillion@latest/assets/sponsors/automattic.svg\" alt=\"Automattic\" width=\"50%\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://servmask.com\"\u003e\u003cimg src=\"https://cdn.jsdelivr.net/gh/johnbillion/johnbillion@latest/assets/sponsors/servmask.svg\" alt=\"ServMask\" width=\"25%\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003ePlus all my kind sponsors on GitHub:\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://github.com/sponsors/johnbillion\"\u003e\u003cimg src=\"https://cdn.jsdelivr.net/gh/johnbillion/johnbillion@latest/sponsors.svg\" alt=\"Sponsors\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://github.com/sponsors/johnbillion\"\u003eClick here to find out about supporting my open source tools and plugins\u003c/a\u003e.\u003c/p\u003e\n\n## FAQs\n\n### When do these schemas apply?\n\nThe PHP object schemas apply whenever a supported PHP object is encoded to JSON. For example:\n\n```php\nprintf(\n\t'let wpPost = %s;',\n\twp_json_encode( get_post() )\n);\n```\n\nThe REST API object schemas apply to the response to a REST API request or `getEntityRecord()` call. Examples:\n\n```js\n// WP_REST_API_Categories\nconst api = wp.apiFetch( {\n\tpath: '/wp/v2/categories/'\n} );\n\n// WP_REST_API_Category\nconst category = getEntityRecord(\n\t'taxonomy',\n\t'category',\n\tid,\n);\n\n// WP_REST_API_Posts\nconst posts = getEntityRecords(\n\t'postType',\n\t'post',\n\tquery\n);\n```\n\nThe schemas also apply outside of an HTTP request, for example if you're saving data as a JSON file and reading it in a Node application.\n\n### Why are there different schemas for PHP objects and REST API responses?\n\nAn object in a REST API response is not the same as its corresponding object in PHP, in fact they are substantially different.\n\nSchemas are available via an OPTIONS request to the REST API endpoints, but the schemas do not adhere strictly to the JSON Schema standard. [Here's an article by Timothy B. Jacobs with more info](https://timothybjacobs.com/2017/05/17/json-schema-and-the-wp-rest-api/).\n\n### Are these schemas automatically generated from WordPress core?\n\nNo, but they are automatically tested against output from WordPress core to ensure their correctness. Extra documentation and schemas for properties have been added where possible, so generating them directly from WordPress core isn't desirable.\n\n### How do I know the schemas are accurate?\n\nThey're all tested against actual output from WordPress core.\n\n## Tests\n\nTo run the tests:\n\n* `nvm use`\n* `npm install`\n* `composer install`\n* `composer test`\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbillion%2Fwp-json-schemas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnbillion%2Fwp-json-schemas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbillion%2Fwp-json-schemas/lists"}