Document query API

Closes #48.