DRY up your API with microformats

Most API developers face the problem of multiple representation of the same resource. ie

  • HTML/XHTML for humans
  • JSON/XML for Servers
  • iCal for Calenders
  • etc

This is not only a technical challenge wasting developer hours but also a fertile ground for bugs. Wouldn’t it be nice if we could have representations that both humans and machines could understand?

You guessed it! microformats

According to their wiki, microformats can be described as.

Designed for humans first and machines second, microformats are a set of simple, open data formats built upon existing and widely adopted standards. Instead of throwing away what works today, microformats intend to solve simpler problems first by adapting to current behaviors and usage patterns.

Microformats work by embedding in existing html eg

<!--Example lifted from http://microformats.org/wiki/hcard-->
<div class="vcard">
 <a class="url fn" href="http://tantek.com/">Tantek Çelik</a>

Thus a parser would be able to pick out the details it needs and when rendered in a browser a user would just see it as normal clickable link.

I know by now you may not be feeling too eager to spend even more time learning a new technology but I think this one is definately worth it. And not just because microformats already power over 70% of standard web formats.

Benefits of htags

Engaging features

With microformats you get active features for free for example

  • hcard Enables your users to quickly save your details in their phonebooks
  • hCalender Your users can add your events to calendars.

Search results

SEO is very important to most if not all businesses with an online presence. Microformats can greatly assist you with this task as well.

  • hProduct Standard formats are easy on search engines and can enable comparison sites work for you.
  • hRecipe The market for recipes is bigger than most people think. In fact google has a search engine for recipes Google Recipe
  • hResume for seekers and employers
  • hReviews for re viewable products, services, businesses, events, etc
  • Check out more formats available at Microformats wiki

Developer productivity

Bill gates is famously quoted

I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it.

I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it.

Well microformats is the tool for the lazy developer.

  • It is easier to build
  • Minimize duplication of content
  • Far more user friendly than XML or even JSON for both developers and end users.
  • Provides facilities for extension such as rel-me rel-author rel-license

I hope I have whetted your appetite and you will take the time to master this awesome tool.

Till next time, happy coding!


Published by


Software Project Manager