WordPress to JSON Api

30 / Oct / 2015 by Ankit Jain 0 comments

There are many websites which are currently running on wordpress. What if those websites need there data to use for mobile application. It is very tedious task to use the wordpress data for REST APIs.

As a solution to this problem there is good plugin called WordPress REST Api plugin. It makes the task of conversion the wordpress data to json very easily. You can find the plugin at :

https://wordpress.org/plugins/json-rest-api/

This plugin provides an easy to use REST API, available via HTTP. Grab your site’s data in simple JSON format, including users, posts, taxonomies and more. Retrieving or updating data is as simple as sending a HTTP request.

Steps for JSON Parsing from WordPress

  1.  Download and Install the JSON API Plugin to your WordPress site (Copy the plugin into plugins folder for offline users).

addPlugin

2. Go to JSON API Settings:
Settings => JSON API

settingJSON

3. Methods in JSON API :

  • Core
  • Widget
  • Respond
  • Post

4. Create Base API Url :

You can find the base API url at the bottom of settings page Named as API BASE you can even change it as per requirement.

5. Call GET API Methods

http://<BASE URL>/<method name>/

6. Call POST API Methods

  • Get nonce
    • http://<BASE URL>/get_nonce/?controller=posts&method=<method name>
  • Use nonce in method calling
    • http://<BASE URL>/create_post/?nonce=46c26394d6&title=mypost2&status=publish

Note: Parameters can be added as per post structure

 

FOUND THIS USEFUL? SHARE IT

Leave a comment -