Hi,
I would like to query some material properties using their ID in the ICSD database. I see there is an option to get the icsd provenance based on the mp_id here https://matsci.org/t/how-to-get-icsd-ids-via-mp-api/41970/2 . But I would like to know whether can I make a query using icsd_id
itself similar to mpr.summary.search(material_id= "mp-149")
. Thanks in advance
Hi @Akhil_S,
Not every ICSD entry is included in MP - some of them we’re working on adding, others we do not plan to add (e.g., if they are disordered). Also, many ICSD entries can structure match to the same MP ID.
The simplest way to accomplish what you’re asking might be this:
from mp_api.client import MPRester
with MPRester("api_key") as mpr:
mp_docs = mpr.materials.summary.search(fields=["material_id", "database_IDs"])
icsd_to_mpid = {}
for mp_doc in mp_docs:
mpid = str(mp_doc.material_id)
for icsd_id in mp_doc.database_IDs.get("icsd",[]):
if icsd_id not in icsd_to_mpid:
icsd_to_mpid[icsd_id] = []
icsd_to_mpid[icsd_id].append(mpid)
where you replace "api_key"
with your API key (if it’s not set as an environment variable).
Then the keys of icsd_to_mpid
will be all ICSD IDs currently matched to at least one entry in MP, and the values of of icsd_to_mpid
will be the MP IDs which match to that ICSD ID.