Hello,
I'm trying to write a little personal project that will a) establish a random 5-colour palette, b) query Europeana for paintings with that palette, c) have Europeana return one at random.
What seems to be happening is that the colour palette criteria is being ignored when results are returned.
I am really very new to all of this and one of my reasons for doing this is to learn how to deal with APIs, so it is very likely that I have done something stupid. I am sorry for bothering you if that is the case - I did try to work this out by reading the documentation several times and trying to read the source code of the Europeana Colour Explorer. Here is my python function to build the API call:
def get_art():
api_key = 'XXXXXXXX'
art_api = 'https://api.europeana.eu/record/v2/search.json?wskey='+ api_key
query = {"query" : "painting",
"theme" : "art",
"colourpalette" : [colour0, colour1, colour2, colour3, colour4],
"media" : "true",
"sort" : ("random", "desc"),
"rows" : "1"
}
response = requests.post(art_api, json = query)
return response
(I know this api key handling is not ideal but it is the only way i could get it to work!)
The colour variables are defined above this snippet, taken randomly from a list of the CSS hex colours and then returned as hex values.
This query returns 239,552 results. Commenting out 'theme' returns 264,554 results, which suggests that the original query is 'painting' AND 'theme:art'. Likewise, commenting out 'media' gives a higher number of returns: 245,498. But commenting out 'colourpalette' also returns 239,552 results. So i think my query as stands returns 'painting' AND 'theme:art' AND 'media:true' but ignores the colourpalette parameters?
Please do you have any tips for fixing this?
many thanks in advance,
Nikki