What is Rest API, why is it used, and how can I go about creating one and learning more about it? All functions should be of either GET/POST/DELETE/PUT form?
Simply, a REST API defines a set of functions which developers can perform requests and receive responses via HTTP protocol such as GET and POST. The REST API should specify what it can provide and how to use it, details such as query parameters, response format, request limitations, public use/API keys, method (GET/POST/PUT/DELETE), language support, callback usage, HTTPS support and resource representations should be self-descriptive…
REST is a highly scalable and cachable architecture that is ideal for designing APIs. Basic ideas behind REST -
URL and headers should uniquely identify the resource, such that it can be cached.
REST APIs should be stateless i.e. result of an API call shouldn't vary depending on the API calls preceding it. Keeping state across APIs restricts caching and is thus not considered RESTful.
Use appropriate HTTP verbs i.e. GET for read and idempotent requests, POST for write requests, PUT for write and idempotent requests, DELETE for deletion of resources.
Return appropriate status codes that are compliant with REST standards for the ease of use and universal cachability over different proxy layers.
HATEOAS i.e. Hypermedia as the engine of application state which states that most of the URLS shouldn't be hardcoded, instead server-side should guide the client by providing the URLs in its response. The idea is quite akin to how we use websites on our browsers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With