简体   繁体   中英

Can we say “If an API is following 6 constraints of REST then it’s a RESTful API”?

Can we say “If an API is following 6 constraints of REST then it's a RESTful API”? or my statement is completely wrong?

Well, you are half right. Yes, there are 6 constraints that Mr. Roy Fielding described in his phD publication. But, the last one "Code On Demand" is optional

Ref: https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm

Can we say “If an API is following 6 constraints of REST then it's a RESTful API”? or my statement is completely wrong?

You probably need to be detailed about the nature of the "uniform interface" constraint:

REST is defined by four interface constraints: identification of resources; manipulation of resources through representations; self-descriptive messages; and, hypermedia as the engine of application state.

See also REST APIs Must be Hypertext Driven (Fielding 2008).

REST defines 6 architectural constraints which make any web service – a true RESTful API.

  1. Uniform interface
  2. Client-server
  3. Stateless
  4. Cacheable
  5. Layered system
  6. Code on demand ( optional )

All the above constraints help you build a truly RESTful API, and you should follow them. Still, at times, If you find yourself violating one or two constraints. Do not worry; you are still making a RESTful API – but not “truly RESTful.”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM