Export Documents of a Collection
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
Parameters
Path Parameters
The name of your MongoDb Collection
Query Parameters
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.
Soft-deleted documents too (collections declared with softDelete, 2.3.0); needs the administrate grant of the collection, 403 otherwise.
falsendjson (one JSON document per line), json (one array) or csv
"ndjson"Filter Query like on the list of documents, by default all documents are exported
Sorting like on the list of documents, a leading - sorts descending
The fields to export, for csv they are the columns in this order
The greatest number of documents, by default all
"int32"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.
"relaxed""canonical""plain""relaxed"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*
falsefalsetrue (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
falsefalse