Captain Jack Sparrow on RESTful Web services
“I like it. Simple. Easy to remember.” The words of Captain Jack Sparrow. And this is exactly how I feel about RESTful API’s.
What is REST? The Wikipedia definition says:
“Representational State Transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The term was introduced in the doctoral dissertation on the web written in 2000 by Roy Fielding,[1] one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification, and has come into widespread use in the networking community.”
Do not let this put you off or confuse you! Lets look at a RESTful implementation to make things clearer. Lets look at YouTube’s RESTful API.
Lets say you want to write a PHP or Python or some script that gets your account details on YouTube and display them on a page.
All you need to do is to go fetch the output of a certain page and parse that output to get it working:
You read in the URL given by YouTube:
http://www.youtube.com/api2_rest?method=youtube.users.get_profile&
dev_id=YOUR_DEV_ID&user=YOUTUBE_USER_NAME
As you can see, this looks like a pretty standard link to a page in a site. Thats just it! It is! You can open this URL page in your browser. Obviously, YOUR_DEV_ID and YOUTUBE_USER_NAME should be replaced by the values you got from YouTube.
If all is ok, this “page” should return something like this:
<?xml version=”1.0″ encoding=”utf-8″?>
<ut_response status=”ok”>
<user_profile>
<first_name>YouTube</first_name>
<last_name>User</last_name>
<about_me>YouTube rocks!!</about_me>
<age>30</age>
<video_upload_count>7</video_upload_count>
…. and more ….
</user_profile>
</ut_response>
This looks just like XML, doesn’t it! Exactly. So you write your script to read the contents of the page that the given URL points to and parse this XML output it returns and do with it what you want to.
This is easily the easiest way of doing a web service you’ll come accross. Not only is it easy to consume the service, it is also easy to implement a web service this way!
Note, that there is a lot more to it. This is a simple, working example. I suggest you read all the Wikipedia page to get a better, more complete overview! You can however with this titbit of information, use the YouTube RESTful API!
technorati tags:RESTful, YouTube, API, webservices, REST
Blogged with Flock
3 Comments to "Captain Jack Sparrow on RESTful Web services"
Spit it out!
Programming, web development Stii
Recent Posts
- Astalavista Wordpress!
- Lifestreaming and Twitter is making us lazy
- Days with my father
- Friday morning fail by a stripper
- Got Springleap!
- Afrigator vs Regator
- Don’t pirate music/movies! You might be forced to use Windows if you do…
- Pike > Python?
- Using Twhirl for FriendFeed
- Being anti-social SUCKS!
My Posse
- Jayx’s bloggy
- Gogo’s blog
- Go2 South Africa
- Stumble Upon
- Dave Duarte
- Wikipedia
- zlythern
- Max Kaizen
- Tresblue
- Mike Stopforth
- RafiQ
- Muti.co.za
- Employmint
- Danette’s Bloggy!
- Thinking Machine
- White African
- kiefpiet.co.za
- Skuff’s World
- Goozeberry
- Crossloop blog
- Crossloop
- Aquila Online
- Charl van Niekerk
- Derek Allard
- Code Igniter
- Carls
- Justin Hartman
- blik.co.za
- Stefano Sessa
- Uno de Waal
- Amplitude!
- bLaugh
- Tyler Reed
- Chris Rawlinson
- Stormhoek!
- 3am
- Mike Solomon
- Mobile Q and A
- Eric Edelstein
- Marc Forrest
- Imel Rautenbach
- Absolutewillie
- Vincent Maher
- Colin Daniels
- Groogle!
- Chilibean
- Paul Jacobson
- Ayelet
- Python Guru Neil
- Rails Guru Nic
- Beverley Merriman
- Miguel
- Nic Harrywhatshisname
- Chris iMod
- Geekrebel!
- Steven McD
- Belinda sweetheart!
- Henre Rossouw
- JPGeek
- Foxinni
- Adii
- Charl Norman
- Bandwidthblog
- Jason Bagley
- Simon Botes
- Auric Silverwing
- Mark Forrester
- Saul Kropman
- Fred Roed
- Sass Schultz
- Gregor Rohrig
- Catherine Lückhoff
- Toastmasters
- SAA
Filed in
- Afrigator (26)
- ajax (9)
- API (2)
- Apple stuff (10)
- Blogging (25)
- browsers (5)
- Business (28)
- Code Igniter (8)
- firefox (8)
- flock (14)
- Funnies (73)
- GeekDinner! (18)
- General and sometimes Rants (49)
- Go2SA (2)
- ideas 2.0 (14)
- javascript (12)
- Kick-ass Tools (30)
- Linux (5)
- Marketing (25)
- moo.ajax (4)
- mootools (6)
- Open Source (10)
- Programming (33)
- C# (1)
- PHP (13)
- Python (9)
- Ruby (on Rails) (9)
- RSS (5)
- Semantic Web (32)
- Social Web (57)
- Software Development (15)
- South Africa (33)
- Tagging (6)
- Techie stuff (22)
- Tshirts (3)
- Tutorials (42)
- Blogging (17)
- Flocking (6)
- muti.co.za (13)
- Web 2.0 (73)
- web development (20)
Past Stuff
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006















[...] more information in the Geek Dinner, please feel free to contact Stii or myself or have a squize at the Geek Dinner [...]
[...] just read an article titled Captain Jack Sparrow on RESTful Web services. Although I think the article is good in explaining the simplicity of web services to the masses, [...]
[...] night Neville released a first draft of a REST API for Muti! POX, just as I like it… So I’m quite privileged and honoured to be one of the [...]