background preloader


Facebook Twitter

REST Mistakes. Web APIs typically use REST style for communication while moving away from more traditional SOAP web services.

REST Mistakes

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. It is not unusual, however, that many APIs that claim to be RESTful actually fail to do so. Some of the most common mistakes that Mike mentions in his presentation: Tunneling everything through GET. REST style conforms to Web architecture design and, if properly implemented, it allows you to take the full advantage of scalable Web infrastructure. API - Formats - REST vs. non-REST. Some background on REST REST is an architectural style for web services like ours.

API - Formats - REST vs. non-REST

It’s the basis of the way the web works today, so it was designed with things like scalability and interoperability in mind. This style has a few main guidelines: URLs should represent resources (nouns) rather than actions (verbs). APIs should re-use HTTP, the language of the web, as much as possible. One of the main advantages to having a RESTful API is related to #2: by using HTTP as the interface, you have to write less of your own code; instead, you get to leverage widespread existing HTTP support.

For example, every HTTP stack understands that a 4xx status code signifies a client error whereas a 5xx status code signifies a server error. Unfortunately, today's mainstream client-side web platforms have some notable limitations in their support of HTTP, generally due to security reasons. For example, XMLHttpRequest (the “x” in Ajax) doesn’t work across domains in older browsers. REST APIs must be hypertext-driven » Untangled. I am getting frustrated by the number of people calling any HTTP-based interface a REST API.

REST APIs must be hypertext-driven » Untangled

Today’s example is the SocialSite REST API. That is RPC. It screams RPC. There is so much coupling on display that it should be given an X rating. What needs to be done to make the REST architectural style clear on the notion that hypertext is a constraint? API designers, please note the following rules before calling your creation a REST API: A REST API should not be dependent on any single communication protocol, though its successful mapping to a given protocol may be dependent on the availability of metadata, choice of methods, etc. There are probably other rules that I am forgetting, but the above are the rules related to the hypertext constraint that are most often violated within so-called REST APIs. RESTful Web services: The basics.

The basics REST defines a set of architectural principles by which you can design Web services that focus on a system's resources, including how resource states are addressed and transferred over HTTP by a wide range of clients written in different languages.

RESTful Web services: The basics

If measured by the number of Web services that use it, REST has emerged in the last few years alone as a predominant Web service design model. In fact, REST has had such a large impact on the Web that it has mostly displaced SOAP- and WSDL-based interface design because it's a considerably simpler style to use. REST didn't attract this much attention when it was first introduced in 2000 by Roy Fielding at the University of California, Irvine, in his academic dissertation, "Architectural Styles and the Design of Network-based Software Architectures," which analyzes a set of software architecture principles that use the Web as a platform for distributed computing (see Resources for a link to this dissertation). Back to top Listing 1.