GET /{db}/{doc}

In this document

This request retrieves a document from a database.

Request


Request headers

Query parameters

The following query parameters are all optional.

NameTypeDescriptionDefault
attachments BooleanInclude attachment bodies in responsefalse
att_encoding_info BooleanInclude encoding information in attachment stubs if the attachment is compressedfalse
atts_since arrayInclude attachments only since specified revisions. Does not include attachments for specified revisionsnone
conflicts BooleanInclude information about conflicts in documentfalse
deleted_conflicts BooleanInclude information about deleted conflicted revisionsfalse
latest BooleanForce retrieval of latest leaf revision, no matter what revision was requestedfalse
local_seq BooleanInclude last update sequence number for the documentfalse
meta BooleanActs same as specifying all conflicts, deletedconflicts and openrevs query parametersfalse
open_revs arrayRetrieve documents of specified leaf revisions. You can specify the value all to return all leaf revisionsnone
rev stringRetrieve the specified revision of the documentnone
revs BooleanInclude a list of all known document revisionsfalse
revs_info BooleanInclude detailed information for all known document revisionsfalse

Response


The response contains a JSON document in the message body.

Response headers

Message body

The message body contains the following objects in a JSON document.

NameTypeDescription
_id stringDocument identifier
_rev stringrevision identifier
_deleted BooleanIndicates whether the document is deleted. Appears only when the document was deleted.
_attachments objectStubs for the attachments. Appears only when the document has attachments.
_conflicts arrayList of revisions with conflicts. Appears only when the request uses the conflicts=true query parameter.
_deleted_conflicts arrayList of revisions with conflicts that were deleted. Appears only when the request uses the deleted_conflicts=true query parameter.
_local_seq integerSequence number of the document in the database. Appears only when the request uses the local_seq=true query parameter.
_revs_info arrayList of objects with information about local revisions and their status. Appears only when the request uses the open_revs=true query parameter.
_revisions objectList 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
}