What is REST API? [REST API Explained Briefly]

If you’ve got used any modern website then the likelihood is that you’ve got interacted with an internet site that uses REST. Even YouTube uses restful URLs on its site but what exactly is rest for starters rest stands for representation state transfer.

What is REST API?

It does so with the following five URLs, the first two URLs did not have an ID so they act on the entire user’s resource, while the last three URLs do have an ID in their URL. Thus act only on a single useful resource but as you may notice there are only two distinct URLs.

How does REST Works?

This is because the REST uses the four basic HTTP actions get post put and delete to work out what to try to do with each URL. If we add those actions to the URLs it’s much easier to ascertain what each of the URLs does the primary URL. We’ve is that the get users URL and it’s wont to get an inventory of all users in REST when a get URL doesn’t have an ID in acts upon the whole resource and can always return an inventory of each item.
Therein resource the get action in rest corresponds with reading data, the second URL which is nearly just like the primary is employed to make a replacement. User in rest the post-action corresponds with the creation and will always be used on the whole resource by not using an ID within the URL.
The third URL is another get URL but this URL is for getting only one user-supported ID that’s within the URL the ID portion of the URL is employed by the REST to work out which resource from the gathering of resources it should influence within the case of this URL

How it is used?

It is used to return the user with that ID the fourth URL is the most confusing of them all but it is used to update a user with an ID. The put action in rest corresponds with an update and it works very similarly to post, but instead of creating a new resource, it updates an existing resource. Lastly, we have the most straightforward URL of them all which is for deleting the user with a specific ID. The delete action and rest do exactly what you would think and it deletes the resource with the given ID.

How does a website use REST?

In order for a website to use the REST API, the URLs don’t get to be formatted precisely the same as above. For instance, using these URLs would still be considered restful, but in most applications, we use the previously mentioned URLs. The only thing that matters with REST is that the URL is used to represents a resource. In this case, a user and that they support creating reading updating and deleting from our resource using the HTTP actions, Get post update and delete and that’s all there is to how restful URLs work.
Tags:,

Post A Comment

Your email address will not be published.