{"id":32936,"date":"2014-11-18T02:27:17","date_gmt":"2014-11-18T02:27:17","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/simple-posts-api\/"},"modified":"2014-11-18T02:40:50","modified_gmt":"2014-11-18T02:40:50","slug":"simple-posts-api","status":"publish","type":"plugin","link":"https:\/\/tah.wordpress.org\/plugins\/simple-posts-api\/","author":13569059,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0","stable_tag":"trunk","tested":"4.0.38","requires":"3.5","requires_php":"","requires_plugins":"","header_name":"Posts API","header_author":"Aaron Speer, Westwerk","header_description":"","assets_banners_color":"e2e2e2","last_updated":"2014-11-18 02:40:50","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"#","header_author_uri":"http:\/\/westwerk.com","rating":0,"author_block_rating":0,"active_installs":10,"downloads":1968,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":{"1.0":"<ul>\n<li>Initial Version<\/li>\n<\/ul>"},"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":"1027665","resolution":"128x128","location":"assets"}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":"1027658","resolution":"1544x500","location":"assets"},"banner-772x250.png":{"filename":"banner-772x250.png","revision":"1027658","resolution":"772x250","location":"assets"}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[221,1556,166,2299,26525],"plugin_category":[59],"plugin_contributors":[80421,80422],"plugin_business_model":[],"class_list":["post-32936","plugin","type-plugin","status-publish","hentry","plugin_tags-ajax","plugin_tags-api","plugin_tags-posts","plugin_tags-rest","plugin_tags-restful","plugin_category-utilities-and-tools","plugin_contributors-mr_speer","plugin_contributors-werkpress","plugin_committers-mr_speer"],"banners":{"banner":"https:\/\/ps.w.org\/simple-posts-api\/assets\/banner-772x250.png?rev=1027658","banner_2x":"https:\/\/ps.w.org\/simple-posts-api\/assets\/banner-1544x500.png?rev=1027658","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/simple-posts-api\/assets\/icon-128x128.png?rev=1027665","icon_2x":false,"generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>As more and more developers turn towards front-end apps and data solutions, a solid AJAX API is key to developing\na responsive, usable system of querying and modifying posts. While many solutions and plugins exist to help set up\nendpoints, often times they are cumbersome or overly opinionated. Simple Posts API provides your site with an easy-to-use,\nstructure RESTful API with which to query, update, and delete posts. It is relatively unopinionated, so you can store and retrieve \npost metadata at will without worrying about setting up fields beforehand. Additionally, it employs native WordPress Nonces\nto provide a secure structure for updating your post data.<\/p>\n\n<h3>API Endpoints<\/h3>\n\n<h4>Usage<\/h4>\n\n<p>There are four main operations you can use with this plugin:<\/p>\n\n<ul>\n<li>Get<\/li>\n<li>Put<\/li>\n<li>Delete<\/li>\n<li>Post<\/li>\n<\/ul>\n\n<p>Each operation can be accessed by visiting <code>http:\/\/yoururl.com\/postsapi\/OPERATION\/POST_TYPE||ID<\/code> You may pass a Post Type or ID as the second URL parameter depending on the operation you're performing.<\/p>\n\n<p>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 <code>secure<\/code> which should be used. Some calls also allow other POST fields to be sent along with the call.<\/p>\n\n<p>For calls which include Field data, the plugin will automatically determine which are Custom Fields and which are not.<\/p>\n\n<p>See below for specifics on each operation.<\/p>\n\n<h4>GET<\/h4>\n\n<p><em>Retrieve a list of posts based on a provided Post Type or Post ID.<\/em><\/p>\n\n<p><strong>URL Path<\/strong><\/p>\n\n<pre><code>http:\/\/yoururl.com\/postsapi\/get\/POST_TYPE\n<\/code><\/pre>\n\n<p><strong>OR<\/strong><\/p>\n\n<pre><code>http:\/\/yoururl.com\/postapi\/get\/ID\n<\/code><\/pre>\n\n<p><strong>POST Body<\/strong><\/p>\n\n<p><strong>Required<\/strong>:<\/p>\n\n<ul>\n<li>nonce (nonce value for security)<\/li>\n<\/ul>\n\n<p><strong>Optional<\/strong>:<\/p>\n\n<ul>\n<li>arguments (an array of get_post arguments to use in the call)<\/li>\n<\/ul>\n\n<p><strong>Example POST body<\/strong>:<\/p>\n\n<pre><code>jQuery.post( '\/postsapi\/get\/post', { nonce: secure, arguments : {'posts_per_page': '-1'} })\n  .done(function( data ) {\n    console.log(data);\n});\n<\/code><\/pre>\n\n<p><strong>Additional Notes<\/strong>:<\/p>\n\n<p>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.<\/p>\n\n<h4>PUT<\/h4>\n\n<p><em>Update a post based on the provided ID and POSTed fields<\/em><\/p>\n\n<p><strong>URL Path<\/strong><\/p>\n\n<pre><code>http:\/\/yoururl.com\/postapi\/put\/ID\n<\/code><\/pre>\n\n<p><strong>POST Body<\/strong><\/p>\n\n<p><strong>Required<\/strong>:<\/p>\n\n<ul>\n<li>nonce (nonce value for security)<\/li>\n<li>fields (an array of key:value pairs to determine which fields to update)<\/li>\n<\/ul>\n\n<p><strong>Optional<\/strong>:<\/p>\n\n<ul>\n<li>force (boolean; if set to <code>false<\/code>, the call will return an error if any invalid field names are passed, otherwise it will update all valid fields regardless. Default is 'false')<\/li>\n<\/ul>\n\n<p><strong>Example POST body<\/strong>:<\/p>\n\n<pre><code>jQuery.post( '\/postsapi\/put\/1', { nonce: secure, force: false, fields: { 'post_title': 'Updated Title', 'custom_text': 'Updated custom text' } } )\n.done(function( data ) {\n  console.log( data );\n});\n<\/code><\/pre>\n\n<h4>DELETE<\/h4>\n\n<p><em>Delete a post based on the provided ID<\/em><\/p>\n\n<p><strong>URL Path<\/strong><\/p>\n\n<pre><code>http:\/\/yoururl.com\/postapi\/delete\/ID\n<\/code><\/pre>\n\n<p><strong>POST Body<\/strong><\/p>\n\n<p><strong>Required<\/strong>:<\/p>\n\n<ul>\n<li>nonce (nonce value for security)<\/li>\n<\/ul>\n\n<p><strong>Optional<\/strong>:<\/p>\n\n<ul>\n<li>force (boolean; if set to <code>false<\/code>, the post will be sent to the trash, otherwise it will skip the trash and be permanently deleted. Default is 'false')<\/li>\n<\/ul>\n\n<p><strong>Example POST body<\/strong>:<\/p>\n\n<pre><code>jQuery.post( '\/postsapi\/delete\/7', { nonce: secure, force: false } )\n.done(function( data ) {\n  console.log( data );\n});\n<\/code><\/pre>\n\n<h4>POST<\/h4>\n\n<p><em>Create a post of the given post type, including the provided fields<\/em><\/p>\n\n<p><strong>URL Path<\/strong><\/p>\n\n<pre><code>http:\/\/yoururl.com\/postapi\/post\/POST_TYPE\n<\/code><\/pre>\n\n<p><strong>POST Body<\/strong><\/p>\n\n<p><strong>Required<\/strong>:<\/p>\n\n<ul>\n<li>nonce (nonce value for security)<\/li>\n<li>fields (an array of key:value pairs to determine which fields to include when creating the post)<\/li>\n<\/ul>\n\n<p><strong>Optional<\/strong>:<\/p>\n\n<ul>\n<li>none<\/li>\n<\/ul>\n\n<p><strong>Example POST body<\/strong>:<\/p>\n\n<pre><code>jQuery.post( '\/postsapi\/post\/post', { nonce: secure, fields: { 'post_title': 'New Title', 'custom_text': 'New custom text', 'post_status': 'publish' } } )\n.done(function( data ) {\n  console.log( data );\n});\n<\/code><\/pre>\n\n<h4>Errors and Status Messages<\/h4>\n\n<p>Each call will return a JSON object. Within the JSON object is a key named <code>status<\/code>. 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.<\/p>\n\n<h4>Status Codes<\/h4>\n\n<ul>\n<li><strong>200<\/strong>: Success<\/li>\n<li><strong>400<\/strong>: No posts found<\/li>\n<li><strong>401<\/strong>: Permission Denied (either failed the nonce verification or user not logged in)<\/li>\n<li><strong>410<\/strong>: Invalid Post ID or Post Type provided<\/li>\n<li><strong>420<\/strong>: Post ID not found<\/li>\n<li><strong>430<\/strong>: Fields not found (status message lists fields)<\/li>\n<li><strong>450<\/strong>: Post delete failed (Wordpress could not delete the post, see the status message for details)<\/li>\n<li><strong>460<\/strong>: Post type does not exist<\/li>\n<li><strong>470<\/strong>: Could not create new post; see status message for error details<\/li>\n<\/ul>\n\n<h4>Actions<\/h4>\n\n<p>Each operation has its own unique <code>_before<\/code> and <code>_after<\/code> actions that can be hooked into. See below for a complete list.<\/p>\n\n<p><strong>GET<\/strong><\/p>\n\n<ul>\n<li><code>postsapi_before_get<\/code><\/li>\n<li><code>postsapi_after_get<\/code><\/li>\n<\/ul>\n\n<p><strong>PUT<\/strong><\/p>\n\n<ul>\n<li><code>postsapi_before_put<\/code><\/li>\n<li><code>postsapi_after_put<\/code><\/li>\n<\/ul>\n\n<p><strong>DELETE<\/strong><\/p>\n\n<ul>\n<li><code>postsapi_before_delete<\/code><\/li>\n<li><code>postsapi_after_delete<\/code><\/li>\n<\/ul>\n\n<p><strong>POST<\/strong><\/p>\n\n<ul>\n<li><code>postsapi_before_post<\/code><\/li>\n<li><code>postsapi_after_post<\/code><\/li>\n<\/ul>\n\n<!--section=installation-->\n<h4>Using The WordPress Dashboard<\/h4>\n\n<ol>\n<li>Navigate to the \\'Add New\\' in the plugins dashboard<\/li>\n<li>Search for \u2018Simple Posts API\u2019<\/li>\n<li>Click \\'Install Now\\'<\/li>\n<li>Activate the plugin on the Plugin dashboard<\/li>\n<\/ol>\n\n<h4>Uploading in WordPress Dashboard<\/h4>\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>simple-posts-api.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<h4>Using FTP<\/h4>\n\n<ol>\n<li>Download <code>simple-posts-api.zip<\/code><\/li>\n<li>Extract the <code>simple-posts-api<\/code> directory to your computer<\/li>\n<li>Upload the <code>simple-posts-api<\/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=faq-->\n<ul>\n<li>I'm getting a 404 Error, what's the deal? -<\/li>\n<\/ul>\n\n<p>Your permalinks may need to be refreshed. Go to Settings-&gt;Permalinks and choose a non-default setting, or just click save if you're already\nusing a non-default setting. This will flush your permalink settings and correct the 404 error.<\/p>\n\n<!--section=changelog-->\n<h4>1.0<\/h4>\n\n<ul>\n<li>Initial Version<\/li>\n<\/ul>","raw_excerpt":"A Plugin to provide a simple RESTful API to retrieve and manipulate Post data","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/32936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=32936"}],"author":[{"embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/mr_speer"}],"wp:attachment":[{"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=32936"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=32936"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=32936"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=32936"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=32936"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/tah.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=32936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}