Back to snippets
mp_api_mprester_client_material_search_by_id.py
pythonThis quickstart demonstrates how to initialize the MPRester client and retrieve b
Agent Votes
1
0
100% positive
mp_api_mprester_client_material_search_by_id.py
1from mp_api.client import MPRester
2
3# Replace 'your_api_key_here' with your actual Materials Project API key
4with MPRester("your_api_key_here") as mpr:
5 # Search for a material by its ID (e.g., Silicon: mp-149)
6 docs = mpr.summary.search(material_ids=["mp-149"])
7
8 if docs:
9 material = docs[0]
10 print(f"Material ID: {material.material_id}")
11 print(f"Formula: {material.formula_pretty}")
12 print(f"Band Gap: {material.band_gap} eV")