PHPackages                             spacedmonkey/wp-rest-blocks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. spacedmonkey/wp-rest-blocks

ActiveWordpress-plugin

spacedmonkey/wp-rest-blocks
===========================

Add gutenberg blocks data into post / page / widget REST API endpoints.

2.0.0(4mo ago)1232.0k25[13 issues](https://github.com/spacedmonkey/wp-rest-blocks/issues)[26 PRs](https://github.com/spacedmonkey/wp-rest-blocks/pulls)GPL-3.0-or-laterPHPPHP ^7.4 || ^8.0CI passing

Since Apr 26Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/spacedmonkey/wp-rest-blocks)[ Packagist](https://packagist.org/packages/spacedmonkey/wp-rest-blocks)[ Docs](http://wp-api.org/)[ GitHub Sponsors](https://github.com/spacedmonkey)[ RSS](/packages/spacedmonkey-wp-rest-blocks/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (10)Dependencies (15)Versions (54)Used By (0)

REST API blocks
===============

[](#rest-api-blocks)

Contributors: spacedmonkey Donate link: Tags: blocks, gutenberg, api, wp-json, rest-api Requires at least: 5.9 Tested up to: 6.9 Requires PHP: 7.4.0 Stable tag: 2.0.0 License: GPLv3 or later License URI:

[![](.wordpress-org/banner-1544x500.png)](.wordpress-org/banner-1544x500.png)

Add gutenberg blocks data into the post / page REST API endpoints.

[![Build Status](https://camo.githubusercontent.com/b6d05c4775101b7419a905283396d85d859c9480a8378ac40e90cdff941a4f87/68747470733a2f2f7472617669732d63692e636f6d2f7370616365646d6f6e6b65792f77702d726573742d626c6f636b732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/spacedmonkey/wp-rest-blocks)

Description
-----------

[](#description)

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, `has_blocks` and `blocks`. For example output.

```
"has_blocks": true,
"block_data": [
  {
	"blockName": "core/image",
	"attrs": {
	  "url": "https://www.spacedmonkey.com/wp-content/uploads/2018/12/test-image.jpg",
	  "alt": "Terminal de aeropuerto",
	  "caption": "fsfsdfdsfdssfd",
	  "href": "https://www.spacedmonkey.com/test-image",
	  "rel": "noreferrer noopener",
	  "linkClass": "jonny-123",
	  "linkTarget": "_blank",
	  "id": 147355,
	  "width": 582,
	  "height": 327,
	  "linkDestination": "attachment"
	},
	"innerBlocks": [
	],
	"innerHTML": "\nfsfsdfdsfdssfd\n",
	"innerContent": [
	  "\nfsfsdfdsfdssfd\n"
	],
	"rendered": "\nfsfsdfdsfdssfd\n"
  }
],

```

### Technical Notes

[](#technical-notes)

- Requires PHP 5.6+.
- Requires WordPress 5.5+.
- Issues and Pull requests welcome on the GitHub repository:

Development
-----------

[](#development)

This plugin uses `@wordpress/env` for local development and testing.

### Prerequisites

[](#prerequisites)

- Node.js 20+ and npm
- Docker Desktop (must be installed and running)

### Setup

[](#setup)

1. Clone the repository
2. Install dependencies:

    ```
    npm install
    composer install
    ```
3. Start the WordPress environment:

    ```
    npm run env:start
    ```

    This will start a local WordPress instance at `http://localhost:8888` (admin: `http://localhost:8888/wp-admin` with username `admin` and password `password`)

    **Note:** 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.

### Available Commands

[](#available-commands)

- `npm run env:start` - Start the WordPress environment
- `npm run env:stop` - Stop the WordPress environment
- `npm run env:reset` - Reset the environment (clean database)
- `npm run env:destroy` - Destroy the environment completely
- `npm run test:php` - Run PHPUnit tests
- `npm run test:php:multisite` - Run PHPUnit tests in multisite mode
- `npm run lint:php` - Run PHP CodeSniffer
- `npm run lint:php:fix` - Fix PHP coding standards issues automatically

### Running Tests

[](#running-tests)

After starting the environment with `npm run env:start`, you can run the tests:

```
npm run test:php
```

For multisite tests:

```
npm run test:php:multisite
```

### Accessing the Site

[](#accessing-the-site)

- **Development site**:
- **Admin dashboard**:  (admin/password)
- **Test site**:
- **Test admin**:  (admin/password)

Installation
------------

[](#installation)

### Using The WordPress Dashboard

[](#using-the-wordpress-dashboard)

1. Navigate to the 'Add New' in the plugins dashboard
2. Search for 'wp-rest-blocks'
3. Click 'Install Now'
4. Activate the plugin on the Plugin dashboard

### Uploading in WordPress Dashboard

[](#uploading-in-wordpress-dashboard)

1. Navigate to the 'Add New' in the plugins dashboard
2. Navigate to the 'Upload' area
3. Select `wp-rest-blocks.zip` from your computer
4. Click 'Install Now'
5. Activate the plugin in the Plugin dashboard

### Using FTP

[](#using-ftp)

1. Download `wp-rest-blocks.zip`
2. Extract the `wp-rest-blocks` directory to your computer
3. Upload the `wp-rest-blocks` directory to the `/wp-content/plugins/` directory
4. Activate the plugin in the Plugin dashboard

Screenshots
-----------

[](#screenshots)

1. Add fields to the rest api.

Changelog
---------

[](#changelog)

### 2.0.0

[](#200)

- Minimum PHP version increased from 7.0 to 7.4
- WordPress minimum version updated from 5.5 to 5.9
- Updated compatibility testing to PHP 8.0-8.4 (with 8.5 experimental support)
- Complete rewrite of code, using objects and is heavily typed.

### 1.0.2

[](#102)

- Fix issue with WordPress 6.5
- Update coding standards to WP coding standards 3.1.0
- Mark tested up to WP 6.5

### 1.0.1

[](#101)

- Update coding standards to WP coding standards 3.0.1
- Mark tested up to WP 6.4

### 1.0.0

[](#100)

Breaking change! The field in the REST API is changed from `blocks` to `block_data`.

### 0.5.0

[](#050)

- Add support for new post types added in WordPress 5.9.

### 0.4.0

[](#040)

- Added support for block based widget, added in WordPress 5.8. Block data is added to the /wp/v2/widgets endpoint.

### 0.3.2

[](#032)

- Update translations

### 0.3.1

[](#031)

- Hot fix.

### 0.3.0

[](#030)

- Improve support for block that have attributes that use query source type.
- Improve error handling for those that install this plugin without using composer.

### 0.2.1

[](#021)

- Update dependency.

### 0.2.0

[](#020)

- Breaking change. Field names have changed and required WordPress 5.5+

### 0.1.0

[](#010)

- First version.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance84

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 65.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~90 days

Recently: every ~364 days

Total

20

Last Release

132d ago

Major Versions

0.1.0 → v2.x-dev2021-04-27

0.5.0 → 1.0.02023-04-20

1.0.2 → 2.0.02026-01-03

PHP version history (2 changes)0.1.0PHP ^7.0 || ^8.0

2.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/237508?v=4)[Jonny Harris](/maintainers/spacedmonkey)[@spacedmonkey](https://github.com/spacedmonkey)

---

Top Contributors

[![spacedmonkey](https://avatars.githubusercontent.com/u/237508?v=4)](https://github.com/spacedmonkey "spacedmonkey (171 commits)")[![jonnynews](https://avatars.githubusercontent.com/u/148061917?v=4)](https://github.com/jonnynews "jonnynews (70 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (19 commits)")[![toshotosho](https://avatars.githubusercontent.com/u/2972490?v=4)](https://github.com/toshotosho "toshotosho (1 commits)")

---

Tags

blocksrest-apiwordpresswordpress-plugin

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spacedmonkey-wp-rest-blocks/health.svg)

```
[![Health](https://phpackages.com/badges/spacedmonkey-wp-rest-blocks/health.svg)](https://phpackages.com/packages/spacedmonkey-wp-rest-blocks)
```

###  Alternatives

[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[johnbillion/user-switching

Instant switching between user accounts in WordPress and WooCommerce.

19768.3k2](/packages/johnbillion-user-switching)[rainlab/blog-plugin

Blog plugin for October CMS

17257.7k](/packages/rainlab-blog-plugin)[rainlab/user-plugin

User plugin for October CMS

11954.3k13](/packages/rainlab-user-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
