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: Is
stands for Represtational State Transfer, It’s an architectural style that
define a set of constrains and properties based on HTTP.
The fallowing
HTTP method are typically used in a RESTFULL API.
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: To
create new subordinate resource, If a resource has been created on the server
then the response should return code 201 ok (created).
PUT: To update
existing resource, if resource does not exist then it will create new and
return code 201 otherwise it will modify existing data return 200 ok.
DELETE: To
delete resource, a successful resource of delete request should be HTTP
response code 200 ok. If the response includes an entity descrying the status
202 (Accepted). If the action has been queued or 204(no content). If the action
has been performed but the response does not include an entity.
PATCH: To
make partial update on a resource. If you see PUT request also modify a
resource entity so to make clear PATCH method is correct choice for partially
updating an existing resource and PUT should only be used if you are replacing
a resource in its entirely.
If you want to
know about status code follow this link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
.
Comments
Post a Comment