Querying all compositions contained specified elements

How can I query on Materials Project all the chemical compositions containing specific elements?

Cause from my attempts it looks it will only give back chemical compositions iff they contain all the specified elements. Instead, what I want is that, specifying for example \ce{Na}, \ce{O}, \ce{Ba}, \ce{Cl} I get back all possible compounds which might have some proportions of these elements but not necessarily all together.

Materials API (MAPI) - Materials Project Documentation If you are using the legacy API through the Pymatgen MPRester, you can use the query method, which uses MongoDB operators. Quoting the documentation,

For example, a POST to mpquery with

{"criteria": "{'elements':{'$in':['Li', 'Na', 'K'], '$all': ['O']}, 'nelements':2}", "properties": "['formula', 'formation_energy_per_atom']"}

will return the formula and formation energy per atom of all Li, Na and K oxides.

I don’t remember quite how the $in operator works, it’s possible that “criteria”: "{‘elements’:{’$in’:[‘Na’,‘O’,‘Ba’,‘Cl’], . . . would fail to return NaF because fluorine is not in the list. If that’s not the desired behavior you might have to do a little fancy logic with putting together multiple $or operators.