'should I consider the case sensitive when design the rest api url
Now I am design a rest api, what makes me confusing is that the url case sensitive, for example, the /currentUser
, I read some api design like google:
https://developers.google.com/oauthplayground/exchangeAuthCode
the named with camel case, and youtube:
https://www.youtube.com/youtubei/v1/log_event?alt=json&key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8
the named snake case, and stackoverflow:
https://stackoverflow.com/questions/71447875/is-casesensitive-important-for-appid
the named with a -
. which is better? which one should I choose? or both are good, there is no need to consider the url case sensitive?
Solution 1:[1]
With respect to RFC 3986, URLs: /resourcename
and /resourceName
are different. BUT: The general convention nowadays is to treat all URLs uniformly, regardless of character size.
Most REST APIs use hyphenated notation: /resource-name
Google is somewhat schizophrenic because it recommends something different here.
I recommend being case insensitive, using hyphens, and being consistent throughout the API.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Miroslav Holec |