A bit on RESTful webservices

February 10, 2009

Today I was put on the spot and asked to explain REST as it pertains to Web Services, unfortunately I found that I could not articulate that which I know and ended up basically flubbing the opportunity. Uggh, I was so angry at myself.

The truth is that REST is not easy to use and/or explain. Yeah, its simple but its not easy, in fact its hard. So I thought to avoid that particularly uncomfortable situation recurring that I should come up with some basic points to explain it, I shall call them Conrad’s 4 basic cornerstones of RESTful Web Services. Those reading here should also see it as an opportunity to chime in and help by providing feedback as I think there are a lot of people that THINK they understand REST but don’t really grok and I am certainly not excluded in that statement. I am not going to go into the benefits and what not, read wikipedia for that. This is purely some notes on the very basic principles.

Conrad’s 4 Cornerstones of RESTful Web Services (HTTP)

REST = Representational State Transfer

  1. The service exposes application state and interaction as resources that can be represented (sic) as a unique URI over HTTP
  2. Resources are manipulated (maybe not the right word) through a uniform interface, these are POST, GET, PUT and DELETE verbs
  3. The service is stateless.
  4. The service is strictly client-server

Right I believe that is enough for my purposes, there are some other bits around Caching and Layering, mime types and response codes that my points don’t cover but IMHO we are ok as HTTP takes care of that for us to some extend and the rest are less crucial to grokking the concept and thus removed for simplicity.  (opinions?)

What does the URI address for the resource look like?
A simple example:
http://mysite.com/api/user/1
Here we are addressing a specific resource in the user collection .. though we are not expressing any intent as we are not providing a verb.

Throw a verb in the mix:
GET http://mysite.com/api/user/1
Ah, now we are getting somewhere we want to retrieve the data for that specific resource.

OR

DELETE http://mysite.com/api/user/1
I would like to delete the addressed resource..

Similarly POST would create a new user (drop the resource identifier “1” here) and PUT would alter and replace the resource.

Thus the verbs loosly map as follows for out purposes:
POST = CREATE
GET = READ
PUT = UPDATE
DELETE = DELETE

Responses on these actions will return status codes, another handy HTTP freeby that REST can use e.g. 200 OK’s and 404 Not Found etc..

To state or not to state?

Um REST is stateless and the so-called gray area of using cookies for auth purposes is not gray, its broken. Just deal with the fact that your are not 100% compliant and leave that there.  Alternatively look at Amazons Rest Auth implementation which operates via headers sent to and fro. Also adding the session identifier to every URL is not valid as this breaks the uniqueness of the resources’ address as each user will utilise a different URI to address THE SAME resource!

Ok I am tired now, I still want to talk about using RESTlike URL’s in your web application/site (as opposed to API’s for webservices) as I have done in the past which raises issues such as the difficulties of using PUT and DELETE via browser forms often addressed by repurposing the POST method somewhat .. maybe subject matter for a next time.

PS whats up with Facebooks so-called RESTlike API?

Methods like admin.getAllocation etc??? Looks more like RPCLike what with method names getting sent in the requests? Use of HTTP and XML does not a REST service make!

Advertisements

Well, I dunno. Apparently it’s up in the air at the moment according to google.

But Dewald Botha is trying to claim the fame for entirely selfish reasons (something about a SEO prize??). For a brief moment he pipped the Brad Fallon and the Justin Hartman (no links, cause that’s not fair to Dewald, and that makes him a sad panda apparently)

Link to the bloody oke if you care, he said he would hurt me if I don’t ask (but I am sure you don’t care about either point anyway)

Oh and visit his stupid website http://coolestguyontheinternet.com/ because he is slipping down the ranking quick because he had illegal pages up at the wikipedia and the hubpages and they finally caught wind.

If anything it should be funny to see if he wins, in which cause he may buy us all a beer, but I doubt it because he is also a poor panda getting married on top of being a sad panda, which has nothing to do with the panda in Kung Fu panda but that panda was a funny panda, so I just wanted to mention it.

The power of community.

August 22, 2008

As some of my friends know I am a badge wearing supporter/member of the SA 4×4 Community Forum. This is a very active niche forum of 4×4 enthusiasts, 4,648 of them. (I was once told that as much as 2/3’s are active). That amounts to a fair amount of passionate people. People with a combined voice.

Recently these people got together and raised R10000 for the desert lion project with a quick collection.

In recent times however a portion of the estimated 130 Members that own Toyota Fortuners have been fighting their own little war with regards to suspected handling problems on their vehicles after individuals realised that their complaints where getting met with the cold shoulder/ag shame response.

They rallyed together and hotly debated the subject on the forum generating 10 pages and near 200 posts.

Once the dangers and photos of Fortuners rolled at speeds as low as 60kph became evident the ball rolled quickly. DriveOut/WegRy magazine and the Argus and Mercury newspapers came to aid printing letters and an article containing a response from Toyota SA respectively.

Right now Toyota’s has put measures in place to replace new models and existing vehicles with better tyres which they claim solve the problem, note that they claim that they came to this conclusion by their own accord and claim no formal complaints are lodged. ??

However the Forum does not intend to stop there, they want a total recall as they believe its more than the tyres to blame and they are arranging a mass testdrive in the following week with a DriveOut correspondent where they will test various configs and setups on eachothers Fortuners to arrive at some conclusion.

Don’t underestimate the voice the web can give your little social network group. The power is at your fingertips.

*Initialising Rant*

Bwaaaaaaaa!!

Ja boet Nic. I see you are getting a little fedup around people blogging about blogging. I have long since realised the bloody exact same thing. Why do you oldschoolers out there think I canned the Geekspin blog and had the bastard thing taken over by 1000’s of spam comments and crap?

I got tired, moeg. Siek.

I wish there where some more decent blogs out there, you know the real ones. Written by REAL people with REAL passions. Like this one by Pia, . (Well done pia, btw).

THAT my friends is exactly what blogging is about, lets not bullshit ourselves into thinking that the little group of flame slinging techies blogging about blogging and twittering about twitter is where its at. Nay, that’s just the useless early adopter circle. Friends, Web 2.0 and the whole of silicon valley is all a farce, 98% of this crap means nothing to the other millions of people on this planet. Nada. *gasp*

Nasty words for the day: Self-entitlement, Self-righteousness, Egotistical, Egomaniac, Choirpreaching, Insignificance. There put that in your pipe and smoke it.

Ok ok. Calm down children. Some of you I am interested in hearing what you are saying so I read and chime in to the never ending circlejerk. If you are actively involved at engineering the space then you get a free ticket to join, like me. But the rest of the planet doesn’t give a damn (insert alternative four letter word here).

Tired.

*Rant complete*

It was with much amusement that I read the post by SaulK on “the outlet” on 6 things you did not know of rafiq.

Two interesting things stand out for me, 1) This post is less malicious then tickling a puddycat and is clearly a clever ploy to attract some attention, which is by no means a bad thing (or are their some thinly veiled frustrations hidden Saul? 🙂 ) , 2) It presents a very interesting experiment as to whether the one provoked will respond quickly.

And yes .. he did. In fact he muti’d it himself within a couple hours.

This had me thinking .. let’s say you wanted to get hold of some lofty techy type celeb, fairly ensconced in the web, can this be a more effective means of communication than email? Email is so nasty nowadays, what with spam and the amount of it, that it has become a fairly ineffective medium through witch to get hold of the cognoscenti (eliciting that *damned spammer* response is easier than one might think) whereas a post on a blog or twitter referencing one name seems to not carry that same problem (perhaps the cognitive filters are differently applied, reading a blog post at ones one accord is different from having an email shoved upon oneself afterall).

As I’m writing this though I release that I have read these exact same thoughts somewhere else before, and I have found it. In July Doc Searls responded on a similar call via a blog by Rohit Bhargava.
Rohit has also seen and acknowledged this trend and his even coined it, “Egommunication”.

Ego Searches, also called Vanity Searches. Shallow or Human Nature? We like to know what people are saying, good or bad (we hope more good). We don’t like to feel people are talking behind our backs, but we don’t like getting sold to. Is this an opportunity for gold diggers and spammers employing clever tricks to have us view their wares? Perhaps.

To tack onto this idea I would like to add another observation, take a look at the number of comments at the end of Saul’s piece, normally he garners somewhere between null and two comments on a piece, this one had 9 comments at the time of writing this. What does this tell us? Link baiting works, lol. No but more importantly, people track themselves and those that they feel close, or involved with. Basically Rafiq’s groupies and enemies where also checking in. Thus sending out a certain proposition to a certain person might get you in contact with others with a similar interest around there, perhaps even a competitor in the space you never may have known about.

What’s your take on this? As a developer I have to ask, is there a place for a tool here? I reckon so, I wouldn’t mind a tool where I can slot in my name and have it feed me an RSS feed of new items found out there on the web, Facebook, Flicker, Twitter, Blogs, Web Searches wherever. Call it a vanity aggregator, perhaps one already exists? The idea of the Vanity Folder is not a new one.

Stii Pm’ed me a good article on ReadWriteWeb, a fairly long post about the shift from blogging to microblogging and some such. Not a bad read a lot of what they say is true, and could be interpreted as the end of blogging etc.

Stii then wrote on his that perhaps we (bloggers) are getting lazy and that perhaps Twitter is working for us cause we have short attention spans.

Here’s my 2 cents.

Yes, traffic is moving from blogs to twitter. Thank god for that. Now, let me tell you why I am relieved before you people have a heart attack.

Reason 1: Most blogs have become rubbish. We are all guilty of this, but if I’m honest then when I come to your blog or open your feed then don’t want to know what you had for dinner, or how your mug of coffee kicks ar*e, or how you have a toothache. I certainly don’t want to see every bloody braindump you have throughout the day or have to click on 17 “this is so cool” links. Seriously.

Reason 2: Tweets can and should be short. I can take 140 chars no more.

Reason 3: Blogs are forever, put stuff there you want to perserve, the really important stuff.

Reason 4: Twitter is transient, if it gets to noisy I just ignore it, I don’t really care. I hope I am not missing anything important, rather put that on your blog!

I hope what this means is that the noise will shift away from the blogs and onto the micro-b’s (*cute shortening of microblogs) and that the blogosphere will reclaim some of the shining beauty it once had, that place where I did not want to miss a single post on YOUR feed.

Twitter’s cool right? Yeah, when its up. The general consensus is that its reaching the end of the road as far as the cognitive dissonance rope left to the users of the servers.

What’s next? A suggestion? Make the “microblog-o-sphere” open, get a solid PHP based platform down and use the strength of the community to ensure a reliable code base.

Enters Laconica .. ta-da!

Laconica (wiki) is a tidy little opensource alternative to Twitter and a number is installations have cropped up including identi.ca which seems to be the current flavor of the moment.

What about scalability I hear you ask? One word answer. Federation, Laconica aims to distribute the microblogging experience by federating across any number of installs, this would allow one to say create an fairly focused community on one service but allow the ability to track friends using other similar installs, thus removing the immediate load on any one server and having the conversation continue in some form if one of the points do go down. (Caveat: I have not seen this in action myself, so I hope that it works as well in practice as it sounds in theory)

I have created an account, now just waiting for some people to talk too. Add me plz: http://identi.ca/conradstrydom