Skip to content

Export Documents of a Collection​

GET
/mongodb/collections/{collectionName}/documents/export

Download the documents of a Collection as a stream: ndjson (one JSON document per line), json (one array) or csv (a header line, nested values as JSON, a text with a comma, a quote or a line break in quotes). The documents are written while the database delivers them, the memory of the server does not depend on the size of the Collection. The columns of a csv export are the fields of projection, by default the fields of the first 1000 documents. With extendedJson the types of the values are explicit. A failure while the stream is running ends the stream, the status is 200 by then; send trailer=true for an end marker. POST takes the filter in the body (no URL limit).

Authorizations​

httpAuth
Type
HTTP (bearer)
or
httpAuth1
Type
HTTP (basic)
or
apiKeyAuth
Type
API Key (header: X-AUTH-APIKEY)

Parameters​

Path Parameters

collectionName*

The name of your MongoDb Collection

Type
string
Required

Query Parameters

expand

References to expand (2.4.0): declared ref fields of the collection, repeated or comma separated, at most 5. Each becomes the referenced document, read with the grant and the read scope of its collection (null, or left out of an array, when the caller cannot read it). 400 for a field that is no reference.

Type
array
withDeleted

Soft-deleted documents too (collections declared with softDelete, 2.3.0); needs the administrate grant of the collection, 403 otherwise.

Type
boolean
Default
false
format

ndjson (one JSON document per line), json (one array) or csv

Type
string
Default
"ndjson"
filter

Filter Query like on the list of documents, by default all documents are exported

Type
string
sort

Sorting like on the list of documents, a leading - sorts descending

Type
array
Default
projection

The fields to export, for csv they are the columns in this order

Type
array
Default
limit

The greatest number of documents, by default all

Type
integer
Format
"int32"
extendedJson

relaxed (default since 2.0.0) or canonical: the documents as MongoDB Extended JSON with the types of their values ({"$oid": ...}, {"$date": ...}, {"$numberDecimal": ...}; canonical also {"$numberInt": ...}, {"$numberLong": ...} and {"$numberDouble": ...}); a text that looks like a date is {"$string": ...}. plain: the format of 1.x (ids and dates as strings, every number as JSON number, no types). The default of a csv export is plain.

Type
string
Valid values
"relaxed""canonical""plain"
Default
"relaxed"
filterCaseInsensitive

true: wildcards and prefixes of the Lucene filter ignore the case (the behaviour before 2.0.0). By default they are case-sensitive, so an index on the field serves a prefix like name:abc*

Type
boolean
Examplefalse
Default
false
trailer

true (2.1.0): the export ends with a marker, so a cut-off stream can be told from a complete one. ndjson: a last line {"$end":true,"count":n}, or {"$error":"..."} when the stream fails; json: the array is followed by nothing on success and the stream ends without "]" on failure (the marker is the closing bracket); csv: a last line "# end n" or "# error ...". Default false

Type
boolean
Examplefalse
Default
false

Responses​

text/plain
JSON
"string"

Playground​

Authorization
Variables
Key
Value

Samples​

Powered by VitePress OpenAPI

Released under the MIT License.