Simple Posts API

Simple Posts API

Wordpress plugin

Install on Wordpress

App Details

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

Each operation can be accessed by visiting http://yoururl.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

http://yoururl.com/postsapi/get/POST_TYPE 

OR

http://yoururl.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:

jQuery.post( '/postsapi/get/post', { nonce: secure, arguments : {'posts_per_page': '-1'} }) .done(function( data ) { console.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

http://yoururl.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:

jQuery.post( '/postsapi/put/1', { nonce: secure, force: false, fields: { 'post_title': 'Updated Title', 'custom_text': 'Updated custom text' } } ) .done(function( data ) { console.log( data ); }); 

DELETE

Delete a post based on the provided ID

URL Path

http://yoururl.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:

jQuery.post( '/postsapi/delete/7', { nonce: secure, force: false } ) .done(function( data ) { console.log( data ); }); 

POST

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

URL Path

http://yoururl.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:

jQuery.post( '/postsapi/post/post', { nonce: secure, fields: { 'post_title': 'New Title', 'custom_text': 'New custom text', 'post_status': 'publish' } } ) .done(function( data ) { console.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

Pricing

Starting from $0 per month.

Check Out the What's New Popup Widget

By Common Ninja

What's New PopupTry For Free!

App Info

Rating

Reviewers

No reviews

Tags

ajax
api
posts
rest
RESTful

Developed By

mr_speer

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Forms

Forms plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Comments

Comments plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Maps

Maps plugins for Wordpress

Security

Security plugins for Wordpress

Translation

Translation plugins for Wordpress

Ads

Ads plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Chat

Chat plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Membership

Membership plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Contact

Contact plugins for Wordpress

Comments

Comments plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

What's New Popup for Wordpress logo

What's New Popup

Show product updates, new features, and announcements in a What's New popup that keeps users informed and engaged.

Logo Slider for Wordpress logo

Logo Slider

Add a logo slider to your site to showcase clients and partners, strengthen brand credibility, and build trust with new visitors.

Company Branch Flip Cards for Wordpress logo

Company Branch Flip Cards

Display locations with company branch flip cards that help customers find nearby offices, understand key details, and enjoy a smoother overall experience.

TikTok Feed for Wordpress logo

TikTok Feed

Show your latest TikTok videos in a live feed that keeps content fresh, builds social proof, and keeps visitors engaged.

YouTube Slider for Wordpress logo

YouTube Slider

Show YouTube videos with a YouTube slider that displays clips in a smooth, customizable layout to boost engagement.

PDF Viewer for Wordpress logo

PDF Viewer

Add a PDF viewer to your site to display documents, share product information, and give visitors easy access to helpful content in one place.

Instagram Slider for Wordpress logo

Instagram Slider

Add an Instagram slider to your site to display social posts dynamically and keep your visual content engaging and current.

Stories for Wordpress logo

Stories

Add interactive stories to your site to showcase content in a visual, mobile friendly format that boosts engagement and guides visitors toward action.

Image Stack Gallery for Wordpress logo

Image Stack Gallery

Showcase photos with an image stack gallery that layers images in a stacked display with smooth transitions to create a visually striking presentation.

Email Subscription Form for Wordpress logo

Email Subscription Form

Capture email leads with an email subscription form that collects addresses, saves entries, sends notifications, and helps grow your audience.

Google Play Reviews for Wordpress logo

Google Play Reviews

Show Google Play reviews for your Android app to build trust, strengthen credibility, and help visitors make confident download decisions.

Accordion for Wordpress logo

Accordion

Add collapsible content sections to your site to organize information and help users navigate content more efficiently.

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms