CouchDB – View/GET Document

To view or get a document from CouchDB database, you can either use CouchDB Web Interface or REST API. We will go through each of the methods to get the document details.

GET Document via REST API

Send a HTTP GET request with the following URL.

http://hostname/database_name/document_id/

We have our CouchDB running in our localhost. Hence, we shall use 127.0.0.1:5984 as hostname.

We will use an existing database named tutorialkart.

Let us get document with id 0005.

The resulting request URL that we have to use for PUT request will become,

http://127.0.0.1:5984/tutorialkart/0005/

We will use Postman, to trigger a GET request with the URL to create a document in CouchDB Database. You can use any other CLI or GUI tool of your choice.

ADVERTISEMENT
CouchDB - GET document

The response contains the document as JSON.

View Document via CouchDB Web Interface

You can also view document in CouchDB database using Web Interface.

Open URL http://hostname/_utils/ in your browser. In this example, the URL will be http://127.0.0.1:5984/_utils/.

Click on Databases tab present in the left panel. Click on the database from which you would like to get the document details. Click on Create Document button.

Click on any of the view (say Table view) and click on the document.

When you click on the document, an editor will be opened with the JSON document.

Summary

In this CouchDB Tutorial, we learned to GET document of CouchDB database via HTTP REST API or view the document details using Web Interface provided by CouchDB.