Currently, the Internet is filled with a large number of articles about how to design RESTful API (for convenience, "RESTful API" is abbreviated as "API" below). However, there is no "universal" design standard: how to authenticate? What is the API format? When you start to write an app, especially when the back-end model part has been written, you have to go to great lengths to design and implement the public API part of your app. Because once released, the API released to the outside world will be difficult to change.
Question 1:
Send email /mail/1/send using POST /mail/send using POST
How to name the URL
Question 2
Get a specific user list /getVipUser /user/vip /getUserList?type=vip
How to name the URL
Question 3
I am very confused about whether to use camel or snake shape. I have used both. Some people say it doesn’t matter, but I am still confused.
Restful is just a set of reference specifications. My understanding is that there is no one-size-fits-all standard in the field of software development, only different best practices. As for the API, it only needs to be easy for developers to distinguish. You don’t have to force yourself to do it for the sake of specifications. Standard, as long as the function is implemented, who cares what your API looks like.
You can check out Ruanyifeng’s blog post:
http://www.ruanyifeng.com/blo...
Regarding whether to use camel case or snake case, it should be all lowercase
vip
can be used as a resourceGET vips/user/{id}
ORGET users/vip/{id}
Get a single resourceGET vips/user
ORGET users/vip
Get multiple ResourcesYou may want to refer to these resources: restful-api-design-references - RESTful API design reference list, which can help you understand REST-style interface design more thoroughly.
In the actual application of RESTful api, the design of Github API v3 can be said to be a model, you can also take a look.