The REST API is the next big thing in the world of WordPress development. Ever since its inception, it has been gaining popularity, and more and more developers are turning towards it.
Of course, the REST API comes with numerous benefits, such as the ability to interact with third-party platforms and apps. Have an application coded in Ruby and want to interact with a WordPress site based on PHP? The REST API is here to help you!
This book will help you get started with the REST API for WordPress. You will learn the basics as well as the advanced details of this new API so that you can use it in your projects.
Chapter 1, Getting Started with REST API, gives you an overview of what the REST API is, how it functions, and all that it is capable of doing. You will also find information about other platforms if you are new to WordPress.
Chapter 2, Interacting with REST API in WordPress, is where you will learn the basics of the REST API in WordPress. General POST and GET commands shall be covered here.
Chapter 3, Working with Taxonomies and Users with REST API, moves to taxonomies such as categories and tags. Users and user roles will also be covered.
Chapter 4, Working with Forms Using REST API, will show you how the REST API can be used to work with custom forms for your WP platform. This chapter will teach you how to get the most out of it.
Chapter 5, Custom Routes in WordPress REST API, progresses beyond default roles and teaches you how to add and work with custom routes using the REST API.
Chapter 6, Creating a Simple Web App Using WordPress REST API, is where you learn how to create a web app. Plus, you will also learn how to pass commands to your web app.
Chapter 7, Mastering REST API for Your Projects, is where you will learn how to master the REST API for your projects. Obviously, this chapter requires that you have a working knowledge of the REST API, as well as experience with WordPress development.
Chapter 8, WordPress REST API in Practice, teaches you the practical aspects of the WP REST API and its development.
Chapter 9, Summing It Up, wraps up our journey with the WordPress REST API. We will have a recap of all that we have learned so far and an overview of what the REST API can do for us.
Obviously, you will need a working installation of WordPress to begin with. The latest version of WordPress is recommended so that you do not miss out on security updates.
You will also need to install and activate the WordPress REST API plugin on your site. Free download and installation instructions are here: https://wordpress.org/plugins/rest-api/.
At least PHP 5.4 or higher is recommended. The latest supported version of MySQL is required as well, and enhancements such as MariaDB are also allowed.
You can run WP on a generic LAMP or WAMP stack. For further instructions, consider reading the WordPress documentation.
This book is for WordPress developers and designers who want to get a complete practical understanding of the WordPress REST API and leverage it to create fully featured web apps.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
A block of code is set as follows:
require 'net/http' url = 'http://www.example.com/database/1191' resp = Net::HTTP.get_response(URI.parse(url)) resp_text = resp.body
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
url = 'http://www.example.com/database/1191'
resp = Net::HTTP.get_response(URI.parse(url))
resp_text = resp.body
Any command-line input or output is written as follows:
$url = "http://www.example.com/database/1191"; $response = file_get_contents($url); echo $response;
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Hit Preview link in the pane and you will see your remote WordPress site in the panel."
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
Log in or register to our website using your e-mail address and password.
Hover the mouse pointer on the SUPPORT tab at the top.
Click on Code Downloads & Errata.
Enter the name of the book in the Search box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on Code Download.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR / 7-Zip for Windows
Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learning-WordPress-REST-API. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at [email protected] with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.