Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get experimental Si band gaps from Citrination API
from citrination_client import *
client = CitrinationClient('API_KEY', 'https://citrination.com')
query = PifQuery(
from_index=0,
size=1000,
system=SystemQuery(
chemical_formula=ChemicalFieldOperation(
filter=ChemicalFilter(equal="Si")
),
properties=PropertyQuery(
name=FieldOperation(
filter=Filter(equal="band gap")
),
data_type=FieldOperation(
filter=Filter(equal="EXPERIMENTAL")
)
),
),
)
pifSearchResult = client.search(query)
values = [p.scalars[0].value for h in pifSearchResult.hits
for p in h.system.properties if p.name == 'Band gap']
# values -> [u'1.12', u'1.16', u'1.12', u'1.17', u'1.166', u'1.16', u'1.165']
pifSearchResult.as_dictionary()
# {'hits': ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment