Last Updated: February 25, 2016
·
4.648K
· jsimon

How to list design documents and views on couchbase via the REST API

if you just want to go down to the source:
a simple gist
else:
Stick around, I hope you enjoy it...

The REST API

We are using 2 query points, the first

To retrieve information for all buckets in a cluster

curl http://localhost:8091/pools/default/buckets

The first query returns a json encoded array of objects so we want to read

foreach response as bucket
    print bucket.name

And the second

To retrieve the design documents for the specified bucket

curl http://localhost:8091/pools/default/buckets/{bucket_name}/ddocs

Now that we've queried the Design Document for that bucket, we get the Design Document's name, the revision number, and the views that live inside of it.

Told you it was pretty simple,
if you're having troubles understanding the json encoded response, head here and paste the response there for a nice formatting.

Special thanks to @avsej and @scalabl3 for all the help :D

1 Response
Add your response

if you're making your REST call from an environment that has 'python' installed (linux, for one), you can pipe all of your curl output into python to reformat the output like:

curl http://localhost:8091/pools/default/buckets/{bucket_name}/ddocs | python -mjson.tool

over 1 year ago ·