Basics Of Rest API
- Get link
- X
- Other Apps
In this blog I want to discuss about Restful APIs and its importance. A Restful API is a backbone of any full stack application. hence it becomes very important to understand the fundamentals of a Restful API
What is RESTful API?
RESTful API is an interface that two computer systems use to
exchange information securely over the internet. Most business applications
have to communicate with other internal and third-party applications to perform
various tasks. For example, to generate monthly payslips, your internal
accounts system has to share data with your customer's banking system to
automate invoicing and communicate with an internal timesheet application.
RESTful APIs support this information exchange because they follow secure, reliable,
and efficient software communication standards.
What is an API?
An application programming interface (API) defines the rules that you must follow to communicate with other software systems. Developers expose or create APIs so that other applications can communicate with their applications programmatically. For example, the timesheet application exposes an API that asks for an employee's full name and a range of dates. When it receives this information, it internally processes the employee's timesheet and returns the number of hours worked in that date range.
You can think of a web API as a gateway between clients and resources on the web.
Clients
Clients are users who want to access information from the web. The client can be a person or a software system that uses the API. For example, developers can write programs that access weather data from a weather system. Or you can access the same data from your browser when you visit the weather website directly.
Resources
Resources are the information that different applications
provide to their clients. Resources can be images, videos, text, numbers, or
any type of data. The machine that gives the resource to the client is also
called the server. Organizations use APIs to share resources and provide web
services while maintaining security, control, and authentication. In addition,
APIs help them to determine which clients get access to specific internal
resources.
What is REST?
Representational State Transfer (REST) is a software architecture that imposes conditions on how an API should work. REST was initially created as a guideline to manage communication on a complex network like the internet. You can use REST-based architecture to support high-performing and reliable communication at scale. You can easily implement and modify it, bringing visibility and cross-platform portability to any API system.
API developers can design APIs using several different architectures. APIs that follow the REST architectural style are called REST APIs. Web services that implement REST architecture are called RESTful web services. The term RESTful API generally refers to RESTful web APIs. However, you can use the terms REST API and RESTful API interchangeably.
What are the benefits of RESTful APIs?
RESTful APIs include the following benefits:
Scalability
Systems that implement REST APIs can scale efficiently because REST optimizes client-server interactions. Statelessness removes server load because the server does not have to retain past client request information. Well-managed caching partially or completely eliminates some client-server interactions. All these features support scalability without causing communication bottlenecks that reduce performance.
Flexibility
RESTful web services support total client-server separation. They simplify and decouple various server components so that each part can evolve independently. Platform or technology changes at the server application do not affect the client application. The ability to layer application functions increases flexibility even further. For example, developers can make changes to the database layer without rewriting the application logic.
Independence
REST APIs are independent of the technology used. You can
write both client and server applications in various programming languages
without affecting the API design. You can also change the underlying technology
on either side without affecting the communication.
HTTP Methods
Methods are used to modify or interact with these resources
- GET – Get method is used to read information about the resource. A path parameter is also required incase a single resource is fetched. Usually a request payload is unwanted. Some of the commonly used status code in GET methods are 200(success), 404(not fount).
- POST – Post method is used to create a resource or to trigger some operation on some resource. It requires a request payload. Some of the commonly used status code in POST methods are 200(success), 201(resource created), 400(bad request) and 409(conflict).
- PUT – Put method is used to update a resource or to create a resource if it don’t not exists also known as upset. This method is usually used in case we want to update almost all the fields of a resource. A request payload is required in put method. Commonly used status codes are 404(not found) and 400(wrong payload).
- PATCH – Patch method is used to update a resource. This method is more efficient than put method in case we want to change very few fields in a resource rather than updating an entire resource. A request payload is required with this method. Commonly used status codes are 404(not found) and 400(wrong payload).
- DELETE – Delete method is used to delete a resource. A request payload is not required all that it requires is the id of the resource to be deleted as a path parameter. Commonly used status codes are 200(success) and 404(not found).
- Get link
- X
- Other Apps



Comments
Post a Comment