How to use get_entries_in_chemsys() to get only experimentally observed entries in a chemical subspace

Hello,

When using the get_entries_in_chemsys() method to get only the entries in a chemical subspace which have been experimentally observed. There are many flags or options, such as compatible_only, use_gibbs, and the additional_criteria inputs, but I’m unsure how I might request only the experimentally observed options this using the method. An example of how (if it is possible) or any insight would be very helpful!

Thank you for the help & time.

The easiest way is obtaining material IDs from the summary endpoint which have been experimentally observed, and then searching the thermo endpoint just for those IDs. An example for the Li-Cl-O system is below:

from mp_api.client import MPRester
from itertools import combinations

# First obtain all possible subsets of the chemical system
chemsys_elements = ["Li","Cl","O"]
constituent_chemsys = set()
for i in range(len(chemsys_elements)):
    constituent_chemsys.update({"-".join(combo) for combo in combinations(chemsys_elements,1+i)})

# This is the default thermo type used in MP, you could also use GGA_GGA+U or R2SCAN.
thermo_types = ["GGA_GGA+U_R2SCAN"]

with MPRester("your_api_key") as mpr:
    # Retrieve all materials in those chemical systems which are experimentally observed, `theoretical=False`
    expt_obs_mats = mpr.materials.summary.search(chemsys = list(constituent_chemsys), theoretical=False, fields=["material_id","composition"])
    
    # Obtain thermodynamic data
    thermo_docs = mpr.materials.thermo.search(material_ids=[doc.material_id for doc in expt_obs_mats],thermo_types=thermo_types)

# Concatenate entries in the thermo docs
entries = []
for doc in thermo_docs:
    entries.extend(doc.entries.values())