WordPress plugin intelligence profile

Simple Posts API

A Plugin to provide a simple RESTful API to retrieve and manipulate Post data

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 4.0
Current version1.0
WordPress coverageTested up to WordPress 4.0
Minimum stackWP 3.5 · PHP —
Directory statusactive
Last directory update18 Nov 201411y ago
Active installations10Adoption metric — not a quality score
WordPress.org ratingNo WordPress.org ratings yet
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Simple Posts API version 1.0 as active, updated 11y ago and tested up to WordPress 4.0.

Overview

About this plugin

As more and more developers turn towards front-end apps and data solutions, a solid AJAX API is key to developing

a responsive, usable system of querying and modifying posts. While many solutions and plugins exist to help set up

endpoints, often times they are cumbersome or overly opinionated. Simple Posts API provides your site with an easy-to-use,

structure RESTful API with which to query, update, and delete posts. It is relatively unopinionated, so you can store and retrieve

post metadata at will without worrying about setting up fields beforehand. Additionally, it employs native WordPress Nonces

to provide a secure structure for updating your post data.

API Endpoints

Usage

There are four main operations you can use with this plugin:

  • Get
  • Put
  • Delete
  • Post

com/postsapi/OPERATION/POST_TYPE||ID You may pass a Post Type or ID as the second URL parameter depending on the operation you’re performing.

Each call must have a POST body containing a variable (nonce) containing a nonce value which WordPress will verify. There is a localized JS variable provided named secure which should be used. Some calls also allow other POST fields to be sent along with the call.

For calls which include Field data, the plugin will automatically determine which are Custom Fields and which are not.

See below for specifics on each operation.

GET

Retrieve a list of posts based on a provided Post Type or Post ID.

URL Path

com/postsapi/get/POST_TYPE

OR

com/postapi/get/ID

POST Body

Required:

  • nonce (nonce value for security)

Optional:

  • arguments (an array of get_post arguments to use in the call)

Example POST body:

log(data); });

Additional Notes:

The GET function returns author information for each post. If a user is logged in and has admin capabilities, the author information is extensive. If the user is not an admin, then any private information is stripped from the returned object for security purposes.

PUT

Update a post based on the provided ID and POSTed fields

URL Path

com/postapi/put/ID

POST Body

Required:

  • nonce (nonce value for security)
  • fields (an array of key:value pairs to determine which fields to update)

Optional:

  • force (boolean; if set to false, the call will return an error if any invalid field names are passed, otherwise it will update all valid fields regardless. Default is ‘false’)

Example POST body:

log( data ); });

DELETE

Delete a post based on the provided ID

URL Path

com/postapi/delete/ID

POST Body

Required:

  • nonce (nonce value for security)

Optional:

  • force (boolean; if set to false, the post will be sent to the trash, otherwise it will skip the trash and be permanently deleted. Default is ‘false’)

Example POST body:

log( data ); });

POST

Create a post of the given post type, including the provided fields

URL Path

com/postapi/post/POST_TYPE

POST Body

Required:

  • nonce (nonce value for security)
  • fields (an array of key:value pairs to determine which fields to include when creating the post)

Optional:

  • none

Example POST body:

log( data ); });

Errors and Status Messages

Each call will return a JSON object. Within the JSON object is a key named status. This contains a status code and status message.

You can check against this in your scripts in order to see if the call was successful or not. Any status code other than 200 is an error.

Status Codes

  • 200: Success
  • 400: No posts found
  • 401: Permission Denied (either failed the nonce verification or user not logged in)
  • 410: Invalid Post ID or Post Type provided
  • 420: Post ID not found
  • 430: Fields not found (status message lists fields)
  • 450: Post delete failed (WordPress could not delete the post, see the status message for details)
  • 460: Post type does not exist
  • 470: Could not create new post; see status message for error details

Actions

Each operation has its own unique _before and _after actions that can be hooked into. See below for a complete list.

GET

  • postsapi_before_get
  • postsapi_after_get

PUT

  • postsapi_before_put
  • postsapi_after_put

DELETE

  • postsapi_before_delete
  • postsapi_after_delete

POST

  • postsapi_before_post
  • postsapi_after_post
WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • ajax
  • api
  • posts
  • rest
  • restful
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 4.0

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 4.0.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to4.0
Minimum requirementsWordPress 3.5 · PHP not listed
Update activity18 Nov 201411y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.