From the course: Learning REST APIs

What is a REST API?

From the course: Learning REST APIs

Start my 1-month free trial

What is a REST API?

- 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. To make sense of this, consider a typical website. Each page comprises a single HTML document containing the content, any reference items like images, one or more style sheets describing how the document is presented in the browser, and some JavaScript manipulating the document or styles or both. When the visitor navigates from one page to another, they send a URL, Universal Resource Locator, request to the server pointing at a web resource in the form of a specific HTML document. 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. An application downloaded to the browser that runs in the browser and is populated with data from the web. In this application, each page is a view representing the current state. When the visitor loads the site for the first time, all the components that make up the application are downloaded including an HTML framework, referenced items, one or more style sheets, and some JavaScript. The application then sends a URI or Universal Resource Identifier request for a web resource representing the next state of the application to be transferred, and uses the resulting data to build the current view. 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.

Contents