Unable to pull more than 250 assets though Immich API
Hi,
Forgive me as I'm not a programmer but know enough for how to get in trouble lol. I'm trying to use Google Gemini to create a python GUI script that analyzes images from my Immich server. It then saves the metadata from the images (portrait or landscape) to a file and is supposed to set a randomly selected image as the wallpaper in Windows 11 every x amount of minutes. The issue I'm running into is that it's only able to pull the first 250 assets and then keeps repeating that list of assets and not adding more. I'm on the latest version of Immich (v1.143.1) and the API key being used as all available permissions. And yes, I have more than 250 images available on Immich
. Below is what Google Gemini is telling the issue is. Attached is the python code I'm using/running. I don't know if this matters, but I have Immich running on a Debian 12 (bookworm) server running in docker, obviously. I'm happy to share any other information on my Immich server setup if this is not a bug in Immich to help fix this.
Thank you for providing this final, conclusive log. I can say with 100% certainty now where the problem is, and I sincerely appreciate your patience in helping diagnose this.
The issue is not in the script, but is a bug in the API of your specific Immich server version.
Let's break down the new log file. It tells us everything we need to know:
The solution is to resolve the bug in your Immich server. You have two primary options:
Forgive me as I'm not a programmer but know enough for how to get in trouble lol. I'm trying to use Google Gemini to create a python GUI script that analyzes images from my Immich server. It then saves the metadata from the images (portrait or landscape) to a file and is supposed to set a randomly selected image as the wallpaper in Windows 11 every x amount of minutes. The issue I'm running into is that it's only able to pull the first 250 assets and then keeps repeating that list of assets and not adding more. I'm on the latest version of Immich (v1.143.1) and the API key being used as all available permissions. And yes, I have more than 250 images available on Immich
Thank you for providing this final, conclusive log. I can say with 100% certainty now where the problem is, and I sincerely appreciate your patience in helping diagnose this.
The issue is not in the script, but is a bug in the API of your specific Immich server version.
Final Diagnosis: The Evidence from the Log
Let's break down the new log file. It tells us everything we need to know:
- `Attempting to fetch assets via GET /api/asset...`This shows our new code from the last attempt is running correctly. It's trying the simpler, more stable endpoint first.
- `Failed to use GET /api/asset: 404 Client Error: Not Found... Falling back to original method.`This is the **first smoking gun**. The `GET /api/asset` endpoint doesn't exist on your server. This is common for slightly older versions of Immich. The script correctly detected this failure and fell back to using the original `POST /api/search/metadata` method.
- `Found 100000 total assets on server.`The script, using the original (buggy) method, *thinks* it found 100,000 assets.
- `Total in cache: 100 ... Total in cache: 200 ... Total in cache: 248 ... Total in cache: 250`The cache grows perfectly until it hits exactly 250 entries.
- `Total in cache: 250 ... Total in cache: 250 ... Total in cache: 250`The cache size freezes, even though the `Newly Cached` counter keeps going up.
- The script is forced to use the
/api/search/metadataendpoint. - The pagination feature of this specific endpoint on your server version (v1.143.1) is broken.
- It correctly returns the first page of ~250 assets, but then for every subsequent page request, it returns that same first page over and over again.
- Our script correctly processes the first 250 unique assets, adds them to the cache, and then correctly identifies all subsequent (duplicate) assets as already cached, so it doesn't add them again.
The Solution
The solution is to resolve the bug in your Immich server. You have two primary options:
- Update Your Immich Server: This is the highly recommended solution. You are running version v1.143.1. API bugs like this are frequently fixed in new releases. Updating your Immich instance to the latest stable version will almost certainly resolve this pagination issue.
- Report the Bug: If you are unable to update, you should report this issue on the official Immich GitHub Issues page. Provide them with the key information: you are on version v1.143.1 and the
POST /api/search/metadataendpoint is failing to paginate correctly with theskipparameter.


message.txt60.76KB