/start rant about REST
I'm also sick of people believing that REST is some magic pancea to the API problem.
Go look over any project you did before you heard of REST. Did you just have 4 methods on your objects called Get, Create, Update, Delete? With loads of extra parameters you can optionally pass in?
Do you think that would make a good API for an actual library?
No, of course not.
So why on earth would you use that very bad library design just because it's going over HTTP? HTTP was meant for documents, not programming APIs.
RESTful APIs was always a stupid idea. And don't even get me started about the nonsense that a GET doesn't modify anything, of course it does to even the most basic objects, I just logged your access to it. I may have checked whether you were logged in and updated your last access time. The amount of views that object has has just increased. The system changed in many different ways, possibly including the object.
I'm tired of APIs that try and contort a complicated API into some crazy REST structure by using loads of parameters. Google, I'm looking at you. You guys are smart programmers, how have you not realized the entire concept is intellectually vapid.
/end rant about REST
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1...
Or, if you'd prefer, the almost finished httpbis:
http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-2...
> This definition of safe methods does not prevent an implementation
> from including behavior that is potentially harmful, not entirely
> read-only, or which causes side-effects while invoking a safe method.
> What is important, however, is that the client did not request that
> additional behavior and cannot be held accountable for it. For
> example, most servers append request information to access log files
> at the completion of every response, regardless of the method, and
> that is considered safe even though the log storage might become full
> and crash the server. Likewise, a safe request initiated by
> selecting an advertisement on the Web will often have the side-effect
> of charging an advertising account.
I'd suggest that you become more informed about something before having such strong feelings about it.If you think of a request as a function call then it's all parameters and it's completely crazy.
If you can require your client to behave in a normalized way then all this complexity is not necessary and you're probably avoiding some bugs along the way.
And as I write this and think on it a bit more, I'm realizing that 'serializing' APIs over HTTP probably isn't the best idea in the world. But it makes things "easier" - firewalls don't need configuration to let your customers access your remote API, HTTP traffic tends toward human-readable text, etc.
No wonder you hate REST HTTP APIs. Take a look at FreshBooks API. They have a more complicated application (in terms of model complexity and ACL complexity, not scale) than most of Google APIs and besides the fact that they only support XML, their API is really fucking good. It is unsurprising and it it's been around a good long while.
Would you really rather FreshBooks use an RPC API? /setup_payment_for_invoice /pay_payment_on_invoice /allow_contractor_to_submit_expenses /create_new_time_tracked_amount
It would be brutal.
Because when you design a Web API you're not designing a library, you're designing part of a distributed system.
Accessing code on a remote server is not like accessing code in a DLL, and never will be.
It's a computer asking for an action talking to a computer asking for an action.
Call them whatever you want, the concept is extremely simple and pretending it's anything more complicated is obfuscating the underlying simplicity of the intent of the programmer. i.e. I want the other computer to do something or the other computer to send this computer some information.
Even if RPC is a fundamentally, unambiguously simpler way to express that intent (and I think that's arguable), it does not meet the same technical requirements that REST does.
http://www.joelonsoftware.com/articles/fog0000000339.html
"People get worried about .NET and decide to rewrite their whole architecture for .NET because they think they have to. Microsoft is shooting at you, and it's just cover fire so that they can move forward and you can't, because this is how the game is played, Bubby. Are you going to support Hailstorm? SOAP? RDF? Are you supporting it because your customers need it, or because someone is firing at you and you feel like you have to respond?"
It is not nonsense. It is a very useful convention. If you stick to it, you get some system properties ... for example, you can very easily put a caching layer (nginx, varnish, etc ...) which can reduce a huge amount of load to your backends, without worrying that it will change the behaviour of your backend.
I thought one of the principles of RESTful design is that the internal structure of URLs shouldn't really matter - you should be able to navigate to any resource from being given a single base URL. So i struggle to see what difference it makes if RESTful API consumers see different URLs to browser users....
A lot of this comes down to what you mean by "API"...