To communicate with CouchDB one can either choose:
- CouchDB Curl
- CouchDB Fauxton
But to communicate with the CouchDB database to transfer data from or to a server, CouchDB Curl utility is needed. It is a command-line utility. It thus accesses the HTTP protocol straight away from the command line. It uses protocols like HTTP, HTTPS, FTP, FTPS, TFTP, DICT, TELNET, LDAP or FILE for communication. Being designed to work without user interaction it offers many useful tricks. Some of the tricks include proxy support, user authentication, SSL (https:) connections, cookies, FTP upload, HTTP post and file transfer resume. All the popular operating systems like UNIX, Linux, Mac OS X and Windows supports the Curl utility.
To use Curl Utility:
Use the curl command followed by the desired website address.
Curl Utility Options:
The Curl Utility Options can be checked at Curl utility help.
$ curl ?help
Popular Curl Utility Options used by CouchDB are:
It facilitates the users to specify a request method like the GET, POST and PUT while communicating with an HTTP server, to override the default method i.e, the GET method. It also facilitates the users to specify the FTP command while communicating with an FTP server, to override the default command i.e, the LIST command.
It defines a custom header to pass on to the server. For example, a “content-type” header to define the type of content of the file to be uploaded.
It sends data along with the HTTP POST request to the server.
It facilitates the writing of the output of the request to a file.
curl -o example.html www.codesjava.com/index.html
After the execution of the above command, the source code of the homepage of example_site.com will be taken, a file named example.com will be created and the output will be saved in the example.html file.
It also facilitates the writing of the output of the request to a file, similar to the -o flag, but unlike the -o flag, it creates a new file with the same name as the requested URL. The source code of the requested URL will be then copied to the file created.
curl -O www.codesjava.com/index.html
Hello CouchDB Example:
To access the CouchDB’s homepage one can either:
- Use the URL at browser.
- Use the command prompt.
To access the CouchDB’s homepage follow the below steps:
- Ensure the successful installation of CouchDB in the Linux environment.
- Send a get request to the CouchDB instance to access CouchDB’s homepage: