results = m.query({“formula_anonymous”: “AB2”}, properties=[“cif”, “band_gap”,“formula”])
I came across this piece of code but apparently this cant be used. I want to retrieve all the matreials following formula AB2 like VS2, MoS2, etc, their bandgaps and other info like a,b,c parameters and alpha,beta,gamma values.
Can someone help me what can I use instead of above written code?
Hey @raj_aryan,
It looks like you may be using the older API, the documentation for the new API can be found here..
To pull all documents with a generic AB2 formula, you can use the following code snippet (note that there is no CIF field, but there is a structure field, and pymatgen allows you to write this to a CIF). Just make sure to add your API key in the <>
section:
from mp_api.client import MPRester
with MPRester(<your API key>) as mpr:
docs = mpr.materials.summary.search(formula="AB2")
Thank you very much. It was very helpful.