Some entries seem not to be queryable?

While doing some analyses with the API, I’ve found that some materials appear not to be queryable via the API. Here is a short list, but there may be others. Please try running the following code.

from pymatgen.ext.matproj import MPRester

list=[“mp-769348”,“mp-867891”,“mp-23426”,“mvc-11699”,“mp-867839”,“mp-625056”,“mp-561394”,“mp-555855”,“mp-867615”,“mp-16564”,“mp-604812”,“mp-25620”,“mp-866628”,“mp-34710”,“mvc-13876”]
MPR = MPRester(“yourAPIkey”)
for x in list:
try:
entry = MPR.get_entry_by_material_id(x)
except:
print(“Won’t query”,x)

1 Like

Hi Wenhao,

Each material ID is one chosen out of its calculation (“task”) IDs, typically the highest-quality structure optimization task. In our recent database re-build, which added 20% more structures to the database, several new calculations for pre-existing materials caused this “chosen” ID to change. We’ll consider whether we want to pin material IDs to old values for less user confusion; thank you for this feedback.

For now, and in general, a workaround is to note that all task IDs associated with a material are in its “task_ids” field (and a task ID is associated with one and only one material), so using Mongo syntax to search via that field will execute your intended query. For example:

from pymatgen.ext.matproj import MPRester

mpr = MPRester()
tids =[
    "mp-769348","mp-867891","mp-23426","mvc-11699","mp-867839",
    "mp-625056","mp-561394","mp-555855","mp-867615","mp-16564",
    "mp-604812","mp-25620","mp-866628","mp-34710","mvc-13876"]
# One at a time
for tid in tids:
    mpr.get_entry_by_material_id({"task_ids": tid})
# In one go
mpr.get_entries({"task_ids": {"$in": tids}})

Best,
Donny