mp_api.client.routes.materials.electrodes.ElectrodeRester

class mp_api.client.routes.materials.electrodes.ElectrodeRester(api_key: str | None = None, endpoint: str = 'https://api.materialsproject.org/', include_user_agent: bool = True, session: requests.Session | None = None, s3_resource: Any | None = None, debug: bool = False, monty_decode: bool = True, use_document_model: bool = True, timeout: int = 20, headers: dict = None, mute_progress_bars: bool = False)[source]

Bases: BaseRester[InsertionElectrodeDoc]

Args: api_key (str): A String API key for accessing the MaterialsProject REST interface. Please obtain your API key at https://www.materialsproject.org/dashboard. If this is None, the code will check if there is a “PMG_MAPI_KEY” setting. If so, it will use that environment variable. This makes easier for heavy users to simply add this environment variable to their setups and MPRester can then be called without any arguments. endpoint (str): Url of endpoint to access the MaterialsProject REST interface. Defaults to the standard Materials Project REST address at “https://api.materialsproject.org”, but can be changed to other urls implementing a similar interface. include_user_agent (bool): If True, will include a user agent with the HTTP request including information on pymatgen and system version making the API request. This helps MP support pymatgen users, and is similar to what most web browsers send with each page request. Set to False to disable the user agent. session: requests Session object with which to connect to the API, for advanced usage only. debug: if True, print the URL for every request monty_decode: Decode the data using monty into python objects use_document_model: If False, skip the creating the document model and return data as a dictionary. This can be simpler to work with but bypasses data validation and will not give auto-complete for available fields. timeout: Time in seconds to wait until a request timeout error is thrown headers (dict): Custom headers for localhost connections.

__init__(api_key: str | None = None, endpoint: str = 'https://api.materialsproject.org/', include_user_agent: bool = True, session: requests.Session | None = None, s3_resource: Any | None = None, debug: bool = False, monty_decode: bool = True, use_document_model: bool = True, timeout: int = 20, headers: dict = None, mute_progress_bars: bool = False)

Args: api_key (str): A String API key for accessing the MaterialsProject REST interface. Please obtain your API key at https://www.materialsproject.org/dashboard. If this is None, the code will check if there is a “PMG_MAPI_KEY” setting. If so, it will use that environment variable. This makes easier for heavy users to simply add this environment variable to their setups and MPRester can then be called without any arguments. endpoint (str): Url of endpoint to access the MaterialsProject REST interface. Defaults to the standard Materials Project REST address at “https://api.materialsproject.org”, but can be changed to other urls implementing a similar interface. include_user_agent (bool): If True, will include a user agent with the HTTP request including information on pymatgen and system version making the API request. This helps MP support pymatgen users, and is similar to what most web browsers send with each page request. Set to False to disable the user agent. session: requests Session object with which to connect to the API, for advanced usage only. debug: if True, print the URL for every request monty_decode: Decode the data using monty into python objects use_document_model: If False, skip the creating the document model and return data as a dictionary. This can be simpler to work with but bypasses data validation and will not give auto-complete for available fields. timeout: Time in seconds to wait until a request timeout error is thrown headers (dict): Custom headers for localhost connections.

Methods

__init__([api_key, endpoint, ...])

Args: api_key (str): A String API key for accessing the MaterialsProject REST interface.

count([criteria])

Return a count of total documents.

get_data_by_id(document_id[, fields])

Query the endpoint for a single document.

search([material_ids, battery_ids, ...])

Query equations of state docs using a variety of search criteria.

search_electrode_docs(*args, **kwargs)

Deprecated.

Attributes

available_fields

primary_key

s3_resource

session

suffix

supports_versions

document_model

alias of InsertionElectrodeDoc

search_electrode_docs(*args, **kwargs)[source]

Deprecated.

search(material_ids: str | list[str] | None = None, battery_ids: str | list[str] | None = None, average_voltage: tuple[float, float] | None = None, capacity_grav: tuple[float, float] | None = None, capacity_vol: tuple[float, float] | None = None, elements: list[str] | None = None, energy_grav: tuple[float, float] | None = None, energy_vol: tuple[float, float] | None = None, exclude_elements: list[str] | None = None, formula: str | list[str] | None = None, fracA_charge: tuple[float, float] | None = None, fracA_discharge: tuple[float, float] | None = None, max_delta_volume: tuple[float, float] | None = None, max_voltage_step: tuple[float, float] | None = None, num_elements: tuple[int, int] | None = None, num_steps: tuple[int, int] | None = None, stability_charge: tuple[float, float] | None = None, stability_discharge: tuple[float, float] | None = None, working_ion: Element | None = None, num_chunks: int | None = None, chunk_size: int = 1000, all_fields: bool = True, fields: list[str] | None = None)[source]

Query equations of state docs using a variety of search criteria.

Parameters:
  • material_ids (str, List[str]) – A single Material ID string or list of strings (e.g., mp-149, [mp-149, mp-13]).

  • battery_ids (str, List[str]) – A single battery ID string or list of strings (e.g., mp-22526_Li, [mp-22526_Li, mp-22526_Ca]).

  • average_voltage (Tuple[float,float]) – Minimum and maximum value of the average voltage for a particular voltage step in V.

  • capacity_grav (Tuple[float,float]) – Minimum and maximum value of the gravimetric capacity in maH/g.

  • capacity_vol (Tuple[float,float]) – Minimum and maximum value of the volumetric capacity in maH/cc.

  • elements (List[str]) – A list of elements for the framework material.

  • energy_grav (Tuple[float,float]) – Minimum and maximum value of the gravimetric energy (specific energy) in Wh/kg.

  • energy_vol (Tuple[float,float]) – Minimum and maximum value of the volumetric energy (energy density) in Wh/l.

  • exclude_elements (List[str]) – A list of elements to exclude for the framework material.

  • formula (str, List[str]) – Chemical formula or list of chemical formulas of any of the materials associated with the electrode system. This includes materials partially along the charge-discharge path.

  • fracA_charge (Tuple[float,float]) – Minimum and maximum value of the atomic fraction of the working ion in the charged state.

  • fracA_discharge (Tuple[float,float]) – Minimum and maximum value of the atomic fraction of the working ion in the discharged state.

  • max_delta_volume (Tuple[float,float]) – Minimum and maximum value of the max volume change in percent for a particular voltage step.

  • max_voltage_step (Tuple[float,float]) – Minimum and maximum value of the maximum voltage for a particular voltage step in V.

  • num_elements (Tuple[int,int]) – Minimum and maximum number of elements to consider.

  • num_steps (int) – Number of distinct voltage steps from charged to discharged based on stable intermediates.

  • stability_charge (Tuple[float,float]) – Minimum and maximum value of the energy above hull of the charged material.

  • stability_discharge (Tuple[float,float]) – Minimum and maximum value of the energy above hull of the discharged material.

  • working_ion (Element, List[Element]) – Element or list of elements of the working ion.

  • num_chunks (int) – Maximum number of chunks of data to yield. None will yield all possible.

  • chunk_size (int) – Number of data entries per chunk.

  • all_fields (bool) – Whether to return all fields in the document. Defaults to True.

  • fields (List[str]) – List of fields in InsertionElectrodeDoc to return data for. Default is battery_id and last_updated if all_fields is False.

Returns:

([InsertionElectrodeDoc]) List of insertion electrode documents.

count(criteria: dict | None = None) int | str

Return a count of total documents.

Parameters:

criteria (dict | None) – As in .query(). Defaults to None

Returns:

Count of total results, or string indicating error

Return type:

(int | str)

get_data_by_id(document_id: str, fields: list[str] | None = None) T

Query the endpoint for a single document.

Parameters:
  • document_id – the unique key for this kind of document, typically a task_id

  • fields – list of fields to return, by default will return all fields

Returns:

A single document.