Setting up the Materials Project API client.
The MPRester is a Python client provided by the Materials Project for easily accessing data through its API. It can be found in the
mp-apipackage, which can be installed most easily using
pip install mp_api
git clone https://github.com/materialsproject/api
An API key is needed in order to use the client. This is a unique key provided to each Materials Project account. Your API key can be found on your profile dashboard page or the main API page once logged in.
The MPRester client can then be imported and instantiated. It is preferred to use Python's
withcontext manager for session management:
from mp_api.client import MPRester
with MPRester("your_api_key_here") as mpr:
#do stuff with mpr...
See the following sections for details on how to query different types of data.