What are APIs?
Woah, woah, woah. Let’s start at the beginning. It doesn’t do any good to start throwing around TLAs* that people may not understand. Application Programming Interfaces (APIs) are basically hooks into a software program that lets one program work with another to exchange information or perform tasks together. They are a set of rules about how the programs will connect, what the common protocols are and what actions each is allowed to perform with the other. These allow a website, an app, or a server-based application to operate with another system in order to perform tasks that your business will need to function well.
For example, if your online store is set up to send all of the new customers over to your accounting system, chances are good there is an automated bit of code running on both systems that allows them to connect and update records with any edits, new orders, or account status changes. If done properly, you may not even notice it happening, but it works.
*Three Letter Acronyms 😉
WordPress’s API
Officially known as the WordPress REST API, this API is a great tool for a number of purposes. It was built by the WordPress open-source community to make WordPress much more extensible. The project started in 2013 and was slowly integrated into the core functionality of WordPress.
The API is built on a RESTful structure (REST stands for REpresentational State Transfer) which uses a common data structure that integrates easily with many different web application languages. One of the defining aspects of REST is that it uses JSON (JavaScript Object Notation) to outline how data is formatted. This is useful since so many different technologies use the same syntax to order and organize data already. This includes technologies such as Node.js, ECMAScript, React.js and many other popular web development languages. It’s also worth noting that most other programming languages include standard parsers for JSON as well. In short, it’s a pretty universal protocol to use for APIs because at least you have at least one thing covered pretty easily; how are you going to make sure both sides can understand the data going back and forth.
The API further defines all of the ways in which you can both retrieve and update parts of a WordPress website. There are connections defined to interact with Users, Posts, Metadata, and Site Settings. Each of these areas of WordPress are defined as “endpoints” in the API that can be “called” by a separate program to read or write information to and from WordPress so that each system can perform the tasks they were built for and stay synchronized with regards to shared data.
You might see that this is a potential concern. If you can read and write stuff to a WordPress site, isn’t that a security risk? Good catch! Good news is that the API also allows you to tune the amount of access is allowed at both a broad and granular level. It is also important to know that none of the functions that normally require a login can be accessed without authentication. This prevents unauthorized changes from happening via the API. There are times where you may want to grant access to stuff on your website without being authenticated, but such scenarios are limited use cases and include the same sort of data that is visible do anyone browsing your site to begin with.
Thinking of Integrating WordPress with Your Mobile App?
Want a more dynamic website to work with your Mobile App? They don’t have to be separate! Talk with us about how you can link things together and build a bridge from phone to the desktop.
What you can do using the WP REST API?
So how do you make use of the WordPress REST API? Fun fact! You already do! In fact, much of the Administrative Dashboard in WordPress uses it to make updates and change settings. Here some other ways it can be used that might have bigger implications for your business, though:
- Headless CMS – This lets you use the familiar and powerful WordPress Presentation templates to publish content created in other systems – or vice versa
- Desktop version of your Mobile App
- Web App version of your website for offline and mobile users
- E-commerce fulfillment – synchronize order information between your online store and in-store inventory, shipping, customer support and relationship management systems, and any other part of your operations
- Internet of Things (IoT) – Displaying Real-time information from remote devices on your website.
There always new ways to connect data from one system to another. The WordPress REST API is built like the rest of WordPress with the ability to extend it and add new endpoints for custom data. A good example of how this was done successfully is the most popular e-commerce plugin for WordPress – WooCommerce. WooCommerce extended the WP API to allow access to many parts of your online storefront so Woo can be integrated into any system capable of communicating server-to-server. If you have custom post types or other data that is unique to your needs, those too can be accessed through the API to help your business perform more efficiently. No more spreadsheet imports!
Have you been using the WordPress REST API to do something interesting? Are you trying to find a better way to get data to flow from your website to other systems and want some tips about where to start? Let us know about it in the comments!