Javatpoint Logo
Javatpoint Logo

CouchDB Curl

There are two ways to communicate with CouchDB:

  • CouchDB cURL
  • CouchDB Fauxton

CouchDB cURL utility is used to communicate with CouchDB database. This tool is used to transfer data from or to a server by using one of the supported protocols like (HTTP, HTTPS, FTP, FTPS, TFTP, DICT, TELNET, LDAP or FILE). This command is designed to work without user interaction. cURL offers a busload of useful tricks like proxy support, user authentication, ftp upload, HTTP post, SSL (https:) connections, cookies, file transfer resume and more.

The cURL utility is available for operating systems such as UNIX, Linux, Mac OS X and Windows. It is a command-line utility to access HTTP protocol straight away from the command line.


Using cURL Utility

You can use cURL utility to access any website by using curl command followed by a website address.

For example:

CouchDB Curl 1

cURL Utility Options

cURL utility provides various options to work with, and you can see them in cURL utility help.

The following code shows some portion of cURL help.

CouchDB Curl 2

Following is a list of mostly used cURL utility options used by CouchDB:

-X flag: While communicating with an HTTP server, -X flag facilitates users to specify a request method (GET, POST, PUT etc.) to override the default method(GET).

While communicating with an FTP server, -X flag facilitates users to specify FTP command to override the default command(LIST).

-H: The H flag specifies a custom header to pass on to the server.

For example: If you send a file to the server, you have to use the "content type" that defines the type of content of the file that you want to upload.

-d flag: This flag is used to send data along with the HTTP POST request to the server as it is filled by the user in the form and submitted.

-o flag: -o flag facilitates cURL to write the output of the request to a file.

For example:

The following example specifies the use of -o flag of cURL utility.

CouchDB Curl 3

This example takes the source code of the homepage of javatpoint.com, creates a file named example.com and saves the output in the file named example.html.

CouchDB Curl 4

-O: The O flag is similar to ?o flag but the only difference is that, a new file with the same name as the requested url was created, and the source code of the requested url will be copied to it.

CouchDB Curl 5

Hello CouchDB Example

CouchDB's homepage can be accessed by two ways:

  • By using the url at browser.
  • By command prompt.

Access CouchDB's homepage by sending GET request: First of all make sure you have installed CouchDB in your Linux environment and it is running successfully, use the following syntax to send a get request to the CouchDB instance.

CouchDB Curl 6




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA