공부/CS 기초이론
[Web] REST API 규칙
aerhergag0
2023. 4. 14. 21:56
REST API 규칙
URL Rules
1. 마지막에 "/"를 붙이지 않는다.
http://www.example.com/api/products/ (X)
http://www.example.com/api/product (O)
2. 소문자를 사용한다.
http://www.example.com/api/Users/UserLogin (X)
http://www.example.com/api/users/userlogin (O)
3. '_' 대신 '-'를 사용한다.
http://www.example.com/api/users/user_profiles (X)
http://www.example.com/api/users/user-profiles (O)
4. 컨트롤 자원을 의미하는 동사는 사용할 수 있다.
http://www.example.com/api/products/search (O)
5. 파일 확장자가 포함되는 경우가 없어야 한다.
http://www.example.com/api/users/user-profiles/images/1.jpg (X)
http://www.example.com/api/users/user-profiles/images/1 (O)
6. 메소드는 URL에 포함하지 않는다.