I'm using the Immich API in a Python script.
My goal is to load asset's infos using the searchAssets API call.
The problem is that if I use it with the originalFileName field it does return an empty list, even if the asset with the said original filename does exist.
Why?
Here you can see the script I'm using:
import requests
import json
from types import SimpleNamespace
API_KEY = REDACTED
BASE_URL = 'http://192.168.1.18:2283/api'
def getAssetByOriginalFileName(originalFileName):
url = f'{BASE_URL}/search/metadata'
payload = json.dumps({
"originalFileName": originalFileName
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-api-key': API_KEY
}
response = requests.request("POST", url, headers=headers, data=payload)
return(json.loads(response.text))
###MAIN
originalFileName = 'PXL_20250720_150136601.JPG'
assets = getAssetByOriginalFileName(originalFileName)
print(assets) ```
The output is the following:
`{'albums': {'total': 0, 'count': 0, 'items': [], 'facets': []}, 'assets': {'total': 0, 'count': 0, 'items': [], 'facets': [], 'nextPage': None}}`
.