First of all, let's explained what REST stands for:
REpresentation
State
Transfer
Which is a fancy way of saying that a server responds to Create, Read, Update, Delete in a standard way.
It uses the following actions GET, POST, PUT and DELETE to decide which URL to use:
http://example.com/users
http://example.com/users/1
[GET] http://example.com/users
It acts on the entire resource, and get a list of resources
[POST] http://example.com/users
It acts on the entire resource, is used to create a new resource
[GET] http://example.com/users/1
Acts on a single resource, gets the resource with the single ID
[PUT] http://example.com/users/1
Acts on a single resource, updates the resource with the given ID
[DELETE] http://example.com/users/1
Finally the most straighfoward. It acts on a single resource, deletes the resource with the given ID.
While the URLs mentioned are the most common, there can be sligth different details like using users/details/1 or users/update/1 instead.
I hope you find this explanation helpful!
Top comments (0)