couchdbcouchdb-futon

Custom rest api's for CouchDB?


I have been googling around trying to find examples or just a straight answer to my question. Is it possible to create/extend my own custom api endpoints for couchDB? Such as for example can I create a api call like http://127.0.0.1:5984/database/FillDatabase/... to fill the database with data?

If couchDB does indeed provide this functionality, then please provide me with a link perhaps to some tutorial/guide/example if possible. Thanks.


Solution

  • You may want the _rewrites feature, which allows any view to rewrite an incoming URL for that database.

    However, for root-level APIs, and for ease of customization, it is considered better to impose a web engine in front of CouchDB (nginx, a node.js server, etc.). _rewrites is flexible enough to simplify the API for a specific db, but it's not intended to handle all incoming requests, and can quickly become unwieldy.

    You would also be limited to the work that CouchDB can handle - for example, the FillDatabase custom API would need to conform to the bulk API.