MarkLogic APIs…

In addition to my new JavaScript MarkLogic driver for NodeJS, there are a range of other API available. In this post I list some of them, and what they could be used for.

Out of the Box


The MarkLogic REST API is a new addition in MarkLogic 6. This is an XQuery application that exposes a set of REST endpoints. There is also native support for JSON thanks to this layer. This API is intended to be used as a simple to understand yet powerful base for other API to be built on. Think of this layer as MarkLogic’s wire protocol. It is very lightweight and exposes some key functionality to make developers’ lives easier. An example of this is the ability to change a parameter (?format=json|xml) or the content Accept header to specify whether you want XML or JSON output. Also included is advanced searching and importantly search paging, which is always normally a pain to add to any application layer.


You’ve probably all been indoctrinated that NoSQL databases ‘don’t do SQL’. Well, any software vendor that doesn’t support SQL would say that, wouldn’t they? Happily, MarkLogic can stand astride the religious SQL debate like an adonis, thanks to it’s ability to expose a set of SQL like views to ODBC clients. This is thanks to the ODBC server type in MarkLogic 6. The usefulness of this capability cannot be overestimated. Ever dreaded creating a datamart for your Relational databases because of the inherent hassle? Well, no need to do that for MarkLogic. Just expose the indexes within a set of views, and all of a sudden you have a relational window in to a document driven world. All without a separate, 24 hours out of date, datamart layer. Simples.


MarkLogic’s original API set are still useful, powerful and have a range of other tools built on top of them. The biggest of these is the XCC layer. This open standard (XDBC) was part developed by MarkLogic as the document database version or ODBC. The XCC drivers use this as a wire protocol to access MarkLogic. The main drawback of the XCC libraries was that they were quite low level, and required Java and .NET developers to pass in XQuery. Clearly not ideal, which is why the REST API forms the basis for the new Java API. Still useful API though if you have tools dependant upon them (Like MLCP, XQSync, RecordLoader, et al)

Java API

With the REST API in version 6.0 came the desire to use this API within a Java wrapper. Such a wrapper should be instantly useable by any Enterprise Java developer. This is exactly what MarkLogic achieved in version 6.0 with the ‘new’ Java API (Think ‘New iPad’ being used alongside the existing iPad). You may think that using the REST API as an intermediate layer would be a problem for performance, but internal testing revealed a <1% performance hit compared to the existing (aka ‘old’) Java API. Given the development strengths I would recommend this API to any Java shop.

Openly Available Extensions

Intro How-To:
Language: PHP 5.3+
Latest Version: 30 Nov 2012
Platform: N/A
MarkLogic Version: 6.0+ (REST API)

Intro How-To:
Language: JavaScript
Latest Version: 0.2.0 (23 Dec 2012)
Platform: NodeJS
MarkLogic Version: 6.0+ (REST API)

This is a NodeJS database ‘driver’ I created in a week. It’s akin to (but of course better, being MarkLogic) the couchdb and mongodb drivers you get. It is fully event orientated, and sticks as close to NodeJS’ own principles and conventions as possible. It’s designed to require no specific MarkLogic knowledge or training, and will work against a vanilla MarkLogic server install on the same machine with zero configuration changes.

Intro How-Tos:
Language: XQuery
Latest Version: 15 Oct 2012
Platform: MarkLogic App Server
MarkLogic Version: 4.1+

This was an OpenSource attempt at providing a REST API on version 5.x. It proved very popular, hence the inclusion of a supported REST API in version 6.0. Many tools were layered on top of this API in much the same way as the new REST API. (I’ve always wondered if this was a relation to the line of ‘DOS Beer’ jokes)

Active Document
Language: Ruby
Latest Version: Jan 2012 (Watch this space: Current development being carried out so this works against the MarkLogic V6 REST API. See the REST branch.)
Platform: Ruby GEM
MarkLogic Version: 5.0+ (via Corona)

This is an implementation akin to ActiveRecord on Ruby, but for Document databases. This uses the Corona API for access to MarkLogic 5+.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.