top of page

What the hell is a "RESTful" API?

What does "RESTful" API stand for?


REST stands for REpresentational State Transfer and API stands for Application Programming Interface.


What is an API?


In short, an API is a way for two pieces of software to talk to one another. You can think of it like a drive-through window at a fast food restaurant. You can't walk into the kitchen and make yourself a burger, but you can talk to an attendant at the window to get what you want. In the same way, one software program can send or receive information from another software program through an API.


What is "RESTful"?


"RESTful" API is an interesting way of describing an API that conforms to the REST architectural style. However, REST is not a rigid specification outlined by some formal organization. They are just a loose set of rules that have been the commonly accepted standard since the 2000s. Roy Fielding, an American computer scientist, was the first to describe the REST style.


How do I build a REST API?


As mentioned above, the REST style is not a rigid specification. Therefore, there is no consensus on what would make an API "RESTful". However, there are four key requirements that most resources agree are necessary for any REST API.

  1. Maintain client-server architecture (the server hosts the API and receives calls from one or more clients)

  2. Make all requests stateless (the client and server need to store no information about each other or any requests; all API calls happen in isolation)

  3. Cache data wherever possible (the client can and should store responses from the server)

  4. Maintain support for intermediaries between client and server (the client shouldn't be able to tell if there is middleware between itself and the server, and vice-versa)

In addition to the above four key requirements, there are also many other qualities that REST APIs usually have. See below for a non-exhaustive list.

  1. Accept and respond in JSON

  2. Use nouns (not verbs) in URI paths

  3. Use sensible nesting in URI paths

  4. Handle all errors and return standard error codes

  5. Support filtering, sorting, and pagination of data

  6. Use SSL and TLS for security

  7. Version APIs in URI path

Conclusion


Now, next time someone asks if your API is "RESTful", you can explain that REST is a loose architectural style, and ask that they list their specific requirements. Then, sit back, and grab some popcorn! 🍿


JSON Meme


























Comments


bottom of page