{"id":145482,"date":"2021-08-11T16:02:34","date_gmt":"2021-08-11T16:02:34","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/rest-api-blocks\/"},"modified":"2026-01-03T16:16:04","modified_gmt":"2026-01-03T16:16:04","slug":"rest-api-blocks","status":"publish","type":"plugin","link":"https:\/\/bal.wordpress.org\/plugins\/rest-api-blocks\/","author":2670738,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"2.0.0","stable_tag":"2.0.0","tested":"6.9.4","requires":"5.9","requires_php":"7.4","requires_plugins":null,"header_name":"REST API Blocks","header_author":"Jonathan Harris","header_description":"Add gutenberg blocks data into the post \/ page endpoints api.","assets_banners_color":"ffffff","last_updated":"2026-01-03 16:16:04","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/github.com\/sponsors\/spacedmonkey","header_plugin_uri":"https:\/\/github.com\/spacedmonkey\/wp-rest-blocks","header_author_uri":"https:\/\/www.spacedmonkey.com\/","rating":5,"author_block_rating":5,"active_installs":200,"downloads":6773,"num_ratings":2,"support_threads":0,"support_threads_resolved":0,"author_block_count":1,"sections":["description","installation","changelog"],"tags":{"0.2.1":{"tag":"0.2.1","author":"spacedmonkey","date":"2021-08-11 16:02:17"},"0.2.2":{"tag":"0.2.2","author":"spacedmonkey","date":"2021-08-11 16:33:31"},"0.2.4":{"tag":"0.2.4","author":"spacedmonkey","date":"2021-08-11 17:07:28"},"0.2.5":{"tag":"0.2.5","author":"spacedmonkey","date":"2021-08-11 17:22:25"},"0.2.6":{"tag":"0.2.6","author":"spacedmonkey","date":"2021-08-11 17:32:51"},"0.3.0":{"tag":"0.3.0","author":"spacedmonkey","date":"2021-08-17 12:02:27"},"0.3.1":{"tag":"0.3.1","author":"spacedmonkey","date":"2021-08-17 12:04:54"},"0.3.2":{"tag":"0.3.2","author":"spacedmonkey","date":"2021-08-17 12:07:16"},"0.4.0":{"tag":"0.4.0","author":"spacedmonkey","date":"2021-09-06 23:01:24"},"0.5.0":{"tag":"0.5.0","author":"spacedmonkey","date":"2022-01-07 18:26:05"},"1.0.0":{"tag":"1.0.0","author":"spacedmonkey","date":"2023-04-20 20:40:54"},"1.0.1":{"tag":"1.0.1","author":"spacedmonkey","date":"2023-12-18 16:16:49"},"1.0.2":{"tag":"1.0.2","author":"spacedmonkey","date":"2024-04-20 14:46:44"},"2.0.0":{"tag":"2.0.0","author":"spacedmonkey","date":"2026-01-03 16:16:04"}},"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":2},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":2581604,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":2581604,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":2581604,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.png":{"filename":"banner-772x250.png","revision":2581604,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.2.1","0.2.2","0.2.4","0.2.5","0.2.6","0.3.0","0.3.1","0.3.2","0.4.0","0.5.0","1.0.0","1.0.1","1.0.2","2.0.0"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":2581604,"resolution":"1","location":"assets","locale":""}},"screenshots":{"1":"Add fields to the rest api."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[1556,4121,148076,23853,38850],"plugin_category":[],"plugin_contributors":[81978],"plugin_business_model":[],"class_list":["post-145482","plugin","type-plugin","status-publish","hentry","plugin_tags-api","plugin_tags-blocks","plugin_tags-gutenberg","plugin_tags-rest-api","plugin_tags-wp-json","plugin_contributors-spacedmonkey","plugin_committers-spacedmonkey"],"banners":{"banner":"https:\/\/ps.w.org\/rest-api-blocks\/assets\/banner-772x250.png?rev=2581604","banner_2x":"https:\/\/ps.w.org\/rest-api-blocks\/assets\/banner-1544x500.png?rev=2581604","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/rest-api-blocks\/assets\/icon-128x128.png?rev=2581604","icon_2x":"https:\/\/ps.w.org\/rest-api-blocks\/assets\/icon-256x256.png?rev=2581604","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/rest-api-blocks\/assets\/screenshot-1.png?rev=2581604","caption":"Add fields to the rest api."}],"raw_content":"<!--section=description-->\n<p>A simple plugin to add block data in json format into the rest api. Once installed, there will be two new fields added to the rest api, <code>has_blocks<\/code> and <code>blocks<\/code>.\nFor example output.\n    <code>\"has_blocks\": true,\n\"block_data\": [\n  {\n    \"blockName\": \"core\/image\",\n    \"attrs\": {\n      \"url\": \"https:\/\/www.spacedmonkey.com\/wp-content\/uploads\/2018\/12\/test-image.jpg\",\n      \"alt\": \"Terminal de aeropuerto\",\n      \"caption\": \"fsfsdfdsfdssfd\",\n      \"href\": \"https:\/\/www.spacedmonkey.com\/test-image\",\n      \"rel\": \"noreferrer noopener\",\n      \"linkClass\": \"jonny-123\",\n      \"linkTarget\": \"_blank\",\n      \"id\": 147355,\n      \"width\": 582,\n      \"height\": 327,\n      \"linkDestination\": \"attachment\"\n    },\n    \"innerBlocks\": [\n    ],\n    \"innerHTML\": \"\\n&lt;figure class=\\\"wp-block-image is-resized\\\"&gt;&lt;a class=\\\"jonny-123\\\" href=\\\"https:\/\/www.spacedmonkey.com\/test-image\\\" target=\\\"_blank\\\" rel=\\\"noreferrer noopener\\\"&gt;&lt;img src=\\\"https:\/\/www.spacedmonkey.com\/wp-content\/uploads\/2018\/12\/test-image.jpg\\\" alt=\\\"Terminal de aeropuerto\\\" class=\\\"wp-image-147355\\\" width=\\\"582\\\" height=\\\"327\\\"\/&gt;&lt;\/a&gt;&lt;figcaption&gt;fsfsdfdsfdssfd&lt;\/figcaption&gt;&lt;\/figure&gt;\\n\",\n    \"innerContent\": [\n      \"\\n&lt;figure class=\\\"wp-block-image is-resized\\\"&gt;&lt;a class=\\\"jonny-123\\\" href=\\\"https:\/\/www.spacedmonkey.com\/test-image\\\" target=\\\"_blank\\\" rel=\\\"noreferrer noopener\\\"&gt;&lt;img src=\\\"https:\/\/www.spacedmonkey.com\/wp-content\/uploads\/2018\/12\/test-image.jpg\\\" alt=\\\"Terminal de aeropuerto\\\" class=\\\"wp-image-147355\\\" width=\\\"582\\\" height=\\\"327\\\"\/&gt;&lt;\/a&gt;&lt;figcaption&gt;fsfsdfdsfdssfd&lt;\/figcaption&gt;&lt;\/figure&gt;\\n\"\n    ],\n    \"rendered\": \"\\n&lt;figure class=\\\"wp-block-image is-resized\\\"&gt;&lt;a class=\\\"jonny-123\\\" href=\\\"https:\/\/www.spacedmonkey.com\/test-image\\\" target=\\\"_blank\\\" rel=\\\"noreferrer noopener\\\"&gt;&lt;img src=\\\"https:\/\/www.spacedmonkey.com\/wp-content\/uploads\/2018\/12\/test-image.jpg\\\" alt=\\\"Terminal de aeropuerto\\\" class=\\\"wp-image-147355\\\" width=\\\"582\\\" height=\\\"327\\\"\/&gt;&lt;\/a&gt;&lt;figcaption&gt;fsfsdfdsfdssfd&lt;\/figcaption&gt;&lt;\/figure&gt;\\n\"\n  }\n],<\/code><\/p>\n\n<h3>Technical Notes<\/h3>\n\n<ul>\n<li>Requires PHP 5.6+.<\/li>\n<li>Requires WordPress 5.5+.<\/li>\n<li>Issues and Pull requests welcome on the GitHub repository: https:\/\/github.com\/spacedmonkey\/wp-rest-blocks<\/li>\n<\/ul>\n\n<h3>Development<\/h3>\n\n<p>This plugin uses <code>@wordpress\/env<\/code> for local development and testing.<\/p>\n\n<h3>Prerequisites<\/h3>\n\n<ul>\n<li>Node.js 20+ and npm<\/li>\n<li>Docker Desktop (must be installed and running)<\/li>\n<\/ul>\n\n<h3>Setup<\/h3>\n\n<ol>\n<li>Clone the repository<\/li>\n<li><p>Install dependencies:\n   <code>bash\nnpm install\ncomposer install<\/code><\/p><\/li>\n<li><p>Start the WordPress environment:\n   <code>bash\nnpm run env:start<\/code><\/p>\n\n<p>This will start a local WordPress instance at <code>http:\/\/localhost:8888<\/code> (admin: <code>http:\/\/localhost:8888\/wp-admin<\/code> with username <code>admin<\/code> and password <code>password<\/code>)<\/p>\n\n<p><strong>Note:<\/strong> Docker must be running for this to work. The first time you run this, it will download WordPress and set up the database, which may take a few minutes.<\/p><\/li>\n<\/ol>\n\n<h3>Available Commands<\/h3>\n\n<ul>\n<li><code>npm run env:start<\/code> - Start the WordPress environment<\/li>\n<li><code>npm run env:stop<\/code> - Stop the WordPress environment<\/li>\n<li><code>npm run env:reset<\/code> - Reset the environment (clean database)<\/li>\n<li><code>npm run env:destroy<\/code> - Destroy the environment completely<\/li>\n<li><code>npm run test:php<\/code> - Run PHPUnit tests<\/li>\n<li><code>npm run test:php:multisite<\/code> - Run PHPUnit tests in multisite mode<\/li>\n<li><code>npm run lint:php<\/code> - Run PHP CodeSniffer<\/li>\n<li><code>npm run lint:php:fix<\/code> - Fix PHP coding standards issues automatically<\/li>\n<\/ul>\n\n<h3>Running Tests<\/h3>\n\n<p>After starting the environment with <code>npm run env:start<\/code>, you can run the tests:<\/p>\n\n<pre><code>`bash\n<\/code><\/pre>\n\n<p>npm run test:php\n    `<\/p>\n\n<p>For multisite tests:<\/p>\n\n<pre><code>`bash\n<\/code><\/pre>\n\n<p>npm run test:php:multisite\n    `<\/p>\n\n<h3>Accessing the Site<\/h3>\n\n<ul>\n<li><strong>Development site<\/strong>: http:\/\/localhost:8888<\/li>\n<li><strong>Admin dashboard<\/strong>: http:\/\/localhost:8888\/wp-admin (admin\/password)<\/li>\n<li><strong>Test site<\/strong>: http:\/\/localhost:8889<\/li>\n<li><strong>Test admin<\/strong>: http:\/\/localhost:8889\/wp-admin (admin\/password)<\/li>\n<\/ul>\n\n<!--section=installation-->\n<h3>Using The WordPress Dashboard<\/h3>\n\n<ol>\n<li>Navigate to the 'Add New' in the plugins dashboard<\/li>\n<li>Search for 'wp-rest-blocks'<\/li>\n<li>Click 'Install Now'<\/li>\n<li>Activate the plugin on the Plugin dashboard<\/li>\n<\/ol>\n\n<h3>Uploading in WordPress Dashboard<\/h3>\n\n<ol>\n<li>Navigate to the 'Add New' in the plugins dashboard<\/li>\n<li>Navigate to the 'Upload' area<\/li>\n<li>Select <code>wp-rest-blocks.zip<\/code> from your computer<\/li>\n<li>Click 'Install Now'<\/li>\n<li>Activate the plugin in the Plugin dashboard<\/li>\n<\/ol>\n\n<h3>Using FTP<\/h3>\n\n<ol>\n<li>Download <code>wp-rest-blocks.zip<\/code><\/li>\n<li>Extract the <code>wp-rest-blocks<\/code> directory to your computer<\/li>\n<li>Upload the <code>wp-rest-blocks<\/code> directory to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin in the Plugin dashboard<\/li>\n<\/ol>\n\n<!--section=changelog-->\n<h3>1.0.2<\/h3>\n\n<ul>\n<li>Fix issue with WordPress 6.5<\/li>\n<li>Update coding standards to WP coding standards 3.1.0<\/li>\n<li>Mark tested up to WP 6.5<\/li>\n<\/ul>\n\n<h3>1.0.1<\/h3>\n\n<ul>\n<li>Update coding standards to WP coding standards 3.0.1<\/li>\n<li>Mark tested up to WP 6.4<\/li>\n<\/ul>\n\n<h3>1.0.0<\/h3>\n\n<p>Breaking change!\nThe field in the REST API is changed from <code>blocks<\/code> to <code>block_data<\/code>.<\/p>\n\n<h3>0.5.0<\/h3>\n\n<ul>\n<li>Add support for new post types added in WordPress 5.9.<\/li>\n<\/ul>\n\n<h3>0.4.0<\/h3>\n\n<ul>\n<li>Added support for block based widget, added in WordPress 5.8. Block data is added to the \/wp\/v2\/widgets endpoint.<\/li>\n<\/ul>\n\n<h3>0.3.2<\/h3>\n\n<ul>\n<li>Update translations<\/li>\n<\/ul>\n\n<h3>0.3.1<\/h3>\n\n<ul>\n<li>Hot fix.<\/li>\n<\/ul>\n\n<h3>0.3.0<\/h3>\n\n<ul>\n<li>Improve support for block that have attributes that use query source type.<\/li>\n<li>Improve error handling for those that install this plugin without using composer.<\/li>\n<\/ul>\n\n<h3>0.2.1<\/h3>\n\n<ul>\n<li>Update dependency.<\/li>\n<\/ul>\n\n<h3>0.2.0<\/h3>\n\n<ul>\n<li>Breaking change. Field names have changed and required WordPress 5.5+<\/li>\n<\/ul>\n\n<h3>0.1.0<\/h3>\n\n<ul>\n<li>First version.<\/li>\n<\/ul>","raw_excerpt":"Add gutenberg blocks data into the post \/ page REST API endpoints.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/145482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=145482"}],"author":[{"embeddable":true,"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/spacedmonkey"}],"wp:attachment":[{"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=145482"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=145482"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=145482"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=145482"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=145482"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/bal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=145482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}