Describing REST APIs with HTML5 forms

There are several options for describing APIs in a way that machines and/or people can read: WSDL files (mostly used with SOAP), OpenSearch description files, YQL Open Data Tables, etc.

I had a theory that REST APIs could be sufficiently described — in a way that both machines and people can understand — using HTML5 forms.

Here's an example, describing the NCBI's ESearch API (part of EUtils):

This makes use of several new or modified HTML5 attributes on input and select elements: "type", "required", "pattern", "placeholder" and "autofocus".

The description needs to be able to define:

  • which fields are available ("name")
  • their default values ("selected")
  • whether values are required ("required")
  • hints for when required fields are not filled ("title")
  • what type of data is in each field ("type")
  • patterns to validate the data in each field ("pattern")
  • possible options for each field, when the set of options is limited ("select/option")
  • human-readable descriptions of each field ("label")
  • suggested values or hints for the formatting of fields ("placeholder")
  • dependencies between different fields ("optgroup", "class")

Still needed: a way to express dependencies between fields (e.g. "either this or these are required").

Deliberately missing: any definition of the structure or semantics of the response.

Here's another example, for EFetch. This one is missing optgroup elements, while I investigate the different combinations of parameters.

The Top Google Search Result for each Unicode Character

The result of running a Google search for each Unicode character and storing the top result: The Top Google Search Result for each Unicode Character.

Up to 14000, so far (it's a large file, might take a while to load).

Listing Unicode Characters

A list of all the Unicode characters.

PHP source.

It's essentially just this, but paginated:

<?php foreach (range(1, 200000) as $i): ?><li>&#<?php print $i; ?>;</li><?php endforeach; ?>

It would have been good to use @font-face and its unicode-range attribute, to specify different fonts for different ranges of Unicode characters, but there don't seem to be many Unicode fonts available for linking and Firefox doesn't support unicode-range yet.

Spotify Playlist: The Hype Machine Top 1000 Albums of 2009

A 7059 track, 2.8 week Spotify playlist containing as many as possible of the Top Albums of 2009, in roughly descending order, as compiled by Hype Machine (the original data is at the bottom of that page).

Shuffle!

On A Bus updated

The mobile version of On A Bus has been updated. It now uses Google Maps API v3, which is the best API ever, and the W3C geolocation API for showing your current location (so it works in any browser/mobile device that supports this API).

It's also nice and HTML5-y, so can be installed as an iPhone app using "Add To Home Screen".