cURL

For those more comfortable with the command line than with a web interface, you can instead make HTTP requests directly to CouchDB using cURL. Use cURL’s -X switch to specify the GET, POST, PUT, or DELETE HTTP method in your request to the specified URL (the default HTTP method is GET). Here is an example of using cURL to GET information about your CouchDB install (the GET HTTP method is specified for clarity even though it is the default):

curl -X GET http://localhost:5984/

The response:

{"couchdb":"Welcome","version":"1.1.0"}

Using cURL is a great way to familiarize yourself with CouchDB’s HTTP API. Your application will make HTTP requests to CouchDB just like cURL does. You will likely not build an application using cURL since it could involve a lot of typing at the command line. Many platforms and programming languages have libraries that will make interacting with CouchDB easier. You can use either an HTTP client library or a library specifically designed to work with CouchDB. Using cURL gives you a glimpse into the features that these libraries will make available to you.

Note

Creating and updating design documents (covered in Chapter 3) using cURL can be difficult and time-consuming. There are several tools available that can help with this. The Python version of the CouchApp command line tool is the most commonly used. There's also a Node.js version of the CouchApp command line tool called node.couchapp.js and a Ruby command line tool called soca. Note that not all of these tools may be compatible with one another.

Get Writing and Querying MapReduce Views in CouchDB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.