Last active
August 29, 2015 14:16
-
-
Save tschaume/fa8d0fc7ed29fe972d2c to your computer and use it in GitHub Desktop.
Testing new MP REST endpoints via MPRester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pymatgen.matproj.rest import MPRester | |
from pymatgen.io.cifio import CifParser | |
ENDPOINT, API_KEY = "https://www.materialsproject.org/rest", os.environ.get('MAPI_KEY') | |
with MPRester(API_KEY, endpoint=ENDPOINT) as m: | |
# retrieve all references for a given mp-id | |
# curl -H "x-api-key:$MAPI_KEY" https://www.materialsproject.org/rest/materials/mp-568345/refs | |
print m.get_materials_id_references('mp-568') | |
# find matching structures in MP | |
# python -c 'from pymatgen.core.structure import Structure; import json; json.dump(Structure.from_file("<filename>").as_dict(),open("/tmp/payload.json","w"))' | |
# curl -H "x-api-key:$MAPI_KEY" -d "structure=`cat /tmp/payload.json`" https://www.materialsproject.org/rest/find_structure | |
ciffile = '/Users/patrick/gitrepos/mp/MPContribs/test_files/Fe3O4.cif' | |
print m.find_structure(ciffile) | |
s = CifParser(ciffile).get_structures()[0] | |
print m.find_structure(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment