Cloudant logo
Documentation

alt tag API Reference

The Cloudant API reference is intended to be a comprehensive and living catalog of Cloudant’s capabilities. Contributions are welcome through Cloudant Labs on GitHub. The API reference content is built with Slate.

For the cURL samples

There are three ways you can supply the username and password data for a request.

  1. The -u $USERNAME parameter on its own causes cURL to ask you to enter your password interactively on the command line before performing the request. This option is used for the cURL examples in the Cloudant API reference.

  2. [Caution: This option is not secure] Entering the combination parameter -u $USERNAME:$PASSWORD as part of your command means that you are not asked to enter your password interactively. However, a plain text copy of your password appears in the terminal log.

    A variation of this method requires you to define a curl control file, containing the following details:
    --user "$USERNAME:$PASSWORD"
    --globoff
    --proto "=https"
    You can then define an ‘alias’ that enables the curl command to apply the control file, for example:
    alias acurl="curl -s --config <full_path_and_name_of_config_file> "
    Remember to exclude the control file from backups, as it contains the password in clear text.

  3. [Caution: This option is not secure] For an https cURL request, you can supply the username and password as part of the URL:
    ... https://$USERNAME:$PASSWORD@$USERNAME.cloudant.com ...
    However, a plain text copy of your password appears in the terminal log.

An alternative approach is to use a hashed version of your username and password combination and supply that data in your cURL command. The Cloudant Blog article Authorized curl, a.k.a acurl explains how to create a more complexacurl command that makes use of this technique, enabling you to enter commands such as:
acurl https://$USERNAME.cloudant.com