MPrester, regarding

Dear Users

**TypeError: search() got an unexpected keyword argument 'criteria'**
**--> 106   c = m.summary.search(criteria=criteria,properties=["material_id","nsites","nelements","num_sites","structure","primitive_structure","e_above_hull"])**

I am stuck with above error in the new version of API.

I am executing code in Jupyter NB using Anaconda navigator in windows. The code works fine with google colab but not with Jupyter NB. So i made few changes according to the new version of API but still I couldn’t resolve the above error.

Any suggestions?

Wishes
Rahul

Hi @drrahulsuresh,

Could you share the version of mp-api you have installed? There is no criteria argument anymore, perhaps you are on an old version. See here for the arguments for MPRester.summary.search.

Hope this helps!

Matt

Hi @mkhorton

api - new version. not the legacy.

with MPRester(“api_key”) as m:
criteria = {“structure”: {‘$exists’: True},“material_id”:{“$in”:[“mp-1522”,“mp-555322”,“mp-2099”,“mp-556911”,“mp-22862”,“mp-23193”,“mp-23251”,“mp-22898”]}}
c = m.summary.search(criteria=criteria,properties=[“material_id”,“nsites”,“nelements”,“num_sites”,“structure”,“primitive_structure”,“e_above_hull”])
df=pd.json_normalize(c)
#print(df.head)

Rahul

Hi users
This code works well in google collab but I face this issue in Jupyter notebook.

Can you please tell how to reform this query?

with MPRester(“api_key”) as m:

criteria = {“structure”: {‘$exists’: True}}
c = m.query(criteria=criteria,properties=[“material_id”,“nsites”,“nelements”,“num_sites”,“structure”,“primitive_structure”,“e_above_hull”])
df=pd.json_normalize(c)
print(df.head)

Rahul