I am trying to retrieve band structures using the official example code from the documentation:
from mp_api.client import MPRester
from emmet.core.electronic_structure import BSPathType
with MPRester(API_KEY) as mpr:
bs_sc = mpr.get_bandstructure_by_material_id("mp-149")
However, this currently fails in my environment with a Pydantic ValidationError related to missing equivalent_labels fields:
ValidationError: bandstructure.setyawan_curtarolo.equivalent_labels
Field required
I then tried using use_document_model=False and retrieving the band structure via task_id, but get_bandstructure_from_task_id() attempts to access an old S3 path such as:
Could you please let me know what the currently recommended code is for retrieving a full pymatgenBandStructureSymmLine object for a material such as mp-149 or SiO2? Is the official example outdated, or is there a specific version of mp-api / emmet-core that should be used?
Could you try using the latest version of mp-api==0.46.4 and emmet-core==0.87.1? With these versions, I’m able to run the script locally and retrieve the data successfully.
@Urooj_Fatima I just made a fresh conda environment with mp-api==0.46.4, emmet-core==0.87.1, pymatgen-core==2026.5.18, and pymatgen==2026.5.4, and this snippet works:
from mp_api.client import MPRester
with MPRester("your_api_key_here") as mpr:
ebs = mpr.get_bandstructure_by_material_id("mp-149")
If you have anaconda, conda, or miniforge, just run: conda create -n mp python==3.13 --yes && conda activate mp && pip install mp-api==0.46.4