httk.optimade.process module

httk.optimade.process.process(request, query_function, version, config, debug=False)[source]

Process an optimade query.

Args:
request: a dict with these entries:

baseurl (required): the base url that serves the OPTIMaDe API. representation (mandatory): the string with the part of the URL that follows the base URL. This must always be provided, because

the OPTIMaDe specification requires this to be part of the output in the meta section (meta -> query -> representation).
relurl (optional): the part of the URL that follows the base URL but without query parameters.
Include this if the web-serving framework provides this, i.e., if it splits off the query part for you.

endpoint (optional): the endpoint being requested request_id (optional): a specific entry id being requested. querystr (optional): a string that defines the query parameters that follows the base URL and the relurl and a single ‘?’. query (optional): a dictionary representation of the query part of the URL.

missing information is derived from the ‘representation’ string.

query_function: a callback function of signature
query_function(entries, response_fields, response_limit, filter_ast, debug)
with:
entries: list of optimade entries to run the query for, usually just the entry type requested by the end point. response_fields: which fields should be present in the output response_limit: the maximum number of results to return filter_ast: an abstract syntax tree representing the optimade filter requested debug: if set to true, print debug information to stdout.

returns an OptimadeResults object.

httk.optimade.process.process_init(config, query_function, debug=False)[source]