REST API basics

The REST API exposes a number of endpoints. This tutorial focuses on the following five endpoints:

Endpoint

What you can do with it

/documents

manage document content and metadata

/search

search using a string-based or structured query

/values

retrieve values and aggregates of values

/config/query

configure options for /search, /keyvalue, and /values

For the full list of endpoints, see the Client API reference.

The version of the API (v1) appears as a prefix to the endpoint. For example, to search for "apple" across all documents, you'd make a GET request to:

http://localhost:8011/v1/search?q=apple

Since you haven't loaded any documents yet, this search will yield empty results. If you click the link, you'll see the (empty) results are in XML format. You also have the option of getting the results in JSON format instead:

http://localhost:8011/v1/search?q=apple&format=json

This is true for all five of the above endpoints. You can use the format parameter to indicate which format you want the results in—json or xml (the default).

You could also make the above request using cURL (or wget), specifying the user and password on the command line. Copy and paste the following command and run it on the command line:

That's exactly how we'll be making PUT, POST, and DELETE requests in this tutorial. But for GET requests, we'll often just show the link itself, since it's so convenient to use the browser for these.

Setup

CRUD

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.