Reputation: 500
I am designing a restful API by using Laravel & AngularJS. I know the basic of restful API, but having trouble to figure out what will be the best way to design it for user resource.
Let's guess, user can have his profile & can update profile. So, the URL should be something like this:
www.example.com/users/{id}
www.example.com/users/{id}/edit
but these URLs look bad. The pretty URLs are:
www.example.com/profile
www.example.com/profile/edit
OR
www.example.com/{username}
www.example.com/{username}/edit
My question is, if I use the last two pretty URLs, will it break the restful API principle? And which is the most appropriate way of designing API for user resource?
Upvotes: 0
Views: 349
Reputation: 319
I think you should get the advantage of using HTTP
verbs in RESTFUL
api's which would make your url's more readable such:
`GET www.example.com/users/{id}` for profile retrieval
`PUT www.example.com/users/{id}` for profile update
You can review this blog for more information HTTP Verbs
Upvotes: 2