Web APIs typically use REST style for communication while moving away from more traditional SOAP web services. Our ProgrammableWeb service directory currently lists around 1500 services which are using REST, and around 360 using SOAP. Why is REST becoming so popular and what are the common mistakes in the REST API design?

Graphic from Open APIs: a State of the Market
REST API, or to be more precise RESTful API implemented with HTTP, inherently adopts Web architecture principles and can take many advantages of already existing Web technology. Your RESTful API does not require any vendor-specific software. Instead, it can run on already available, open, standards-based, and royalty-free technology. Universal linking built on URIs and URLs gives your API the ability to link any resource with any other on the Web. By using Internet media types (previously known as MIME types), your API messages can have different representations such as JSON or XML and serve clients with various needs. And last but not least, layering and separation of concerns together with Web infrastructure intermediaries such as proxies, gateways, and firewalls improve your API’s performance via large-scale, shared caching.
It is not unusual, however, that many APIs that claim to be RESTful actually fail to do so. Mike Pearce gave an interesting talk (slides embedded below) on how you can easily break REST principles and which mistakes you should avoid when designing RESTful API.
Some of the most common mistakes that Mike mentions in his presentation:
ETag, If-Modified-Since header, and 304 Not Modified response code. They allow your clients and servers to negotiate always a fresh copy of the resource and through caching or proxy servers increase you application’s scalability and performance.REST style conforms to Web architecture design and, if properly implemented, it allows you to take the full advantage of scalable Web infrastructure. Although you might have reasons for breaking some of REST principles, you should always understand why you are doing so.





©ProgrammableWeb.com 2012. All rights reserved.
Terms of Service | Privacy Policy
5 Responses to “API Anti-Patterns: How to Avoid Common REST Mistakes”
at 11:42 am
[...] API anti-pattern. Cum să eviți greșeli comune REST [...]
at 1:44 pm
Very useful article about REST architecture
at 3:10 am
[...] API Anti-Patterns: How to Avoid Common REST Mistakes – List of common mistakes when designing REST APIs. (by Tomas Vitvar) [...]
at 6:02 pm
REST-style Web framework designed to meet, if properly implemented, it allows you to go take advantage of scalable network infrastructure. Although you may break the REST principle for some reason, you should understand why you always do. Er er er, I think I understand.
at 11:32 am
The HTTP standard does have server level error codes but they are pretty generic (“bad gateway”, “service unavailable”, “http version not supported”). How many of those are really useful to return to a client for an error stemming from business logic specific to your application? If the user tries to create a resource with invalid input, what are you doing to return? You really have no choice but to return a 500 and to embed a app specific error code and message in the response.