I am new to OPTIMADE and I am trying to find the way of querying a specific database and work with the JSON files that are obtained.
The way I am doing it now is by using some external tools
import urllib.request as request import json with request.urlopen('https://www.crystallography.net/tcod/optimade/v1/structures?flter=elements+HAS+ANY+"C","Si","Ge","Sn","Pb"') as response: source = response.read() data = json.loads(source)
From here I get the data object which is a dictionary with 3 keys ‘data’, ‘links’, and ‘meta’. The ‘data’ key is a list with len 10, each element being a dictionary with its ‘attributes’, ect. And the ‘links’ key correctly defines the page limit and offset. The ‘meta’ key is also consistent with the example of the article.
This is the way I found, but I can’t get my head around the optimade python tools themselves. How can I, for example, do this same query using these tools? For instance, to get a set of StructureResource objects, to then obtain the CIF files via the built in adapters? The OptimadeRester from pymatgen also does not use the python-tools, it gets the json files from a specific query and treats the data accordingly to get a pymatgen Structure object.
I am getting something wrong here? I am just searching for a simple way to get the query response from the server and to be able to handle it using the tools provided.