Not able to retrieve elasticity data


I am trying to retrieve the bulk and shear moduli for all metals using the MP-API. I had code that worked when using

with MPRester(my_api_key) as mpr: docs =, fields=["material_id", "bulk modulus", "shear_modulus", "is_metal"])

After printing the latest list of available fields with

list_of_available_fields = mpr.summary.available_fields

I find I should maybe be using

fields=["material_id", "k_voight", "g_voight", "is_metal"]

but this returns “None” for k_voight and g_voight.

An additional question: I see query time can be reduced by using has_props=[“k_voight”], for example, but when I add this to search() is gives the following error:

Any help is appreciated!



“k_voight” is a typo in your script. It should be “k_voigt” and has_props should be provided with emmet core HasProps enum.

Hi Cyrus,

Thank you for the response! My bad on the typo.

For using HasProps I could use a little more guidance though. This is what I’m trying now

from mp_api.client import MPRester
from emmet.core.summary import HasProps

with MPRester("uJpFxJJGKCSp9s1shwg9HmDuNjCDfWbM") as mpr:
    docs =, is_metal=True, fields=["material_id", "is_metal", "k_voigt"])

but it says ‘elasticity’ is not defined, even though that is one of the enum values?

Thank you,


I have a similar problem. I tried to used the provided code on Materials Project webpage:

from mp_api.client import MPRester
with MPRester(api_key="<enter your api key>") as mpr:
    elasticity_doc =["mp-1265"])

but got the following error:

TypeError: search() got an unexpected keyword argument 'material_ids'

(I did change “enter your api key” to my own api key. Just don’t want to show my key here.)

@Carla_Becker, we have just changed how some of the data is built but have not updated the docs yet. Sorry for the confusion. You can instead ask for bulk_modulus or bulk_modulus.voigt to get what you need in fields.

@jessechen the latest API client has support for querying elasticity data using a list of MPIDs. If you update to v0.38.0 it should work now.

– Jason

Hi Jason,

I’m sorry, but it still isn’t working for me. This is what I have:

with MPRester(my_api_key) as mpr:
    docs =, fields=["bulk_modulus"])
    bulk_modulus = docs[0].bulk_modulus

and it returns the error

AttributeError: 'MPDataDoc' object has no attribute 'bulk_modulus'

I think the issue I have may be related to this. If not, my apologies. I am unable to query surface data information. I ran this exact code Friday and it worked. Is there a simple syntactical fix here as well?

    with MPRester() as mpr:
        surface_properties_doc = mpr.surface_properties.get_data_by_id("mp-30")

MPRestError                               Traceback (most recent call last)
Input In [12], in <cell line: 1>()
      1 with MPRester(api_key="") as mpr:
----> 2     surface_properties_doc = mpr.surface_properties.get_data_by_id("mp-30")

File /opt/conda/lib/python3.9/site-packages/mp_api/client/core/, in BaseRester.get_data_by_id(self, document_id, fields)
    912             results = self._query_resource_data(
    913                 criteria=criteria, fields=fields, suburl=document_id  # type: ignore
    914             )
    916 if not results:
--> 917     raise MPRestError(f"No result for record {document_id}.")
    918 elif len(results) > 1:  # pragma: no cover
    919     raise ValueError(
    920         f"Multiple records for {document_id}, this shouldn't happen. Please report as a bug."
    921     )

MPRestError: No result for record mp-30.

Just chiming in to say that both of the code snippets are working for me (except the doc.bulk_modulus.voigt part, since bulk_modulus attribute is a dictionary). In the recent past, I remember reading about people having issues with the API with an outdated mp-api package, even with a package a few minor versions or patches behind. I’m guessing either this may be the issue or there was an outage with the API at the time these errors happened.

1 Like

@Carla_Becker and @bwander make sure you have the most up to date emmet-core and mp-api. I believe that should fix the issues as @firaty has also suggested.

– Jason

@munrojm I got mine sorted by updating. Thanks for the help! (also @firaty)

I updated to the latest versions of emmet-core and mp-api and now my code runs successfully, but the elastic constant data is empty:

This code

with MPRester(my_api_key) as mpr:
    docs =["mp-30"], is_metal=True, fields=["material_id", "is_metal", "k_voigt", "k_reuss", "K_vrh"])
    k_voigt = docs[0].k_voigt
    k_reuss= docs[0].k_reuss
    k_vrh = docs[0].k_vrh



even though online I see

Am I querying the wrong data?

1 Like

Same problem there. After querying materials with…, fields=[‘k_voigt’, ‘k_reuss’, ‘k_vrh’, ‘g_voigt’, ‘g_reuss’, ‘g_vrh’]),
this list of fields is included in entries SummaryDoc “fields_not_requested”, with no elasticity data obtained.
It definitely was not like this in database version 2022.10.28, when all those fields were retrieved without problems!

Hi Youjin,

I was able to resolve my problem by updating to the latest versions of emmet-core and mp_api with the commands

pip install emmet-core --update
pip install mp_api --update

and then access the elasticity data with

with MPRester(my_api_key) as mpr:
     docs =["bulk_modulus", "shear_modulus"])
     bulk_modulus_voigt = doc.bulk_modulus["voigt"]
     bulk_modulus_reuss = doc.bulk_modulus["reuss"]
     bulk_modulus_vrh = doc.bulk_modulus["vrh"]
     shear_modulus_voigt = doc.shear_modulus["voigt"]
     shear_modulus_reuss = doc.shear_modulus["reuss"]
     shear_modulus_vrh = doc.shear_modulus["vrh"]