What is Rest API?
API is stand for Application Programming Interface is a set of subroutine definitions, protocols and tools for building application software.
REST (Representational State Transfer) is an architectural style that defines a collection of constraints and properties based on HTTP.
In a RESTFULL API, the following HTTP methods are commonly used.
GET: To retrieve resource representation/information only.
Example request URL.
1.HTTP GET http://www.appdomain.com/users
2.HTTP GET http://www.appdomain.com/user?size=2&page=3
POST: If the resource has already been created on the server, the response code for building a new subordinate resource should be 201 ok (created).
PUT: To re - implement resource; if the resource does not exist, it will be generated and code 201 will be returned; if it does, it will be updated and code 200 will be brought back.
DELETE: To delete a resource, a successful delete request should return the HTTP response code 200 ok. If the response contains an entity criticizing the status 202, (Accepted). If the action was previously queued or 204 (no content). If the action has been completed but the response lacks an entity.
PATCH: A partial update to a resource. If you see a PUT request that also modifies a resource entity, it is clear that the PATCH method is the correct choice for partially updating an existing resource and the PUT method should only be used if you are completely replacing a resource.
If you want to learn more about status codes, go to https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.
Comments
Post a Comment