Json To Rest API Plugin
A simple plugin to turn JSONs into REST service.
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/daino92/json2rest/archive/refs/heads/main.zipJson2Rest is a lightweight WordPress plugin that turns named JSON data into a configurable REST endpoint.
It is useful for small WordPress powered projects that need to serve structured data to a frontend or another application without building a custom backend.
Features
- Store multiple named JSON objects from the WordPress admin
- Configure the REST route and query parameter name
- Retrieve a specific JSON object with a
GETrequest - Use the standard WordPress REST API namespace
- Keep data managed inside WordPress with no external database required
- Includes a simple admin interface for adding, editing, and removing JSON blocks
Requirements
- A WordPress installation with REST API support
- PHP with the WordPress functions used by the plugin
Installation
- Download or clone this repository.
- Copy the
Json2Restdirectory intowp-content/plugins/. - Log in to WordPress and open Plugins.
- Activate Json To Rest API Plugin.
- Open JSON Settings in the WordPress admin menu.
Configuration
1. Configure the endpoint
Open JSON Settings and provide:
- Parameter Name — the query-string parameter used to select a JSON object
- REST Name — the endpoint path
For example:
Parameter Name: school
REST Name: schools
2. Add JSON data
Open JSON Settings → Fill JSONs, add a name for each data block, and enter valid JSON.
Example:
{
"name": "University of Athens",
"city": "Athens",
"students": 42000
}
Save the data before requesting the endpoint.
API usage
The endpoint is available through the WordPress REST API:
GET https://example.com/wp-json/rest/v1/schools?school=athens
The value of school must match one of the JSON block names saved in the admin interface.
Example response:
{
"name": "University of Athens",
"city": "Athens",
"students": 42000
}
The endpoint returns an error when the plugin has not been configured, the requested parameter is missing, or no matching JSON object exists.
Project structure
json-rest-api-plugin.php Plugin entry point and WordPress hooks
includes/ Settings, REST endpoint, and helper functions
templates/ WordPress admin screens
assets/ Admin JavaScript and CSS
Development
This is a WordPress plugin and does not currently use Composer or a build step. Install it in a local WordPress environment and test changes through the WordPress admin and REST API.
License
This project is licensed under the MIT License.