europeana / rd-europeana-python-api

Python API for Europeana
European Union Public License 1.2
6 stars 2 forks source link

README.md usage example does not work #6

Closed ejgenc closed 2 years ago

ejgenc commented 2 years ago

The following code snipped found in the 'Usage' section of the project's README file no longer works as of yesterday.

from pyeuropeana.apis import Search

search_api = Search('YOUR_API_KEY')

df = search_api(
  query = '*',
  qf = '(skos_concept:"http://data.europeana.eu/concept/base/48" AND TYPE:IMAGE)',
  reusability = 'open AND permission',
  media = True,
  thumbnail = True,
  landingpage = True,
  colourpalette = '#0000FF',
  theme = 'photography',
  sort = 'europeana_id',
  profile = 'rich',
  rows = 1000,
).dataframe()

Calling the call dunder function no longer returns an instance of a SearchResponse class, but a plain Python dictionary. This Python dictionary contains not only the data about Cultural Heritage Objects, but also metadata about the API call such as the API key, request number, total number of items discovered by the query etc. The data about Cultural Heritage Objects resides under the "items" key. To turn that dictionary into a dataframe that contains only CHO data, we need to utilize the 'resp2df' function provided until utils.py.

In line with the recent changes, the example should be changed as follows:

from pyeuropeana.apis import Search

search_api = Search('YOUR_API_KEY')

response = search_api(
  query = '*',
  qf = '(skos_concept:"http://data.europeana.eu/concept/base/48" AND TYPE:IMAGE)',
  reusability = 'open AND permission',
  media = True,
  thumbnail = True,
  landingpage = True,
  colourpalette = '#0000FF',
  theme = 'photography',
  sort = 'europeana_id',
  profile = 'rich',
  rows = 1000,
)
df = resp2df(response, full=False)

@joseed-europeana I suggest that this issue stays open even after we fix this specific problem. We also have to update all similar examples found scattered throughout different notebooks.

ejgenc commented 2 years ago

This issue was fixed with #8