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

MPR = MPRester(“yourAPIkey”)
for x in list:
entry = MPR.get_entry_by_material_id(x)
print(“Won’t query”,x)


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 =[
# 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}})