All Courses > Up and Running > Chapters > How to Register Custom WordPress REST API Routes

How to Register Custom WordPress REST API Routes

Key Takeaways:

Registering custom WordPress REST API routes lets you expose any WordPress data you like to the world.
Registering routes centers around a method called register_rest_route(), which defines a route (a URL), a method (an HTTP verb to be used at the route), and a callback function (which dictates what happens at the route given its method).
The cleanest way to register new REST API routes is object-oriented, and involves defining a class that extends a WordPress class called WP_REST_Controller.

This chapter explores registering custom WordPress REST API routes. Custom routes are URLs that you define, and at which you can expose any data from your WordPress site you like in JSON format. If you've ever wanted to browse your site's custom taxonomy term meta from within an iPhone app—or even if, hopefully, you haven't—then this chapter's for you.

This chapter also doubles as a survey...