-
Notifications
You must be signed in to change notification settings - Fork 71
REST API
Jens Alfke edited this page Aug 30, 2024
·
13 revisions
The LiteCoreREST library adds a small embedded HTTP server to LiteCore, which implements a subset of the Couchbase Lite 1.x (and CouchDB and Cloudant and PouchDB) REST API. You can easily run this by using the cblite tool's serve
subcommand.
Again, this is not the full REST API; it doesn't expose all functionality, it's not enough for Cordova/PhoneGap, and it's not enough for compatibility with the 1.x (or CouchDB or PouchDB) replicator. But it has some uses:
- Automated testing of LiteCore
- Load testing of Sync Gateway (by starting a bunch of
cblite serve
processes to replicate with it) - Automated creation of Couchbase Lite 2 database files from a server, to be bundled into apps
(If you want to cross-reference with the actual code, look at where the handlers are registered in Listener.cc.)
Method | Path | Parameter | Description |
---|---|---|---|
GET | / | Server info, like the version | |
GET | /_all_dbs | List of all database names | |
POST | /_replicate | Start a replication; parameters in JSON body. [See note below] | |
GET | /_active_tasks | Info on active replications | |
GET | /db | Database doc count, current sequence, etc. | |
DELETE | /db | Deletes a database | |
PUT | /db | Creates a database | |
POST | /db | Creates a document with an automatically generated UUID | |
GET | /db/_all_docs | List of documents including current revID | |
?include_docs=true | Adds body of each doc | ||
POST | /db/_bulk_docs | Creates/updates/deletes multiple documents | |
GET | /db/id | Returns document body | |
?rev=revID | Revision ID to get (optional) | ||
DELETE | /db/id | Deletes a document | |
?rev=revID | Current revision ID (required) | ||
PUT | /db/id | Creates or updates a document | |
?rev=revID | Current revision ID (required if doc exists, unless you add a _rev property to the JSON body) |
- All HTTP endpoints and "
?
" options not listed above like_changes
,_bulk_get
, ... - Access to revision history
- Attachments
-
/_replicate
properties other thansource
,target
,continuous
, andcancel
- Local-to-local replication (where both
source
andtarget
are local db names) - Queries (obviously there are no views or design docs, but eventually it'd be nice to be able to POST a query in the JSON syntax or N1QL.)