SSHOC / sshoc-marketplace-backend

Code for the backend
Apache License 2.0
2 stars 0 forks source link

Extend the item-search API endpoint with media #390

Closed nczirjak-acdh closed 1 year ago

nczirjak-acdh commented 1 year ago

Hi,

we use the item-search api to fetch the Dariah National Resources from the tools and service category. (https://marketplace-api.sshopencloud.eu/api/item-search?categories=tool-or-service&f.keyword=DARIAH%20National%20Resource), but we want to also display the logo of these services. But in this API endpoint there is no media section.

Could you please extend this item-search endpoint items list with the media property and include the service logos?!

Thanks!

Norbert

KlausIllmayer commented 1 year ago

I don't think this is necessary, you can use the dedicated endpoint for the tool by using the persistentId that you get from the call to api/item-search, e.g., the mentioned API call returns a json and in the items-section you get the persistentId and the category. With this you call the detail information, e.g. for the first entry having persistentId="hqXyOo" and category="tool-or-service" you call a GET on https://marketplace-api.sshopencloud.eu/api/tools-services/hqXyOo - there you will find the media. One pitfall: the mapping to the corresponding category needs to be done with the help of a manual created mapping list, e.g. "tool-or-service" becomes "/api/tools-services", "publication" becomes "/api/publications", etc.

The api/item-search takes the information from the search index of Solr. I don't think we add media and logos into this index.

The Swagger information can be found here: https://marketplace-api.sshopencloud.eu/swagger-ui/index.html?url=/v3/api-docs

nczirjak-acdh commented 1 year ago

thanks for the quick response. My other problem is that I have to filter the tools-or-services, because I need only the "f.keyword=DARIAH%20National%20Resource", but under this endpoint, there is no keyword filtering option. And in this case i had to fetch all of the 1679 results and filter out the 84 items which has the mentioned keyword. Then could you please extend these endpoint with the keyword filtering option?

The detail view with the persistenId was obvious from the documentation. I already implemented that. thanks :)

KlausIllmayer commented 1 year ago

I guess you propose to extend GET /api/tools-services? Indeed, there is no filtering option there, but this is by design. I don't think it is necessary to extend this endpoint with keyword filtering. You already have GET /api/item-search for this. If your aim is to get the detail data - including media resources - of all tools having the mentioned keyword, then in my opinion you should do this:

  1. Get all items having the keyword "DARIAH National Resource" by calling https://marketplace-api.sshopencloud.eu/api/item-search?f.keyword=DARIAH+National+Resource - you will get 92 results
  2. Go through this list and identify all of the tools (category = tool-or-service)
  3. Get for every of this item the full data by taking the persistentId from the result set of step 2 and call https://marketplace-api.sshopencloud.eu/api/tools-services/{persistentId}, e.g. https://marketplace-api.sshopencloud.eu/api/tools-services/hqXyOo

Does this make sense? In general, it is not unusual that you need to query an API with various calls to different endpoints and do some filtering on your side. Unfortunately, I don't think we are able to extend API endpoints for doing shortcuts. If something in principle is not possible or only with a lot of workarounds, then we could discuss it further.

KlausIllmayer commented 1 year ago

And just to add here: for curation we also need to grab data from different endpoints or do some filtering. We use Jupyter Notebooks for this and there is also a library that could be re-used. Have a look here, if you need some inspiration or like to re-use the library: https://github.com/SSHOC/marketplace-curation