ChuBL / OpenMindat

A Python package for the OpenMindat API.
https://pypi.org/project/openmindat/
Apache License 2.0
4 stars 2 forks source link

FEATURE REQUEST: Retrieval without writing to file #5

Closed fros1y closed 7 months ago

fros1y commented 9 months ago

So far as I can tell, the library requires any requests to be saved to a file in order to retrieve the data. It would be much more helpful if results could be retrieved as a function result or, ideally, an iterable list of model objects or dicts.

ChuBL commented 9 months ago

You are right. In our next update, we will provide the option to return the retrieved data as a JSON object instead of saving it.

ChuBL commented 7 months ago

Thank you for the request. We have added this feature in our v0.0.4. Please try it in your query by calling our get_list() function instead of save().

from openmindat import GeomaterialSearchRetriever

gsr = GeomaterialSearchRetriever()
gsr.geomaterials_search("quartz, green, hexagonal")
gsr.save("filename")

# Alternatively, you can get the list object directly:
gsr = GeomaterialSearchRetriever()
gsr.geomaterials_search("ruby, red, hexagonal")
print(gsr.get_list())