Friday, May 20, 2016

On REST APIs

If I join a company that has standardized on REST-style APIs, I will be a good citizen and follow the established standards.

However I am not a big fan of REST APIs, and if starting from scratch, I will advocate against it. My reasons are follows:

Four verbs are not descriptive enough in all cases. It can be made to work, but it is often like hammering a square peg in a round hole. For example, consider actions like "assign", "approve", "merge", etc.

Second, I need to expose the object mode in the URL path; I may not want to do that always, or the object model may change.

Third, I may want to combine multiple actions into a single request for performance reasons or simple to reduce work. Examples: createOrUpdate (if available then update, else create), createAndGet (create object and return the object which now has backend-generated properties).

Last, HTTP status codes contain a lot of junk and most often not exactly what I need. Status codes are too application-specific to have a single generic list.

No comments:

Post a Comment