<?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>David Janes&#039; Code Weblog &#187; auapi</title>
	<atom:link href="http://code.davidjanes.com/blog/category/auapi/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.davidjanes.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 03 Feb 2012 00:49:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>AUAPI: how to encode geographic location</title>
		<link>http://code.davidjanes.com/blog/2009/03/13/auapi-how-to-encode-geographic-location/</link>
		<comments>http://code.davidjanes.com/blog/2009/03/13/auapi-how-to-encode-geographic-location/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 12:55:43 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[auapi]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=520</guid>
		<description><![CDATA[Geographic location is a little more problematic to encode than other data types we&#8217;ve looked at for the Almost Universal API. The issue is that standards for adding geographic information are either overly complicated or they encode information in a hard-to-use-from-JSON manner. Using GeoRSS GeoRSS provides two ways (well, way more I&#8217;m sure) of adding [...]]]></description>
			<content:encoded><![CDATA[<p>Geographic location is a little more problematic to encode than other data types we&#8217;ve looked at for the <a href="http://code.davidjanes.com/blog/2009/02/27/introducing-the-almost-universal-api/">Almost Universal API</a>. The issue is that standards for adding geographic information are either overly complicated or they encode information in a hard-to-use-from-JSON manner.</p>
<h4>Using GeoRSS</h4>
<p><a href="http://georss.org/">GeoRSS</a> provides two ways (well, way more I&#8217;m sure) of adding geographic point information to a blog post (which is essentially the same as AUAPI item). From the webpage:</p>
<pre>&lt;georss:point&gt;45.256 -71.92&lt;/georss:point&gt;</pre>
<p>which would be encoded as:</p>
<pre class="result">{
 "georss:point" : "45.256 -71.92"
}</pre>
<p>and</p>
<pre>&lt;georss:where&gt;
   &lt;gml:Point&gt;
      &lt;gml:pos&gt;45.256 -71.92&lt;/gml:pos&gt;
   &lt;/gml:Point&gt;
&lt;/georss:where&gt;</pre>
<p>which would be encoded as:</p>
<pre class="result">{
 "georss:where" : {
  "gml:Point" : {
   "gml:pos" : "45.256 -71.92",
  }
 }
}</pre>
<p>Neither of these look particularly satisfying because the lat/lon is encoded as a string. We could encode as an array of numbers, but then we have to write a custom transcriber for converting to XML.</p>
<h4>Using hCard</h4>
<p>Another option would be to use the geo.latitude, geo.longitude attributes in hCard. Unfortunately, hCard requires elements such as FN and in general imply that we are talking about a person or organization, so this isn&#8217;t really satisfying either.</p>
<h4>How AUAPI recommends geographic information should be encoded</h4>
<pre>
'geo': {
   'latitude': 34.743763,
   'longitude': -86.572568
}
</pre>
<p>This in fact, is exactly the microformat&#8217;s <a href="http://microformats.org/wiki/geo">geo</a> standard.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2009/03/13/auapi-how-to-encode-geographic-location/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PortableContacts and the Atom syndication standard</title>
		<link>http://code.davidjanes.com/blog/2009/03/03/portablecontacts-and-the-atom-syndication-standard/</link>
		<comments>http://code.davidjanes.com/blog/2009/03/03/portablecontacts-and-the-atom-syndication-standard/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 11:56:57 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[auapi]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=515</guid>
		<description><![CDATA[Thanks to Kevin Marks, I&#8217;ve just stumble onto the Portable Contacts effort. They seem to have thought quite a bit about the hCard/vCard serialization issue. I&#8217;ve added my two bits, in particular making the claim that they should consider making there proposal more compatible with existing consumers and infrastructure by piggybacking on top of the [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to <a href="http://epeus.blogspot.com/">Kevin Marks</a>, I&#8217;ve just stumble onto the <a href="http://portablecontacts.net/">Portable Contacts</a> effort. They seem to have thought quite a bit about the <a href="http://code.davidjanes.com/blog/2009/03/02/auapi-encoding-hcards-in-json/">hCard/vCard serialization issue</a>. I&#8217;ve added my two bits, in particular making the claim that they should consider making there proposal more compatible with existing consumers and infrastructure by piggybacking on top of the <a href="http://atomenabled.org/developers/syndication/">Atom syndication format</a>, rather than requiring PC consumers to redevelop all this infrastructure around their format. This, in essence, is what the Almost Universal API idea is about.</p>
<hr />I&#8217;ve been <a href="http://code.davidjanes.com/blog/category/auapi/">thinking and writing</a> recently about how APIs can be made compatible with each other &#8211; that is, the same consumers can be used with the results from different APIs &#8211; and Kevin Marks pointed me this way, as I had written about hCard serialization.</p>
<p>However, it occurs to me that PC could be made to overlay the <a href="http://atomenabled.org/developers/syndication/">Atom syndication standard</a> with very few changes (by the looks of it, you&#8217;re fairly late into the design cycle though). For example, this:</p>
<pre>{
  "id": "703887",
  "displayName": "Mork Hashimoto",
  "name": {
    "familyName": "Hashimoto",
    "givenName": "Mork"
  },
  "birthday": "0000-01-16",
  "gender": "male",
  "drinker": "heavily",
  "tags": [
    "plaxo guy",
    "favorite"
  ],
}</pre>
<p>Could be encoded like:</p>
<pre>{
  "id": "703887",
  "title": "Mork Hashimoto",
  "updated" : "2008-...",
  "published" : "2007-...",
  "category" : [
   { "term" : "plaxo guy", },
   { "term" : "favorite", },
  ],
  "contact" : {
    "name": {
      "familyName": "Hashimoto",
      "givenName": "Mork"
    },
    "birthday": "0000-01-16",
    "gender": "male",
    "drinker": "heavily",
  }
}</pre>
<p>Which is almost the same, except now that your XML serialization can be Atom (noting of course there will be changes for the paging elements, etc. that you&#8217;ve defined). The immediate implication of this is that you&#8217;re working within a large existing infrastructure that knows about update notification, has tools for display, and so forth.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2009/03/03/portablecontacts-and-the-atom-syndication-standard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AUAPI: encode images using media:rss</title>
		<link>http://code.davidjanes.com/blog/2009/03/02/auapi-encode-images-using-mediarss/</link>
		<comments>http://code.davidjanes.com/blog/2009/03/02/auapi-encode-images-using-mediarss/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 21:34:21 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[auapi]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=513</guid>
		<description><![CDATA[MediaRSS is the way to encode images in the Almost Universal API (AUAPI). Because MediaRSS encodes its values in attributes, we use the @ symbol to prefix keys. Example 1 &#8211; a single image 'media:content': { '@medium': 'image', '@type': 'image/jpeg', '@url': u'http://farm3.static.flickr.com/2165/2271778128_b59c01a695_m.jpg' } Example 2 &#8211; thumbnail 'media:thumbnail': { '@url': u'http://farm3.static.flickr.com/2165/2271778128_b59c01a695_t.jpg' } Example 3 &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://search.yahoo.com/mrss/">MediaRSS</a> is the way to encode images in the <a href="http://code.davidjanes.com/blog/2009/02/27/introducing-the-almost-universal-api/">Almost Universal API</a> (AUAPI). Because MediaRSS encodes its values in attributes, we use the <code>@</code> symbol to prefix keys.</p>
<h4>Example 1 &#8211; a single image</h4>
<pre>'media:content': {
    '@medium': 'image',
    '@type': 'image/jpeg',
    '@url': u'http://farm3.static.flickr.com/2165/2271778128_b59c01a695_m.jpg'
}</pre>
<h4>Example 2 &#8211; thumbnail</h4>
<pre>'media:thumbnail': {
    '@url': u'http://farm3.static.flickr.com/2165/2271778128_b59c01a695_t.jpg'
}</pre>
<h4>Example 3 &#8211; multiple images in different sizes</h4>
<pre>'media:group': {
    'media:content': [
        {'@medium': 'image',
        '@type': 'image/jpeg',
        '@url': u'http://farm3.static.flickr.com/2165/2271778128_b59c01a695_m.jpg'},
        {'@medium': 'image',
        '@type': 'image/jpeg',
        '@url': u'http://farm3.static.flickr.com/2165/2271778128_b59c01a695_s.jpg'},
        {'@medium': 'image',
        '@type': 'image/jpeg',
        '@url': u'http://farm3.static.flickr.com/2165/2271778128_b59c01a695_b.jpg'}
    ],
    'media:thumbnail': {
        '@url': u'http://farm3.static.flickr.com/2165/2271778128_b59c01a695_t.jpg'
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2009/03/02/auapi-encode-images-using-mediarss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AUAPI: encoding hCards in JSON</title>
		<link>http://code.davidjanes.com/blog/2009/03/02/auapi-encoding-hcards-in-json/</link>
		<comments>http://code.davidjanes.com/blog/2009/03/02/auapi-encoding-hcards-in-json/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 14:15:38 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[auapi]]></category>
		<category><![CDATA[aumfp]]></category>
		<category><![CDATA[semantic web]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=509</guid>
		<description><![CDATA[The best model for describing people is the vCard standard, RFC 2425 and RFC 2426. The microformats community has adapted the vCard standard for serialization into HTML using hCard. In the Almost Universal API (AUAPI), people and organizations should almost always be described using a JSON-encoded hCard. It is difficult to describe, without going into [...]]]></description>
			<content:encoded><![CDATA[<p>The best model for describing people is the <a href="http://en.wikipedia.org/wiki/VCard">vCard</a> standard, <a href="http://tools.ietf.org/html/rfc2425">RFC 2425</a> and <a href="http://tools.ietf.org/html/rfc2426">RFC 2426</a>. The microformats community has adapted the vCard standard for serialization into HTML using <a href="http://microformats.org/wiki/hcard">hCard</a>. In the <a href="http://code.davidjanes.com/blog/2009/02/27/introducing-the-almost-universal-api/">Almost Universal API</a> (AUAPI), people and organizations should almost always be described using a JSON-encoded hCard.</p>
<p>It is difficult to describe, without going into great minutiae, what the difficulties are in transforming the hCard and vCard standards into a pleasant looking and more importantly an easy-to-use hierarchy: there are certainly a number of edge cases that one would have to deal with it! There&#8217;s certainly an argument for just encoding hCard/vCards as a straight vCard serialization &#8211; at least in terms of simplicity of encoding. The issue is that the end consumer (which I believe should be the strongest focus) really has to do the dirty work in grouping everything together themselves.</p>
<h4>Algorithm</h4>
<p>This algorithm is destructive to the data structure it works upon, so generally you&#8217;ll be make a copy first.</p>
<ul>
<li>note that though we reference to all upper, mixed case, camel case and so forth hCard attributes, all attributes are actually physically encoded in lower case with &#8220;-&#8221; separators</li>
<li>let the &#8220;groupers&#8221; be ADR, GEO, N, ORG, TEL. Groupers group together attributes that are related (such as FirstName and LastName)</li>
<li>let the &#8220;narrowers&#8221; be Home, Work, Parcel, Postal (and <em>no-narrower</em>). Narrowers assign a specific meaning to a value, i.e. this a <em>Work</em> phone number.</li>
<li>assume each value is described by a number of attributes, i.e. &#8220;416-515-5555&#8243; can be described by ( TEL, Work, Mobile )</li>
</ul>
<p>Then:</p>
<ul>
<li>for Narrower, then for each Grouper
<ul>
<li>create a dictionary &#8216;subd&#8217;</li>
<li>for each values that is described by the ( Narrower, Grouper )
<ul>
<li>for each remaining attribute (besides Narrower and Grouper), add to subd</li>
<li>if the value was fully described by ( Narrower, Grouper ), add to subd under the key &#8216;@&#8217;</li>
</ul>
</li>
<li>for key, value in subd
<ul>
<li>add to the final result</li>
<li>if narrower is not &#8216;no-narrower&#8217;, add &#8216;@narrower = narrower&#8217;</li>
</ul>
</li>
</ul>
<ul>
<li>add subd to the result under the key Grouper</li>
</ul>
</li>
<li>add all remaining values from the original hCard to the result, noting that
<ul>
<li>if the value is described by a Narrower, we encoded it as a dictionary with &#8216;@narrower = narrower&#8217;</li>
</ul>
</li>
</ul>
<p>Clear? Well, the examples below will help. We the &#8220;416-515-5555&#8243; above we would get:</p>
<pre>{
 "hcard:hcard" : {
  'tel' : {
   '@work' : 'work',
   'mobile' : '416-515-5555',
  }
 }
}</pre>
<h4>Code</h4>
<p>The source code for this algorithm is in the <a href="http://code.google.com/p/aump/">AUMFP</a> tree, in file <code>vcard.py</code> function <code>decompose</code> (<a href="http://code.google.com/p/aump/source/browse/trunk/vcard.py">see around line 1083</a>)</p>
<h4>Namespace</h4>
<p>All JSON encoded hCards are in the namespace <code>hcard:</code>. In the AUAPI serialization, this namespace should only be on the enclosing element, all children will be assumed to be in the namespace. I am currently using the URI <code>http://purl.org/uF/hCard/1.0/</code> for this namespace (<a href="http://code.davidjanes.com/blog/2009/03/01/auapi-json-to-xml-serialization/">when XML serializing</a>); this may change in the future.</p>
<h4>Example 1 &#8211; home phone number from whitepages.com</h4>
<pre>{
 'hcard:hcard': {'adr': {'country-name': u'United States',
                         'locality': u'Huntsville',
                         'postal-code': '35801-2908',
                         'region': 'Alabama',
                         'street-address': u'1114 Humes Avenue NE'},
                 'fn': u'Jack Smith',
                 'geo': {'latitude': 34.743763000000001,
                         'longitude': -86.572568000000004},
                 'n': {'family-name': u'Smith', 'given-name': u'Jack'},
                 'tel': {'voice': u'256-539-8788'}},
}</pre>
<h4>Example 2 &#8211; work phone number from whitepages.com</h4>
<pre>{ 'hcard:hcard': {'adr': {'country-name': u'United States',
                         'locality': u'Gurley',
                         'postal-code': '35748-8715',
                         'region': 'Alabama',
                         'street-address': u'148 Little Cove Road'},
                 'fn': u'Jack Smith',
                 'geo': {'latitude': 34.698258000000003,
                         'longitude': -86.383027999999996},
                 'n': {'family-name': u'Smith', 'given-name': u'Jack'},
                 'org': {'organization-name': u'Alldyne Powder Technoliges'},
                 'tel': {'@work': 'work', 'voice': u'256-776-1238'}},
}</pre>
<h4>Example 3 &#8211; hCard directly to JSON</h4>
<pre>{ 'hcard:hcard': {
                 'adr': {u'country-name': u'United States of America',
                         u'locality': u'San Francisco',
                         u'region': u'CA'},
                 u'fn': u'Tantek \xc7elik',
                 u'logo': u'icon-2007-128px.png',
                 'n': {'family-name': u'\xc7elik',
                       'given-name': u'Tantek'},
                 u'photo': u'http://tantek.com/icon-2007-128px.png',
                 u'url': u'http://feeds.technorati.com/contact/tantek.com/#hcard'},
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2009/03/02/auapi-encoding-hcards-in-json/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AUAPI: JSON to XML serialization</title>
		<link>http://code.davidjanes.com/blog/2009/03/01/auapi-json-to-xml-serialization/</link>
		<comments>http://code.davidjanes.com/blog/2009/03/01/auapi-json-to-xml-serialization/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 13:40:47 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[auapi]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=502</guid>
		<description><![CDATA[Here is a brief outline of how one would &#8220;naively&#8221; transform Almost Universal API&#8216;s (AUAPI) JSON into XML. We say &#8220;naive&#8221; because in general one wants to make a transformation into a specific XML application: Atom, RSS, OPML, KML, etc.. In those cases, one has to rename and rework certain elements first for standards compliance, [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a brief outline of how one would &#8220;naively&#8221; transform <a href="http://code.davidjanes.com/blog/2009/02/27/introducing-the-almost-universal-api/">Almost Universal API</a>&#8216;s (AUAPI) JSON into XML. We say &#8220;naive&#8221; because in general one wants to make a transformation into a specific XML application: Atom, RSS, OPML, KML, etc.. In those cases, one has to rename and rework certain elements first for standards compliance, then complete the naive transformation for remaining elements.</p>
<h4>Walking</h4>
<p>Walking JSON objects is done depth first. Most of the complexity involved is in handling dictionaries, which can be valued as being comprised of ( key, value ) pairs. For each dictionary, we are creating an XML node whose properties are defined as follows:</p>
<ul>
<li>keys beginning with <code>@@</code> are ignored</li>
<li><em>the key <code>@</code> means &#8220;the text&#8221; of the  node</em> (the examples will make this more clear)</li>
<li>other keys beginning with <code>@</code> are attributes of the node</li>
<li>all other keys are defining children of the node</li>
</ul>
<p>There are number of complexities that have to be addressed; for this I suggest looking at the examples or source code.</p>
<h4>Namespace handling</h4>
<ul>
<li>collect all the namespaces used in the JSON and add to the root XML node</li>
<li>if any JSON element has a namespace, assume that namespace is inherited by its children</li>
</ul>
<h4>Code</h4>
<p>You can see the code for this in the AUAPI source base in <code><a href="http://code.google.com/p/auapi/source/browse/trunk/api.py">api.py</a></code> in <code>XMLAPIWriter.TranscribeNode</code>.</p>
<h4>Example 1</h4>
<pre>{
    "numbers" : [ 1, -0.23, ],
    "strings" : [ "bob", "caf\xe9", ],
    "booleanish" : [ True, False, None, ],
}</pre>
<pre class="result">&lt;root&gt;
    &lt;numbers&gt;1&lt;/numbers&gt;
    &lt;numbers&gt;-0.23&lt;/numbers&gt;
    &lt;booleanish&gt;True&lt;/booleanish&gt;
    &lt;booleanish&gt;False&lt;/booleanish&gt;
    &lt;booleanish /&gt;
    &lt;strings&gt;bob&lt;/strings&gt;
    &lt;strings&gt;caf\xc3\xa9&lt;/strings&gt;
&lt;/root&gt;</pre>
<h4>Example 2</h4>
<pre>{
    "a1" : {
        "b1" : 1,
        "b2" : 2,
    },
    "a2" : {
        "b3" : "hi",
        "b4" : "there",
    },
}</pre>
<pre class="result">&lt;root&gt;
    &lt;a1&gt;
        &lt;b1&gt;1&lt;/b1&gt;
        &lt;b2&gt;2&lt;/b2&gt;
    &lt;/a1&gt;
    &lt;a2&gt;
        &lt;b4&gt;there&lt;/b4&gt;
        &lt;b3&gt;hi&lt;/b3&gt;
    &lt;/a2&gt;
&lt;/root&gt;</pre>
<h4>Example 3</h4>
<pre>{
    "@attribute" : "hello",
    "@bttribute" : "there",
    "a" : "some string",
},</pre>
<pre class="result">&lt;root attribute="hello" bttribute="there"&gt;
    &lt;a&gt;some string&lt;/a&gt;
&lt;/root&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2009/03/01/auapi-json-to-xml-serialization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AUAPI: the Atom core vocabulary for items</title>
		<link>http://code.davidjanes.com/blog/2009/02/28/auapi-the-atom-core-vocabulary-for-items/</link>
		<comments>http://code.davidjanes.com/blog/2009/02/28/auapi-the-atom-core-vocabulary-for-items/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 12:58:47 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[auapi]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=495</guid>
		<description><![CDATA[To quickly review, the AUAPI sees API results as composing of two parts. A &#8220;response&#8221; (formerly the &#8220;meta&#8221;) and &#8220;items&#8221;, composed of one or more items. This division is documented in Work Object Records. Here is how we use Atom to encode API items in the AUAPI (we will document &#8220;response&#8221; in a different post). [...]]]></description>
			<content:encoded><![CDATA[<p>To quickly review, the <a href="http://code.davidjanes.com/blog/2009/02/27/introducing-the-almost-universal-api/">AUAPI</a> sees API results as composing of two parts. A &#8220;response&#8221; (formerly the &#8220;meta&#8221;) and &#8220;items&#8221;, composed of one or more items. This division is documented in <a href="http://code.davidjanes.com/blog/2008/11/11/work-web-object-records/">Work Object Records</a>.</p>
<p>Here is how we use Atom to encode API items in the AUAPI (we will document &#8220;response&#8221; in a different post). This sticks fairly closely to the <a href="http://atomenabled.org/developers/syndication/">Atom standard</a>, the differences being in how each term is serialized into JSON for convenience and ease of use &#8211; and that there&#8217;s no real required elements. Don&#8217;t forget that each &#8220;item&#8221; is a discrete unit returned from an API and represents &#8220;whatever&#8221; &#8211; a Flickr photo, an Amazon product</p>
<ul>
<li><code>title</code> (string, plain text) &#8211; the title; this is a plain text string, i.e. no entities or HTML allowed</li>
<li><code>id</code> (string, plain text) &#8211; a unique ID (in the context of the API being called) for this result</li>
<li><code>content</code> (string, HTML) &#8211; the complete text; this is HTML</li>
<li><code>summary</code> (string, HTML) &#8211; the summary text; this is HTML.</li>
<li><code>link</code> (string, URL) &#8211; this is the &#8220;main&#8221; link of whatever the item represents, a page on Amazon, a blog post&#8217;s original HTML and so forth</li>
<li><code>links</code> (array of dictionary) &#8211; these are other links related to the item; the format is documented below</li>
<li><code>category</code> (array of dictionary) &#8211; tags/categories; the format is documented below</li>
<li><code>author</code> (a string or dictionary) &#8211; if a dictionary, the format is documented below</li>
<li><code>updated</code> (string, Atom datetime format) &#8211; when the item was last updated</li>
<li><code>posted</code> (string, Atom datetime format) &#8211; when the item was originally posted; if using <code>updated</code> and/or <code>posted</code>, always use <code>updated</code> and then use <code>posted</code> only if you have a meaningful difference.</li>
</ul>
<h4>Links Format</h4>
<p><code>links</code> are results related to the item. The most important link should be encoded in the <code>link</code> item. <code>links</code> are a list of dictionary, each dictionary containing (<a href="http://atomenabled.org/developers/syndication/#link">further documentation</a>):</p>
<ul>
<li><code>href</code> (string, URI)</li>
<li><code>rel</code> (string, enumeration)</li>
<li><code>type</code> (string, MIME type)</li>
<li><code>hreflang</code> (string, language code)</li>
<li><code>title</code> (string, plain text)</li>
<li><code>length</code> (string, integer)</li>
</ul>
<h4>Category Format</h4>
<p><code>category</code> are the tags for the item, and are a list of a dictionary each dictionary containing (<a href="http://atomenabled.org/developers/syndication/#category">further documentation</a>):</p>
<ul>
<li><code>@</code> (string, plain text) &#8211; the tag</li>
<li><code>rel</code> (string, from enumeration)</li>
<li><code>scheme</code> (string, URI)</li>
</ul>
<h4>Author Format</h4>
<p>The author can be encoded as a string (containing the author&#8217;s name) or as a dictionary, or as a list of dictionaries. If a dictionary, this is how it should be encoded (<a href="http://atomenabled.org/developers/syndication/#person">further documentation</a>)</p>
<ul>
<li><code>@</code> (string, plain text) &#8211; the author&#8217;s name</li>
<li><code>uri</code> (string, URI)</li>
<li><code>email</code> (string, email address)</li>
</ul>
<h4>Example</h4>
<p>This is a API result from <a href="http://www.whitepages.com/landing/api">Whitepages.com</a>, encoded as AUAPI. I have removed non-Atom items and shortened long text for clarity.</p>
<pre>{'content': "&lt;div class="vcard">\n&lt;div class="fn">Jack Smith&lt;/div>...\n&lt;/div>\n",
 'id': '40b296d1a95f3b379a8108b27daf009c',
 'links': [{'href': 'http://www.whitepages.com/16176/t...',
            'rel': 'related',
            'title': 'Find Neighbours',
            'type': 'text/html'},
           {'href': 'http://www.whitepages.com/16176/track...',
            'rel': 'related',
            'title': 'Map',
            'type': 'text/html'},
           {'href': 'http://www.whitepages.com/16...',
            'rel': 'related',
            'title': 'Map',
            'type': 'text/html'},
           {'href': 'http://www.whitepages.com/16176/track/102...',
            'rel': 'alternate',
            'title': 'Whitepages.com',
            'type': 'text/html'}],
 'title': u'Jack Smith'}</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2009/02/28/auapi-the-atom-core-vocabulary-for-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing The Almost Universal API</title>
		<link>http://code.davidjanes.com/blog/2009/02/27/introducing-the-almost-universal-api/</link>
		<comments>http://code.davidjanes.com/blog/2009/02/27/introducing-the-almost-universal-api/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 14:54:32 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[auapi]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=490</guid>
		<description><![CDATA[The Almost Universal API is a culmination &#8211; or at least a local maxima &#8211; of several projects I&#8217;ve been working on for the last few months: in particular, Web Object Records, Pipe Cleaner and PyBM. The AUAPI is: a way of presenting results returned from many popular APIs a Python library to actual do [...]]]></description>
			<content:encoded><![CDATA[<p>The Almost Universal API is a culmination &#8211; or at least a local maxima &#8211; of several projects I&#8217;ve been working on for the last few months: in particular, <a href="http://code.davidjanes.com/blog/category/work/">Web Object Records</a>, <a href="http://code.davidjanes.com/blog/category/pipe-cleaner/">Pipe Cleaner</a> and <a href="http://code.davidjanes.com/blog/category/pybm/">PyBM</a>. The AUAPI is:</p>
<ul>
<li>a way of presenting results returned from many popular APIs</li>
<li>a Python library to actual do this</li>
</ul>
<p>I&#8217;ll be making several posts about how to use the AUAPI, including installation instructions. The plan is to make an <a href="http://pypi.python.org/pypi/setuptools">easy_install</a> version, but initially this will be a SVN from <a href="http://code.google.com/">Google Code</a> thing.</p>
<p>The AUAPI is mainly about how to present results returned from APIs, not how to send data to APIs nor how to encode requests. The encoding is designed to &#8220;look good&#8221; in JSON and be easily and algorithmically encoded into XML. The AUAPI data model is based on:</p>
<ul>
<li><a href="http://atomenabled.org/developers/syndication/">Atom</a>, the &#8220;core&#8221; vocabulary, particularly providing <code>title</code>, <code>content</code>, <code>summary</code>, <code>updated</code>, <code>category</code>, <code>link</code> and links</li>
<li><a href="http://search.yahoo.com/mrss/">MediaRSS</a>, for encoding images</li>
<li><a href="http://microformats.org/wiki/hcard">hCard</a>, for encoding information about people</li>
<li><a href="http://microformats.org/wiki/hcalendar">hCalendar</a>, for encoding information about events</li>
</ul>
<p>There are several &#8220;maybe&#8221; standards too:</p>
<ul>
<li><a href="http://microformats.org/wiki/hproduct">hProduct</a>, for encoding information about things</li>
<li><a href="http://code.google.com/p/google-sgnodemapper/">Google&#8217;s SGN</a> URLs, for providing a universal way of talking about accounts</li>
</ul>
<p>I have already worked a fair number of APIs into the AUAPI. These are documented on the <a href="http://www.mashematica.com/wiki/Quick_Reference">Mashematica</a> Wiki:</p>
<ul>
<li> <a title="Api csv" href="http://www.mashematica.com/wiki/Api_csv">api_csv</a> &#8211; download and interpret CSV documents</li>
<li> <a title="Api delicious" href="http://www.mashematica.com/wiki/Api_delicious">api_delicious</a> &#8211; get information from Delicious.com API</li>
<li> <a title="Api download" href="http://www.mashematica.com/wiki/Api_download">api_download</a> &#8211; download HTML, XML and JSON documents</li>
<li> <a title="Api feed" href="http://www.mashematica.com/wiki/Api_feed">api_feed</a> &#8211; download Atom and RSS feeds</li>
<li> <a title="Api feeds" href="http://www.mashematica.com/wiki/Api_feeds">api_feeds</a> &#8211; find feeds on a page</li>
<li> <a title="Api foaf (not yet written)" href="http://www.mashematica.com/wiki/index.php?title=Api_foaf&amp;action=edit&amp;redlink=1">api_foaf</a> &#8211; read FOAF files</li>
<li> <a title="Api flickr (not yet written)" href="http://www.mashematica.com/wiki/index.php?title=Api_flickr&amp;action=edit&amp;redlink=1">api_flickr</a> &#8211; Flickr API</li>
<li> <a title="Api geocode" href="http://www.mashematica.com/wiki/Api_geocode">api_geocode</a> &#8211; geocode</li>
<li> <a title="Api google" href="http://www.mashematica.com/wiki/Api_google">api_google</a> &#8211; get information from Google AJAX Search API</li>
<li> <a title="Api lastfm (not yet written)" href="http://www.mashematica.com/wiki/index.php?title=Api_lastfm&amp;action=edit&amp;redlink=1">api_lastfm</a> &#8211; return results from Last.fm</li>
<li> <a title="Api microformat" href="http://www.mashematica.com/wiki/Api_microformat">api_microformat</a> &#8211; get microformatted information on a page</li>
<li> <a title="Api opml" href="http://www.mashematica.com/wiki/Api_opml">api_opml</a> &#8211; download OPML documents</li>
<li><a title="Api whitepages" href="http://www.mashematica.com/wiki/Api_whitepages">api_whitepages</a> &#8211; look up phone numbers</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2009/02/27/introducing-the-almost-universal-api/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

