CouchDB HTTP API
HTTP requests are used to communicate with CouchDB.
By using these requests we can-
HTTP Request Formats
There are different request formats used with Database while communicating. These request formats are: get, head, post, put, delete, and copy.
See the different request formats of HTTP Protocol used to communicate with CouchDB.
GET : The GET request format is used to get a specific item. To get different items, you have to send specific url patterns. In CouchDB using this GET request, we can get static items, database documents and configuration, and statistical information in the form of JSON documents.
HEAD : The HEAD method is used to get the HTTP header of a GET request without the body of the response.
POST : The Post request is used to upload data. In CouchDB , the POST request is mainly used to set values, upload documents, set document values, and can also start certain administration commands.
PUT : The PUT request is used to create new objects, databases, documents, views and design documents.
DELETE : The DELETE request is used to delete documents, views, and design documents.
COPY : The COPY method is used to copy documents and objects.
HTTP Request Headers
HTTP headers should be supplied to get the right format and encoding. HTTP request headers are sent along with the request while sending the request to the CouchDB server. Following are the different Http request headers.
Content-type : The content-type Header is used to specify the content type of the data that we supply to the server along with the request. Mostly the type of the content we send along with the request will be MIME type or JSON (application/JSON). Using Content-type on a request is highly recommended.
Accept : The Accept header is used to specify the server, the list of data types that client can understand, so that the server will send its response using those data types. Generally here, you can send the list of MIME data types the client accepts, separated by colons.
In CouchDB, using Accept in queries is not required but it is highly recommended to ensure that the data returned can be processed by the client.
HTTP Response Headers
The HTTP response headers are a type of response sent by the server. These headers give information about the content send by the server as response.
There are 4 types of response headers:
Content-type : The content-type response header specifies the MIME type of the data returned by the server. For most requests, the returned MIME type is text/plain.
Cache-control : The Cache-control response header is used to suggest the client about treating the information sent by the server. CouchDB mostly returns the must-revalidate, which indicates that the information should be revalidated if possible.
Content-length : The content-length header is used to fetch the length of the content sent by the server, in bytes.
Etag : The Etag header is used to show the revision for a document, or a view.
Status Codes of HTTP Headers
The following table specifies the status codes sent by the http headers and their working:
HTTP URL paths to interact with database
Following is a list of some URL paths which are used to interact with the database directly.