How do I do an API call and get the images like google photo's service?
I'm currently building an external app, and i'm looking at the documentation and it doesn't really show how does one get the images
29 Replies
:wave: Hey @ChiefDucky,
Thanks for reaching out to us. Please follow the recommended actions below; this will help us be more effective in our support effort and leave more time for building Immich :immich:.
References
- Container Logs:
docker compose logs
docs
- Container Status: docker compose ps
docs
- Reverse Proxy: https://immich.app/docs/administration/reverse-proxy
Checklist
1. :blue_square: I have verified I'm on the latest release(note that mobile app releases may take some time).
2. :blue_square: I have read applicable release notes.
3. :blue_square: I have reviewed the FAQs for known issues.
4. :blue_square: I have reviewed Github for known issues.
5. :blue_square: I have tried accessing Immich via local ip (without a custom reverse proxy).
6. :blue_square: I have uploaded the relevant logs, docker compose, and .env files, making sure to use code formatting.
7. :blue_square: I have tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable
(an item can be marked as "complete" by reacting with the appropriate number)
If this ticket can be closed you can use the /close
command, and re-open it later if needed.You can use the following format
http://server-ip:2283/api/assets/<asset-id>/thumbnail?size=preview
it would just be a really really simple api request for taken date = "datetime format"
ah yes, but i'm looking for something like
i kinda don't really get it sorry
yea i'm right there?
what is still unclear?
yea so let's say
i need to very simply request images taken on a date
This is the endpoint
http://server-ip:2283/api/search/metadata
POSTthis is the body

yessir
but how would i query
sorry i'm quite new to this
The API document link above showed you a few ways here

using curl, javascript, go or Python
thanks
payload = json.dumps({
"checksum": "string",
"city": "string",
"country": "string",
"createdAfter": "string",
"createdBefore": "string",
"deviceAssetId": "string",
"deviceId": "string",
"encodedVideoPath": "string",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"isArchived": True,
"isEncoded": True,
"isFavorite": True,
"isMotion": True,
"isNotInAlbum": True,
"isOffline": True,
"isVisible": True,
"lensModel": "string",
"libraryId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"make": "string",
"model": "string",
"order": "asc",
"originalFileName": "string",
"originalPath": "string",
"page": 0,
"personIds": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"previewPath": "string",
"size": 0,
"state": "string",
"takenAfter": "string",
"takenBefore": "string",
"thumbnailPath": "string",
"trashedAfter": "string",
"trashedBefore": "string",
"type": "IMAGE",
"updatedAfter": "string",
"updatedBefore": "string",
"withArchived": False,
"withDeleted": True,
"withExif": True,
"withPeople": True,
"withStacked": True
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
oh sorry not to spam
my bad
what is the return of this?
like would it response me a text?
The assetIds
then how does one get the image?
Then You can use the following format
http://server-ip:2283/api/assets/<asset-id>/thumbnail?size=preview
to get the image fileaha
oh so thumbnail is the full resolution?
https://immich.app/docs/api/view-asset
Possible values: [preview, thumbnail]
preview is the small thumb you see on the timeline
thumbnail is the large file in the detail viewapi_key1 = get_key_by_name(conn,'immich')
Immich server details
immich_server_url = 'http://100.85.11.26:2283/api/search/metadata'
access_token = api_key1
Function to get the latest images
def get_latest_images():
headers = {
'Authorization': f'Bearer {access_token}'
}
params = {
'size': 10, # Number of images to fetch
'type': 'IMAGE',
'order': 'desc'
}
response = requests.post(f'{immich_server_url}/api/search/smart', headers=headers, json=params)
if response.status_code == 200:
return response.json().get('items', [])
else:
st.error('Failed to fetch images')
return []
sorry brother
but let's say
this is my python script
how do i send a request
i'm super lost right
use backtick for code please
http://server-ip:2283/api/assets/<asset-id>/original
this is to get the original
sorry can't walk you through this, please use Google
ah this is how you send codes

Hey bro
is this norma?
like expected
until i put in more query?
like when i do 172.19.01:238 it ping me that

but then oncce i actually do the search/metadata it doesn't work
Hey @Alex, sorry for taking this old thread up, but what's the difference between "takenAfter" vs "createdAfter" in the POST /search/metadata? Same goes for "takenBefore" vs "createdBefore". With "createdBefore" + "createdAfter" I'm getting results only for 2023 and 2024 from my Immich instance, an empty results for all other years 2010-2022, but with "takenBefore" + "takenAfter" the results are there.
iirc
takenAfter
is about the date the photo is taken while created
is the date the file is ingested into ImmichThank you!
Not sure that the behaviour I described above is intended, so FYI
Thanks! I believe we are using
taken
property for our search