Chapter 4. CouchDB API

Table of Contents

4.1. Request Format and Responses
4.2. HTTP Headers
4.2.1. Request Headers
4.2.2. Response Headers
4.3. JSON Basics
4.4. HTTP Status Codes
4.5. CouchDB API Overview

The CouchDB API is the primary method of interfacing to a CouchDB instance. Requests are made using HTTP and requests are used to request information from the database, store new data, and perform views and formatting of the information stored within the documents.

Requests to the API can be categorised by the different areas of the CouchDB system that you are accessing, and the HTTP method used to send the request. Different methods imply different operations, for example retrieval of information from the database is typically handled by the GET operation, while updates are handled by either a POST or PUT request. There are some differences between the information that must be supplied for the different methods. For a guide to the basic HTTP methods and request structure, see Section 4.1, “Request Format and Responses”.

For nearly all operations, the submitted data, and the returned data structure, is defined within a JavaScript Object Notation (JSON) object. Basic information on the content and data types for JSON are provided in Section 4.3, “JSON Basics”.

Errors when accessing the CouchDB API are reported using standard HTTP Status Codes. A guide to the generic codes returned by CouchDB are provided in Section 4.4, “HTTP Status Codes”.

When accessing specific areas of the CouchDB API, specific information and examples on the HTTP methods and request, JSON structures, and error codes are provided. For a guide to the different areas of the API, see Section 4.5, “CouchDB API Overview”.