"Experimentally observed" boolean from MAPI

Hi all!
In the GUI of MP it is pretty striaghtforward to see weather a compound has been experimentally observed, but is there a quick way to get the same info via MAPI?
I couldn’t find any boolean-like info by navigating the document [schema].(Materials Project API - ReDoc)

Thanks a lot!

Hi @acarnevali , you can use the theoretical attribute ( a boolean) in the SummaryDoc retrieved from the API. theoretical=True means that the material does not match any known ICSD entries (as best we can tell from our automated matching algorithms). So theoretical=False implies that it has been experimentally observed.

Hope that helps!

2 Likes

Thank you, that’s what I was looking for.
I am not sure though on how to phrase my query, as the instatiated MPRester appears not to have any summary attribute.

from pymatgen.ext.matproj import MPRester ## I am not importing from mp_api as it doesn't work
ids = [some material ids]
with MPRester(api_key = key) as mpr:
    data = mpr.summary(ids)

returns

AttributeError: 'MPRester' object has no attribute 'summary'
1 Like

Ah, apologies I didn’t clarify. The SummaryDoc and summary search endpoints are available via the new MP API, which you can obtain with pip install mp-api (see documentation here).

If you use that, you can do, e.g.:

from mp_api import MPRester
with MPRester(api_key=<your_api_key>) as m:
    theoretical = {str(d.material_id): d.theoretical for d in m.summary.search_summary_docs(material_ids=all_ids, fields=["material_id", "theoretical"])}

where all_ids is a list of mp-ids you want to query.

You can still retrieve the theoretical property using the legacy API (bundled with pymatgen) as well. For that case, I believe you just pass property_data=["theoretical"] to your query (though I have not tested this myself).

2 Likes

Hi @rkingsbury I would like to use this method as well to check if a material is experimentally observed or not, but I am running into issues trying to install mp-api. When I use pip install mp-api I get:

Collecting mp-api
  Using cached https://files.pythonhosted.org/packages/0c/77/b7249dd09f75a1cb3a8fb1554cdc8af7f19ef20933810bbec3c1fdb297af/mp_api-0.18.0-py3-none-any.whl
Requirement already satisfied: setuptools in c:\users\makee\anaconda3\lib\site-packages (from mp-api) (62.6.0)
Collecting mpcontribs-client (from mp-api)
  Downloading https://files.pythonhosted.org/packages/a4/a5/58f6b391d69af461e8999cd6240d9075035205a6a3deede1730c2cc4afa8/mpcontribs_client-4.0.0-py3-none-any.whl
Collecting pymatgen>=2022.0.16 (from mp-api)
  Using cached https://files.pythonhosted.org/packages/ed/51/db21d17a438ee759cd01f588ec8dddf894028b84876620a33b856248886f/pymatgen-2022.0.17.tar.gz
  Installing build dependencies ... done
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\makee\AppData\Local\Temp\pip-build-env-gqvyhp7w\Lib\site-packages\setuptools\__init__.py", line 18, in <module>
        from setuptools.dist import Distribution
      File "C:\Users\makee\AppData\Local\Temp\pip-build-env-gqvyhp7w\Lib\site-packages\setuptools\dist.py", line 35, in <module>
        from ._importlib import metadata
      File "C:\Users\makee\AppData\Local\Temp\pip-build-env-gqvyhp7w\Lib\site-packages\setuptools\_importlib.py", line 39, in <module>
        disable_importlib_metadata_finder(metadata)
      File "C:\Users\makee\AppData\Local\Temp\pip-build-env-gqvyhp7w\Lib\site-packages\setuptools\_importlib.py", line 30, in disable_importlib_metadata_finder
        for ob in sys.meta_path
      File "C:\Users\makee\AppData\Local\Temp\pip-build-env-gqvyhp7w\Lib\site-packages\setuptools\_importlib.py", line 31, in <listcomp>
        if isinstance(ob, importlib_metadata.MetadataPathFinder)
    AttributeError: module 'importlib_metadata' has no attribute 'MetadataPathFinder'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\makee\AppData\Local\Temp\pip-install-p__6x6up\pymatgen\