Getting Started
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-api package, which can be installed most easily using pip:
1
pip install mp_api
Copied!
As an alternative, the package can also be installed from its code repository:
1
git clone https://github.com/materialsproject/api
2
cd api
3
python setup.py
Copied!
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 with context manager for session management:
1
from mp_api import MPRester
2
3
with MPRester("your_api_key_here") as mpr:
4
#do stuff with mpr...
Copied!
See the following sections for details on how to query different types of data.
Relevant Code Links
api/client.py at main · materialsproject/api
GitHub
MPRester client code
Export as PDF
Copy link
Edit on GitHub