This great blog post by Evan Lenz gives a good introduction to the REST API, and explains how the MarkLogic 6 web widgets in Application Builder use it to provide a rich and agile AJAX application. Well worth looking over, especially for those contemplating using the REST API or writing their own widgets.