WordPress JSON REST API [Repost]
Tuesday, September 22, 2015Now a days, accessing data remotely is a common trends in website and application development. Goal for users and developers is the ability to access and update data remotely is used by mobile/smart device applications, web based application, desktop based application, and browser applications. They need to be able to access data in a manner of standardised and interoperable. WordPress core is going to include a new and powerful API that will add a new edge to be part of the interactive web. Currently, WordPress core provides XML-RPC API to full-fill API requirements and as a solution of ability to access and update data remotely. But, the XML-RPC API contains following issues which can cause problems for clients:
- XML is a quitly difficult format to parse and implement.
- The complexity of data representation can cause issues when implementing in clients; to cleaning up XML, the WordPress iOS client is dedicated 40% of its codebase.
- Server-side implementation using XML is also a difficult, because XML format is difficult to generate. So it can produce numerous issues including security issues, such as XXE, as well as encoding issues to have data appeared in the server-side implementation of XML-RPC in core.
- In order to extract all data from the API, clients may be forced to learn multiple specifications. Because the RPC commands are a mixture of standardised and WordPress-specific APIs.
- JSON is most standardized format and JSON standard is used in Data serialization, which maps more directly to common data structures in most programming languages.
- The REST API uses the HTTP 1.1 standard to Communicate and it is available in almost every programming language.
- the majority of HTTP clients used Representational State Transfer ("REST") semantics for interaction.
- The data serialization layer is independent of the data manipulation and accessing layer, enabling the JSON or HTTP semantics to be replaced with another protocol, such as MessagePack or Cap'n Proto.
- The internal structure of the API enables using the data layer of the API for other uses, such as a future version of WP-CLI or internal form handlers.
- The API is using core coding standards, liberal use of actions and filters, and full translatability for integration into core.
- Core data (data types included with standard installations) is comprehensively covered by the API, includes built-in post types and related metadata, as well as providing simple extensibility for the plugin and theme ecosystems.
- The API relies on no external services. It comes with some methods for automatically locating the API given only a WordPress site address, as well as programatically assessing the availability of parts of the API.
“We’ve tried to design this so that even frontend developers with minimal knowledge of WordPress can go out and start creating, and those with WP knowledge can feel at home. And because of WP API’s internal reusability, you can also render it server side with practically the same code. The API will enable front end developers to build themes on WordPress without needing to know PHP or many of WP’s quirks. I believe it will really open up WordPress as a framework that’s easily accessible to everyone.” - Ryan McCueFollowing links will help you to know more details:


0 comments