- REST and API are acronyms for Representational State Transfer and Application Programming Interface. REST APIs are integral to web application development and are becoming mainstays of all web development. Understanding what they are and how they work starts with understanding what these names, representational state transfer and application programming interface, actually mean. According to MDN, Representational State Transfer or REST refers to a group of software architecture design constraints that bring about efficient, reliable, and scalable systems.
So REST isn't a specific technology, but rather a data architecture and design methodology that produces predictable and consistent outputs and behaviors by receiving a set of standard methods called verbs and returning standardized structured data, typically JSON or XML, called the resource. Representational State Transfer is a literal description of what's happening. We transition between representations of states and these representations are transformed back and forth between the application and the server.
The server responds by returning the document along with its adjoining files to the browser which replaces the previous content with all new content. This works fine, but it's resource intensive. Each new page requires a completed HTML document and the document has to be written by a developer or generated by a content management system before it's downloaded and rendered in the browser. Now imagine instead of a website comprising individual documents generated and downloaded from the server, we have a web application.
When the visitor navigates from one view to another, the application sends a new URI request for the web resource representing the next state of the application which is transferred and used to add, modify, replace, or delete the previous data. The key is this representational state is transferred as a data object, not the entire new set of files. And the application can update its data without rendering the whole new page. This allows us to create so-called single page applications on the web and native apps for mobile devices and platforms that all use or consume the same REST resource.
To give a practical example, when you visit LinkedIn on your computer and your smartphone, you use two different applications to access the same data from the same REST resource. All this back and forth is controlled through an application programming interface or API. An API is a set of features and rules that exist inside a software program enabling interaction between the software and other items, such as other software or hardware. In the context of REST APIs, the API is the collection of tools used to access and work with REST resources through your adverbs including get, pulls, put, and delete.
You can think of the REST resource as a librarian and the API as the language used to talk to them. Hey Morton, please get me the 10 most recent articles on digital ethics. Hey Morton, please put this document to the library under the Norwegian Folklore category, and please delete this document from the library as it's no longer relevant.
- What is a REST API?
- Who or what interacts with REST APIs?
- Anatomy of a REST request
- HTTP status messages
- Request/response pairs
- GET, POST, and DELETE