GET /{db}/{doc}
This request retrieves a document from a database.
Request
Request headers
-
Accept—optional—Valid values are:- application/json
- multipart/mixed
- text/plain
-
If-None-Match—optional—Document revision identifier enclosed in double quotes
Query parameters
The following query parameters are all optional.
| Name | Type | Description | Default |
|---|---|---|---|
attachments
| Boolean | Include attachment bodies in response | false |
att_encoding_info
| Boolean | Include encoding information in attachment stubs if the attachment is compressed | false |
atts_since
| array | Include attachments only since specified revisions. Does not include attachments for specified revisions | none |
conflicts
| Boolean | Include information about conflicts in document | false |
deleted_conflicts
| Boolean | Include information about deleted conflicted revisions | false |
latest
| Boolean | Force retrieval of latest leaf revision, no matter what revision was requested | false |
local_seq
| Boolean | Include last update sequence number for the document | false |
meta
| Boolean | Acts same as specifying all conflicts, deletedconflicts and openrevs query parameters | false |
open_revs
| array | Retrieve documents of specified leaf revisions. You can specify the value all to return all leaf revisions | none |
rev
| string | Retrieve the specified revision of the document | none |
revs
| Boolean | Include a list of all known document revisions | false |
revs_info
| Boolean | Include detailed information for all known document revisions | false |
Response
The response contains a JSON document in the message body.
Response headers
-
Content-Type—The value can be:- application/json
- multipart/mixed
- text/plain; charset=utf-8
-
ETag—Document revision identifier contained in double quotes. -
Transfer-Encoding—This header appears when the request uses theopen-revsquery parameter. The value ischunked.
Message body
The message body contains the following objects in a JSON document.
| Name | Type | Description |
|---|---|---|
_id
| string | Document identifier |
_rev
| string | revision identifier |
_deleted
| Boolean | Indicates whether the document is deleted. Appears only when the document was deleted. |
_attachments
| object | Stubs for the attachments. Appears only when the document has attachments. |
_conflicts
| array | List of revisions with conflicts. Appears only when the request uses the conflicts=true query parameter. |
_deleted_conflicts
| array | List of revisions with conflicts that were deleted. Appears only when the request uses the deleted_conflicts=true query parameter. |
_local_seq
| integer | Sequence number of the document in the database. Appears only when the request uses the local_seq=true query parameter. |
_revs_info
| array | List of objects with information about local revisions and their status. Appears only when the request uses the open_revs=true query parameter. |
_revisions
| object | List of local revision identifiers. Appears only when the request uses the revs=true query parameter. |
Example
The following example retrieves a document with the identifier beer_#17_Cream_Ale from a database named beer-db. Because the identifier contains a number sign (#) character, the identifier must be URL encoded in the URI.
Request
GET /beer-db/beer_%2317_Cream_Ale HTTP/1.1
Host: localhost:59840
Response
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: must-revalidate
Content-Length: 259
Content-Type: application/json
Date: Thu, 12 Dec 2013 21:12:28 GMT
Etag: "1-431506b53aeac96a225e619cfa7bb569"
Server: CouchbaseLite 1.486
{
"category" : "North American Lager",
"brewery" : "Big Ridge Brewing",
"style" : "American-Style Lager",
"updated" : "2010-07-22 20:00:20",
"_id" : "beer_#17_Cream_Ale",
"_rev" : "1-431506b53aeac96a225e619cfa7bb569",
"name" : "#17 Cream Ale"
}
The following example retrieves a document with the identifier LemonChicken from a database named cookbook. It also uses the revs and revs_info query parameters to specify that the response includes information about the known document revisions.
Request
GET /cookbook/LemonChicken?revs=true&revs_info=true HTTP/1.1
Host: localhost:59840
Response
Status Code: 200 OK
Accept-Ranges: bytes
Cache-Control: must-revalidate
Content-Length: 848
Content-Type: application/json
Date: Fri, 11 Apr 2014 23:28:16 GMT
Etag: "4-51737756120a34de2d4981ab0f02c5a5"
Server: CouchbaseLite 1.495
{
"_id" : "LemonChicken",
"_revisions" : {
"ids" : [
"51737756120a34de2d4981ab0f02c5a5",
"6210945863a15ee7eff1e540133d19da",
"6847bbc089e24db84bd0371b9c169566",
"78abf9a6508671ba8338e4ef6daa910a"
],
"start" : 4
},
"_rev" : "4-51737756120a34de2d4981ab0f02c5a5",
"_revs_info" : [
{
"rev" : "4-51737756120a34de2d4981ab0f02c5a5",
"status" : "available"
},
{
"rev" : "3-6210945863a15ee7eff1e540133d19da",
"status" : "missing"
},
{
"rev" : "2-6847bbc089e24db84bd0371b9c169566",
"status" : "missing"
},
{
"rev" : "1-78abf9a6508671ba8338e4ef6daa910a",
"status" : "missing"
}
],
"title" : "Lemon Chicken",
"description" : "Chinese lemon chicken",
"serving-suggestion" : "Serve with plain jasmine rice.",
"servings" : 4
}