A REST API is an architectural style for an application programming interface that uses Hypertext Transfer Protocol (HTTP) requests to access and use data. That data can be used to GET, PUT, POST and DELETE data types, which refers to reading, updating, creating and deleting operations related to resources.
An API is code that enables two software programs to communicate with one another. The API's design spells out the proper way for a developer to write a program, or client, that uses the API to request services from another application, or the server.
Principles of the REST API. What makes a service RESTful?
-
The interface must be uniform. This is the most important. All REST APIs must be consistent, providing resource identification in their URIs. They must use standard HTTP methods -- the CRUD operations (GET/POST/PUT, PATCH/DELETE) -- and represent resources in multiple formats, such as XML and JSON. -
Client-server separation. The front end of communication -- the client -- and the back end -- the server -- must be independent of one another; the server must provide the resources, while the client hosts the UI. -
Multiple layers. Though not required, the architecture allows for multiple layers, including proxies, load balancers and authentication; the client doesn't care if it's actually communicating with the web server. -
It must be stateless. Each API call is independent, meaning the server does not track the client's state between requests. -
Caching. Responses use HTTP headers to determine whether they are cacheable; this reduces latency and improves performance. -
Code return. Though not required, the architecture enables the server to return executable code to the client, such as JavaScript, if it is useful.
For a service to be considered a true RESTful web API, it must be designed and implemented all the principles.
Credit: https://www.techtarget.com/searchapparchitecture/definition/RESTful-API
Top comments (0)