LIST_URL = 'https://api.trakt.tv/lists/sample/items/movies?sort=collected&limit=3'
# Headers for the API request
headers = {
'Content-Type': 'application/json',
'trakt-api-version': '2',
'trakt-api-key': API_KEY,
'X-Sort-By': 'collected',
'X-Sort-How': 'desc'
}
def fetch_list(list_url):
response = requests.get(list_url, headers=headers)
This however delivers everything and not only the collected items - I assume I may need to be resolving my user somehow (and not that its coming via the API key?)
Ive been playing for a while and cant work it out - if anyone would have any insights it would be enormously appreciated!
I had assumed this would be the case - problem is I would see two approaches to this:
within the payload there’s some kind of data related to if the item is “collected” true/false - even with extended=full I see an enormous amount of data but nothing related to collected to use for filtering
with X-Sort-By collected I assumed I could take the first 3 / last 3 to get collected and uncollected films but when using the X-Sort-By (even with something like title) it doesn’t seem to change the sorting order of the list
If either of these assumptions are correct, could someone perhaps guide me where I’m going wrong on the call to get it within the payload or how to have the sorting work in the headers?
Lists don’t support sorted results, the headers are read only and so you can apply sorting in your app. You would need to sync the collection data separately and use that to apply sorting on the list, in your app’s logic.