REST APIs explained
An API is a set of rules that allow two software systems to communicate with each other, and a REST API is one of the most used to make systems communicate.
![REST APIs explained REST APIs explained](http://images.ctfassets.net/lizv2opdd3ay/584X3QUCcnyWR4ZWzyH1AF/b25d647f42ba52d17a7d29ecead433b5/public__8_.avif)
![Sean Kennedy](http://images.ctfassets.net/lizv2opdd3ay/66M5i1OLQzJiBkVa33awbL/cdd06203367ceea3cff209735f7d4271/toddle-osx-icon.png)
Sean Kennedy
February 19, 2023
What is a REST API?
Separation of Concerns
Emphasis on Resources
One of the benefits of using resources in this way is that it makes it easy to design intuitive and flexible APIs.
Statelessness
How Does the Magic Happen?
Once the server receives the request, it processes it and responds to the client. This response typically contains a status code indicating whether the request was successful or not, as well as any data or metadata associated with the requested resource. For example, if the client requested a book using a GET request, the server might respond with a JSON object containing information about that book and a status code of 200 (OK).
One of the key benefits of using REST is that it provides a standardized way for different systems to interact with each other. For example, a client developed using JavaScript could easily communicate with a Python server if they both adhere to the same set of protocols. This makes creating highly interoperable web services easy and essential for modern applications that rely on data from multiple sources.
Let's look at an example to see how this works in practice. Imagine you're developing a mobile app that allows users to search for and book flights. To do this, your app needs to communicate with a web service that provides flight information.
Example
![A frontend that shows cartoons and a database of cartoons.](http://images.ctfassets.net/lizv2opdd3ay/3i6bnUeaKtCc41lLaacNzw/7b9a6768f942dafc37b9298dc65a5d4a/public__9_.avif)
![To retrieve information about a specific cartoon, the client would send a GET request to the endpoint](http://images.ctfassets.net/lizv2opdd3ay/2uWsCJP18qKxCHhbttOqZ1/5d74d95f268d0e3a4ec735f74c5154dc/public__10_.avif)
![If you want to add a new cartoon to the database, the client would send a POST request to the endpoint](http://images.ctfassets.net/lizv2opdd3ay/7CwSq7fvGzLqX6npMB4LAr/30cac7f54f8ba3d8eb8f01a45ec0039b/public__11_.avif)
![To update information about a cartoon, the client would send a PUT request to the endpoint](http://images.ctfassets.net/lizv2opdd3ay/1EkGPvN5QucN8z8rf8D0SG/7aca884768287394729bd8a56a7b2df4/public__12_.avif)
![To delete a cartoon from the database, the client would send a DELETE request to the endpoint](http://images.ctfassets.net/lizv2opdd3ay/4D8AXdfy8TzHryyeCppyfr/66f07dcd2a709ee862907c7963963d6c/public__13_.avif)
Communication between apps.
In addition to its flexibility and scalability, REST also provides several other benefits for web developers. For example, it allows for caching of resources, which can improve performance and reduce the load on the server. It also provides a uniform interface for accessing resources, which makes it easier to develop and maintain web services over time.
Overall, REST is an incredibly powerful and flexible architectural style that has revolutionized how web services are developed and deployed. Whether you're building a mobile app, a web application, or a large-scale enterprise system, REST provides a standardized and reliable way to interact with the data and resources you need to get the job done. So, the next time you're working on a project involving web services, remember the REST principles and see how they can help you build a better, more scalable, and more interoperable system!