MPRester error

Hey,
I have recently started learning to use the Materials Project API and was trying to execute one of the examples. The code below worked fine.

from pymatgen.ext.matproj import MPRester 

with MPRester(SUHAS_API_KEY) as mpr:
    print('Exact TaC formula matches are:', mpr.get_materials_ids("TaC"))
    print('All compounds in the Ta-C system are:', mpr.get_materials_ids('Ta-C'))

But when MPRester () is called from the mp_api.client, I am facing the error mentioned below.

from mp_api.client import MPRester

with MPRester(SUHAS_API_KEY) as mpr:
    docs = mpr.materials.summary.search(material_ids=["mp-149"], fields=["structure"])
    structure = docs[0].structure
    # -- Shortcut for a single Materials Project ID:
    structure = mpr.get_structure_by_material_id("mp-149")

This is the error I get:
“You are using deprecated API endpoints. Please read our documentation (https://docs.materialsproject.org) and upgrade to the latest version of the mp-api client (mp-api · PyPI).”

Also sometimes, I get that MPRester has no atttribute ‘get_structure_by_material_id’
Please help

Thank you for reaching out. As the error message said, please make sure to upgrade to the latest version of mp-api.

Your Python version will upper-bound the newest mp-api available version.
Try Python 3.9 or higher and upgrade mp-api.

1 Like