한국어

Coding

온누리070 플레이스토어 다운로드
    acrobits softphone
     온누리 070 카카오 프러스 친구추가온누리 070 카카오 프러스 친구추가친추
     카카오톡 채팅 상담 카카오톡 채팅 상담카톡
    
     라인상담
     라인으로 공유

     페북공유

   ◎위챗 : speedseoul


  
     PAYPAL
     
     PRICE
     

pixel.gif

    before pay call 0088 from app


https://blog.restcase.com/7-rules-for-rest-api-uri-design/


Before going over the rules for REST API URI design, let’s do a quick overview on some of the terms we are going to talk about.

URIs

REST APIs use Uniform Resource Identifiers (URIs) to address resources. On today’s web, URI designs range from masterpieces that clearly communicate the API’s resource model like: 
http://api.example.com/louvre/leonardo-da-vinci/mona-lisa 
to those that are much harder for people to understand, such as: 
http://api.example.com/68dd0-a9d3-11e0-9f1c-0800200c9a66

Tim Berners-Lee included a note about the opacity of URIs in his “Axioms of Web Architecture” list:

The only thing you can use an identifier for is to refer to an object. When you are not dereferencing, you should not look at the contents of the URI string to gain other information.
Tim Berners-Lee

Clients must follow the linking paradigm of the Web and treat URIs as opaque identifiers.

REST API designers should create URIs that convey a REST API’s resource model to its potential client developers. In this post, I will try to introduce a set of design rules for REST API URIs.

Prior diving to the rules, a word about the URI Format as the rules presented in this section pertain to the format of a URI. 
RFC 3986 defines the generic URI syntax as shown below:

URI = scheme "://" authority "/" path [ "?" query ] [ "#" fragment ]

Rule #1: A trailing forward slash (/) should not be included in URIs

This is one the most important rules to follow as the last character within a URI’s path, a forward slash (/) adds no semantic value and may cause confusion. REST API’s should not expect a trailing slash and should not include them in the links that they provide to clients.

Many web components and frameworks will treat the following two URIs equally: 
http://api.canvas.com/shapes/ 
http://api.canvas.com/shapes

However, every character within a URI counts toward a resource’s unique identity.

Two different URIs map to two different resources. If the URIs differ, then so do the resources, and vice versa. Therefore, a REST API must generate and communicate clean URIs and should be intolerant of any client’s attempts to identify a resource imprecisely.

More forgiving APIs may redirect clients to URIs without a trailing forward slash (they may also return the 301 – “Moved Permanently” that is used to relocate resources”).

Rule #2: Forward slash separator (/) must be used to indicate a hierarchical relationship

The forward slash (/) character is used in the path portion of the URI to indicate a hierarchical relationship between resources.

For example: 
http://api.canvas.com/shapes/polygons/quadrilaterals/squares

Rule #3: Hyphens (-) should be used to improve the readability of URIs

To make your URIs easy for people to scan and interpret, use the hyphen (-) character to improve the readability of names in long path segments. Anywhere you would use a space or hyphen in English, you should use a hyphen in a URI.

For example: 
http://api.example.com/blogs/guy-levin/posts/this-is-my-first-post

Rule #4: Underscores (_) should not be used in URIs

Text viewer applications (browsers, editors, etc.) often underline URIs to provide a visual cue that they are clickable. Depending on the application’s font, the underscore (_) character can either get partially obscured or completely hidden by this underlining.

To avoid this confusion, use hyphens (-) instead of underscores

Rule #5: Lowercase letters should be preferred in URI paths

When convenient, lowercase letters are preferred in URI paths since capital letters can sometimes cause problems. RFC 3986 defines URIs as case-sensitive except for the scheme and host components.

For example: 
http://api.example.com/my-folder/my-doc

HTTP://API.EXAMPLE.COM/my-folder/my-doc 
This URI is fine. The URI format specification (RFC 3986) considers this URI to be identical to URI #1.

http://api.example.com/My-Folder/my-doc 
This URI is not the same as URIs 1 and 2, which may cause unnecessary confusion.

Rule #6: File extensions should not be included in URIs

On the Web, the period (.) character is commonly used to separate the file name and extension portions of a URI. 
A REST API should not include artificial file extensions in URIs to indicate the format of a message’s entity body. Instead, they should rely on the media type, as communicated through the Content-Type header, to determine how to process the body’s content.

http://api.college.com/students/3248234/courses/2005/fall.json 
http://api.college.com/students/3248234/courses/2005/fall

File extensions should not be used to indicate format preference.

REST API clients should be encouraged to utilize HTTP’s provided format selection mechanism, the Accept request header.

To enable simple links and easy debugging, a REST API may support media type selection via a query parameter.

Rule #7: Should the endpoint name be singular or plural?

The keep-it-simple rule applies here. Although your inner-grammatician will tell you it's wrong to describe a single instance of a resource using a plural, the pragmatic answer is to keep the URI format consistent and always use a plural.

Not having to deal with odd pluralization (person/people, goose/geese) makes the life of the API consumer better and is easier for the API provider to implement (as most modern frameworks will natively handle /students and /students/3248234 under a common controller).

But how do you deal with relations? If a relation can only exist within another resource, RESTful principles provide useful guidance. Let's look at this with an example. A student has a number of courses. These courses are logically mapped to the /students endpoint as follows:

http://api.college.com/students/3248234/courses - Retrieves a list of all courses that are learned by a student with id 3248234. 
http://api.college.com/students/3248234/courses/physics - Retrieves course physics for a student with id 3248234.

Conclusion

When you are designing REST API services, you have to pay attention to resources, those are defined by URIs.

Each resource in a service or services you are building will have at least one URI identifying it. It's best when that URI makes sense and adequately describes the resource. URIs should follow a predictable, hierarchical structure to enhance understandability and, therefore, usability: predictable in the sense that they're consistent, hierarchical in the sense that data has structure—relationships.

RESTful APIs are written for consumers. The name and structure of URIs should convey meaning to those consumers. By following the above rules, you will create a much cleaner REST APIs with a much happier client. This is not a REST rule or constraint, but it enhances the API.

I also suggest that you will take a look at http://blog.restcase.com/5-basic-rest-api-design-guidelines/

Design for your clients, not for your data.

번호
제목
글쓴이
63 [SSL]HTTPS통신을 위한 SSL인증서 발급하기(OpenSSL) 원리까지 충실하게 설명잘됨
admin
2020-02-13 10081
62 인증 기관에서 발급한 SSL 인증서 설치 및 사용설명
admin
2020-02-13 5320
61 iOS NSURLSession Example (HTTP GET, POST, Background Downlads )
admin
2019-06-04 7463
60 iOS Tutorial - Part 26 - HttpRequest POST, GET (NSURLConnection)1
admin
2019-05-20 6177
59 Simple http post example in Objective-C?
admin
2019-05-20 5695
58 리눅스 CentOS 6.5 SSL 구축 방법
admin
2018-06-01 7715
57 무료 SSL 인증서 SSL For Free
admin
2018-05-26 7763
56 도메인클럽 m 또는 www등의 서브도메인(a레코드) 추가는 어디서 할 수 있나요?
admin
2018-05-25 6998
55 Certificate Installation : Node.js in Linux
admin
2018-05-25 6295
54 online-csr-and-key-generator CSR 온라인 제너레이터 생성 만들기 Private key
admin
2018-05-25 6427
53 COMODO SSL www.gogetssl.com namecheap.com SSL 인증서 구매 서버에 적용 순서
admin
2018-05-25 9424
52 인증서 취소 How to cancel an SSL certificate? www.namecheap.com
admin
2018-05-25 8198
51 Android SSL 프로그램 공인인증서 사설 인증서 ROOTCA Self-signed 인증서 에러 원인
admin
2018-05-25 7023
50 Retrofit is one of the most popular HTTP Client Library for Android 간결하고 요점정리
admin
2018-05-23 7130
49 SSL 프로그래밍 참고
admin
2018-05-23 6375
48 HTTPS 및 SSL을 사용한 보안 구글 문서
admin
2018-05-23 9969
47 Consuming APIs with Retrofit
admin
2018-05-22 8419
46 COMODO SSL Analyzer ip 도메인 모두 가능합니다
admin
2018-05-22 6502
45 OpenSSL 로 ROOT CA 생성 및 SSL 인증서 발급 순서 Self Signed Certificate
admin
2018-05-22 7320
44 Android에 루트 CA 설치
admin
2018-05-22 8409
43 How to update OpenSSL on Debian testing
admin
2018-05-22 6959
42 신뢰되지 않는 인증서를 사용하여 SSL 구성
admin
2018-05-22 11434
41 OpenSSL tips and common commands
admin
2018-05-22 7154
40 How to get FREE SSL Certificate for Website (HTTPS) 인증서 무료로 받기
admin
2018-05-22 6261
39 retropit
admin
2018-05-20 6424
38 SSL test code
admin
2018-05-20 6911
37 HttpsURLConnection в ASyncTask https
admin
2018-05-19 6512
36 protected String doInBackground(String... strings) {
admin
2018-05-19 6392
35 Using Google Spread sheet as DataBase Part -2
admin
2018-05-19 6893
34 Android: HTTPS (SSL) connection using HttpsURLConnection
admin
2018-05-19 7109
33 HttpsUrlConnection, you can refer to my following sample code good
admin
2018-05-19 6435
32 how to use HttpsUrlConnection instead of DefaultHttpClient
admin
2018-05-19 6367
31 Https simple get request
admin
2018-05-19 6468
30 Base64 encoded value of [API-key]:[API-Secret] appending the "Basic " string in start.
admin
2018-05-19 7760
29 Class: https.Server
admin
2018-05-19 6932
28 HTTP2 server push in depth with node.js
admin
2018-05-19 7246
27 HSTS forces the client (browser accessing your server) to direct all traffic through HTTPS
admin
2018-05-19 6541
26 https ssl node js real code
admin
2018-05-19 6712
25 https 및 openssl 키값 decoding 확인 ssl tls
admin
2018-05-19 6621
24 TLS/SSL Concepts nodejs how to
admin
2018-05-19 7120
23 HTTPS Authorized Certs with Node.js
admin
2018-05-19 7303
22 How to Use SSL/TLS with Node.js Related Topics
admin
2018-05-19 7244
21 openssl website
admin
2018-05-19 6278
20 node js HTTPS server and client
admin
2018-05-19 7260
19 RESTful API with NodeJS/Express mysql
admin
2018-05-19 6785
18 Build a Rest API for Node & Mysql 2018 JWT
admin
2018-05-19 7072
17 Using SSL with Express 4 and Node.js
admin
2018-05-19 6970
16 https node js rest api express
admin
2018-05-19 6298
15 9 FREE Useful Online SSL/TLS Certificate Tools
admin
2018-05-19 7976
14 Do you know where your app’s secrets are?
admin
2018-05-19 7090
13 node js rest with express
admin
2018-05-19 7152
12 simple HTTPS JSON REST server using node.js
admin
2018-05-19 6335
11 5 Ways to Make HTTP Requests in Node.js
admin
2018-05-19 23244
10 express() detail easy doc
admin
2018-05-19 19245
9 express https simple example
admin
2018-05-19 6189
8 Online CSR and Key Generator
admin
2018-05-19 6312
7 SSL Converter checker
admin
2018-05-19 7087
6 here is a complete working example. rest api https
admin
2018-05-19 6233
5 node-rest-client
admin
2018-05-19 6993
Rules for REST API URI Design
admin
2018-05-19 7377
3 RESTful API Authentication Basics
admin
2018-05-19 7701
2 Benefits For REST APIs with HTTP/2 HTTP/1.x vs HTTP/2
admin
2018-05-19 60992
1 HTTPS, Redis, FCM, EC2 Setup 키생성 인증서 요청서 openssl 이용 상세한설명
admin
2018-05-19 5864