<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NinjaCipher &#187; api</title>
	<atom:link href="http://www.ninjacipher.com/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ninjacipher.com</link>
	<description>kungpow programming</description>
	<lastBuildDate>Thu, 25 Mar 2010 14:39:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='www.ninjacipher.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>I can has REST?</title>
		<link>http://www.ninjacipher.com/2009/04/14/i-can-has-rest/</link>
		<comments>http://www.ninjacipher.com/2009/04/14/i-can-has-rest/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 12:53:59 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
				<category><![CDATA[api]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=97</guid>
		<description><![CDATA[Recently I&#8217;ve been working on a python wrapper for the twitter.com REST API called BirdyPy. It got me thinking about when I first started working with web APIs and how over complicated it seemed to me then. So I figured that I would share some of the stuff I&#8217;ve learned in my work leveraging XML [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-103" title="i-can-has-walkthru" src="http://www.ninjacipher.com/wp-content/uploads/2009/04/i-can-has-walkthru.jpg" alt="i-can-has-walkthru" width="200" height="214" />Recently I&#8217;ve been working on a python wrapper for the <a href="http://twitter.com" target="twitter">twitter.com</a> REST API called BirdyPy. It got me thinking about when I first started working with web APIs and how over complicated it seemed to me then. So I figured that I would share some of the stuff I&#8217;ve learned in my work leveraging XML APIs and hopefully help some other people struggling with the concept frame it in a simple way.</p>
<p>On the most basic level a <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" target="wikipedia">REST</a> API consists of different urls that you can call to get and post content to a web service. This can be pictures (like <a href="http://www.flickr.com/" target="flickr">Flickr</a>) or micro blog posts (like <a href="http://twitter.com" target="twitter">twitter</a>) or even videos (like <a href="http://youtube.com" target="youtube">youtube</a>). When you make a request to a REST API the API responds with a chunk of XML. This XML usually represents one or more data record (they call them resources). For instance if I want to get a list of my recent twitter updates I can make a call to the following url (http://twitter.com/statuses/user_timeline.xml) and I get back an chunk of XML that represents my last 20 status updates. Taking this a step further I can also post a new status update by making a request to http://twitter.com/statuses/update.xml.</p>
<p>One of the key factors to take into account when working with REST APIs are the request methods used when interacting with the API. If your a little fuzzy on what request method means just think of it in terms of a web form (ie method=&#8217;post&#8217;). GET requests work off of query strings (like so http://mylink.com?id=1) where as POST requests bundle all of the data into the request itself. There is allot you can talk about as far as different request types. You can read more about it here if your still unclear on it.</p>
<p>Most REST APIs are setup so that when you want to <em>get</em> back records from the system you use a GET request. If you want to <em>post</em> records to the system or update an existing record you use a POST request. If your noticing a trend good for you. The convention is to work off of the verb in the sentence&#8230; so to get something you use GET and to post something you use POST. Pretty simple right.</p>
<p>Some APIs are set up so that when you want to delete a record you have to send a request as a DELETE method. And some APIs also use the PUT method for doing things like updates or posting files. Allot of services don&#8217;t take it to this level as it tends to just confuse people. For now just worry about GET and POST until you get everything straight in your head.</p>
<p>Another point to notice is that most REST APIs not only return a chunk of XML representing the data record but they also return a response status code (200 ok, 404 not found, 500 server error etc).  Response status codes are a pretty hefty topic but really simple one you get it. Basically they are a numeric code that represents the status of the response (did it work or not and why). You can read more about them <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">here</a>.</p>
<p>So hopefully that wasn&#8217;t too painful. If anything that should  give you at least an introductory understanding of what to expect when you start to play with a REST API. Stay tuned for the next installment of this series when I show language specific (ruby, python) examples of using REST. Feel free to post some questions and I&#8217;ll do my best to answer them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2009/04/14/i-can-has-rest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
