The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


CouchDB::Client - Simple, correct client for CouchDB


    use CouchDB::Client;
    my $c = CouchDB::Client->new(uri => 'https://dbserver:5984/');
    $c->testConnection or die "The server cannot be reached";
    print "Running version " . $c->serverInfo->{version} . "\n";
    my $db = $c->newDB('my-stuff')->create;
    # listing databases


This module is a client for the CouchDB database.



Constructor. Takes a hash or hashref of options: uri which specifies the server's URI; scheme, host, port which are used if uri isn't provided and default to 'http', 'localhost', and '5984' respectively; json which defaults to a JSON::Any object with utf8 and allow_blessed turned on but can be replaced with anything with the same interface; and ua which is a LWP::UserAgent object and can also be replaced.


Returns true if a connection can be made to the server, false otherwise.


Returns a hashref of the server metadata, typically something that looks like { couchdb => "Welcome", version => "0.8.0-incubating"}. It throws an exception if it can't connect.


Returns a new CouchDB::Client::DB object for a database of that name. Note that the DB does not need to exist yet, and will not be created if it doesn't.


Returns an arrayref of all the database names that the server knows of. Throws an exception if it cannot connect.


Same as above but returns an arrayref of CouchDB::Client::DB objects instead.

dbExists $NAME

Returns true if a database of that name exists, false otherwise.


You will use these at your own risk


$METHOD is the HTTP method to use; $PATH the part of the path that follows scheme://host:port/; and $CONTENT a Perl data structure. The latter, if present, is encoded to JSON and the request is made using the given method and path. The return value is a hash containing a boolean indicating success, a status being the HTTP response code, a descriptive msg, and a json field containing the response JSON.

uriForPath $PATH

Gets a path and returns the complete URI.


Robin Berjon, <robin @t berjon d.t com>


Please report any bugs or feature requests to bug-couchdb-client at, or through the web interface at


Copyright 2008 Robin Berjon, all rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.