RESTful is a standard used to design APIs for web services, making resource management more convenient.
What is RESTful API?
RESTful API, also known as REST API - one of the standards used to develop APIs for web services.
This is application programming interface designed to conform to the constraints of the REST architecture, allowing them to interact with RESTful web services.
When a client request is made through the RESTful API, it converts the structural state of the resource into JSON, HTML, XLT, Python, PHP... formats to the receiver or endpoint.
Among them, JSON is the most popular format because both humans and computers can read it.
Thanks to RESTful API, resource management becomes much simpler.
Currently, RESTful API is increasingly being widely applied in the field of web programming in general.
Criteria of RESTful API
An API is considered RESTful API when it complies with the following criteria:
- Code-on-demand.
- A client-server architecture created by clients, servers and resources.
- Have the request managed via HTTP.
- Stateless client-server communication.
- Data is stored in a cache memory, making communication between the client and the server more efficient.
- There is a unified interface between the components so that information is transmitted in a standard form, i.e. resources are only identified through a unique URL and their handling must be done with basic methods of network protocols such as POST, PUT, GET, DELETE.
Pros and cons of RESTful API
Pros
- The code looks simple and clean.
- No rules about logic code.
- Any programming language or framework can be used to create a RESTful API.
- Allows building many complex applications.
- Manage high loads with HTTP proxy server and cache.
- Allows use of resources along with standard HTTP procedure calls to retrieve data and requests.
- Allows use of OAuth protocols in authenticating REST requests.
Cons
Stateless
Almost all web services require a stateful mechanism.
For example, when a user uses a website with a shopping cart, this means they always need to know how much is in the cart before making a payment.
And maintaining this state is the task of the client side, so the application will be cumbersome and harder to maintain.
Security issue
RESTful API will be suitable for public URLs, but is not the best choice if you need to transfer sensitive data between client and server.