pymatgen.ext.optimade module

Optimade support.

class OptimadeRester(alias_or_structure_resource_url='mp')[source]

Bases: object

Class to call OPTIMADE-compliant APIs, see

This class is ready to use but considered in-development and subject to change until the OPTIMADE paper is published.

OPTIMADE is an effort to provide a standardized interface to retrieve information from many different materials science databases.

This is a client to retrieve structures from OPTIMADE v1 compliant endpoints. It does not yet support all features of the OPTIMADE v1 specification but is intended as a way to quickly search an endpoint in a way familiar to users of pymatgen without needing to know the full OPTIMADE specification.

For advanced usage, please see the OPTIMADE documentation at and consider calling the APIs directly.

For convenience, known OPTIMADE endpoints have been given aliases in pymatgen to save typing the full URL. The current list of aliases is:

aflow, cod, mcloud.sssp, mcloud.2dstructures, mcloud.2dtopo,, mcloud.threedd, mcloud.scdm, mcloud.curated-cofs, mcloud.optimade-sample, mcloud.stoceriaitf, mcloud.pyrene-mofs,, mp, odbx, omdb.omdb_production, oqmd, tcod

To refresh this list of aliases, generated from the current list of OPTIMADE providers at, call the refresh_aliases() method.


alias_or_structure_resource_url – the alias or structure resource URL

aliases = {'aflow': '', 'cod': '', 'mcloud.2dstructures': '', 'mcloud.2dtopo': '', 'mcloud.curated-cofs': '', '': '', 'mcloud.optimade-sample': '', 'mcloud.pyrene-mofs': '', 'mcloud.scdm': '', 'mcloud.sssp': '', 'mcloud.stoceriaitf': '', '': '', 'mcloud.threedd': '', 'mp': '', 'odbx': '', 'omdb.omdb_production': '', 'oqmd': '', 'tcod': ''}[source]
get_structures(elements=None, nelements=None, nsites=None, chemical_formula_anonymous=None, chemical_formula_hill=None) → Dict[str, pymatgen.core.structure.Structure][source]

Retrieve structures from the OPTIMADE database.

Not all functionality of OPTIMADE is currently exposed in this convenience method. To use a custom filter, call get_structures_with_filter().

  • elements – List of elements

  • nelements – Number of elements, e.g. 4 or [2, 5] for the range >=2 and <=5

  • nsites – Number of sites, e.g. 4 or [2, 5] for the range >=2 and <=5

  • chemical_formula_anonymous – Anonymous chemical formula

  • chemical_formula_hill – Chemical formula following Hill convention

Returns: Dict of Structures keyed by that database’s id system

get_structures_with_filter(optimade_filter: str) → Dict[str, pymatgen.core.structure.Structure][source]

Get structures satisfying a given OPTIMADE filter.


filter – An OPTIMADE-compliant filter

Returns: Dict of Structures keyed by that database’s id system


Updates available OPTIMADE structure resources based on the current list of OPTIMADE providers.