from pymongo import MongoClient
import os
from bson.json_util import dumps, loads

collection = "name_of_collection_you_want_to_download"
file_name = collection + ".json"

cluster = MongoClient(os.environ.get("MONGODB_CLIENT"))
db = cluster[os.environ.get("MONGODB_DATABASE")]
collection = db[collection]

results = collection.find()

json_data = dumps(results, indent = 2)

with open(file_name, 'w') as file:
  file.write(json_data)
