Enterprise Integration Zone is brought to you in partnership with:

Lorna Jane Mitchell is a PHP developer, blogger, trainer and evangelist from Leeds in the UK. She is active with phpwomen.org and her local user group PHP North West, and writes for a variety of outlets, including her own blog at lornajane.net. She is an active member of the PHP and open source communities and contributes to the joind.in event feedback project. When she's not at her computer, Lorna enjoys yarn craft, hobby electronics, and her home renovation project. Lorna is a DZone MVB and is not an employee of DZone and has posted 82 posts at DZone. You can read more from them at their website. View Full User Profile

API Documentation with IODocs

  • submit to reddit

I write a lot of APIs, and I also preach that your API isn't finished until it has excellent documentation. Which is great, but that means I therefore have to lead by example and document my APIs. Enter iodocs from the talented folks at Mashery.

Iodocs is a node.js application (which is fun for a PHP developer. Most developers write a bit of JS, but this one hasn't). You describe your API and all its methods in JSON, and then iodocs presents an interface for you to enter API keys, add parameters to each request and press the "try it!" button. This makes your API call and shows you the results on screen, which seems like a great way to demonstrate what all the various parameters do!

iodocs screenshot

The setup and installation was pretty straightforward - node.js apps all have a packages.json file which states their dependencies and the npm package manager knows what to do. So you just grab the app from github and npm install and it pretty much worked. I had a problem with an older version of node.js (I had 0.8.2, when I upgraded to 0.8.9 it was all fine) but I figured it out.

I like the iodocs as a way of showing to the user what you can do with the API before they have to settle down and write some code. For example, on joind.in, you can request lists of events using various criteria, and iodocs presents form fields for that:

iodocs screenshot

If you want to have a play, I deployed this to heroku (blog post coming on that too, if you like) so you're welcome to click around: http://lornajane-iodocs.herokuapp.com/joindinv2. There are descriptions of other APIs too, and I've seen a few sites using this (which is where I came across it). The big stumbling block at the moment is the lack of OAuth2 support (as both joind.in and github use this, I'd quite like it!) but the mashery devs have promised to get back to me on that so watch this space ...

Published at DZone with permission of Lorna Mitchell, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)