Extract oxide bluk from Material Project and save to the excell file

Dear all,

I am a new to use this, I want to extract all the oxide bulk metal from the MP and I try this code but is error, could anyone help me with this.

Thank you in advance

This is my code:

from mp_api.client import MPRester
import pandas as pd

api_key = 'apikey'
mpr = MPRester(api_key)

criteria = {
    "elements": {"$in": ["O"]},  # Materials containing oxygen
    "nelements": {"$gte": 2}     # At least one other element
properties = ["material_id", "pretty_formula", "band_gap", "density", "formation_energy_per_atom"]
oxide_data = mpr.query(criteria=criteria, properties=properties)
df = pd.DataFrame(oxide_data)
df.to_excel('oxide_materials.xlsx', index=False)
print("Data has been successfully saved to oxide_materials.xlsx")

@Nguy_n_Nguyen you are using the old rester syntax which is not supported anymore. Try this,

oxide_data = mpr.materials.summary.search(elements=["O"], 
                                          fields=[“material_id”, “pretty_formula”, “band_gap”, “density”, “formation_energy_per_atom”])

– Jason

@Nguy_n_Nguyen please do not share your API key on this public forum. I’ve generated a new key for you. Please check your dashboard.