CAll Us: +1 888-999-8231 Submit Ticket

What Is An API?

What Is An API?

Photo by pawel blazewicz on Unsplash

The biggest buzz in the WordPress world is the REST API and how it will usher in a new age of freedom, flexibility, and functionality for WordPress users and developers. But the term “REST API” doesn’t mean much to anyone who isn’t a web developer, including most WordPress users. To help WordPress users understand why the REST API is a big deal for the WordPress community, I’d like to take a look at exactly what we mean by API.

First things first, API stands for Application Programming Interface. Knowing that isn’t particularly helpful unless you already know what an API is, so we’ll move swiftly on.

We’re all familiar with applications. Take a look at your phone’s home screen. It’s full of applications. Each application is a self-contained chunk of functionality. A weather application tells you what the weather will be. Your email applications lets you read email.

How does your weather application “know” what the weather will be? In most cases, the application asks a weather service on the internet, which returns the information the app needs to display a forecast. The weather application needs to know exactly what to say to the weather service to get it to send the right information. The weather service will only answer a small set of correctly formatted requests for information.

There’s a sort of contract between the weather app and the weather service: the weather app will respond with information in a format the app can understand if the app makes requests in a format the service can understand. That contract and format is an API.

In short, an API specifies how one piece of software should talk to another, and what responses it can expect. Neither piece of software cares what’s happening inside the other (the implementation). They don’t have to understand each other’s code. As long as the API remains stable, they can communicate.

The WordPress REST API specifies how other software should talk to WordPress and what WordPress will do in response to those requests. An application might use the API to ask WordPress to send a list of blog posts, and WordPress would respond with the blog posts in a format the app can understand.

You can see how useful this is for developers. Before the API, if a developer wanted to build a theme that displays blog posts, they’d have to write code that interfaces with WordPress’ internal code. With the REST API, any application that knows the API can interact with a WordPress site. A theme or front-end app, written in JavaScript or any other language, can ask a WordPress site for content or tell it to perform certain actions, like publishing a post.

The “REST” part of REST API denotes how the API should be interacted with — in the case of REST, requests are sent over HTTP. Each request is a specially formatted web address that WordPress knows how to respond to. REST implies other things too. If you want to deeper understanding of REST APIs, which are used all over the web, take a look at this excellent video.

The WordPress REST API is a standard interface that lets developers write software to use of all the content and user management functionality WordPress provides. Developers can create new themes, plugins, front-ends, back-ends, and applications that use the API, creating exciting opportunities to make the WordPress ecosystems even richer than it is already.

Posted in:
Webmaster, WordPress

Source link

About the Author

Leave a Reply