Download all POSCARs from MP database

Hello,

Is there a way to download all POSCARs from the MP for the most stable phase? and save each POSCAR in a directory by their name.

Regards,
Asif

Hi @Asif-Iqbal-Bhatti,

With the new API, you can download every structure by asking for every single “summary” document:

import MPRester from mp_api

with MPRester("your_api_key_here") as mpr:
    docs = mpr.summary.search(fields=["structure", "material_id"])

From here, you can access the structures as attributes and save them as POSCAR files:

for doc in docs:
    structure = doc.structure
    material_id = doc.material_id

    structure.to("POSCAR", "your_file_name_here")

– Jason

2 Likes