Replies: 6 comments 17 replies
-
I can try to explain about the use of Curl here, but I think it is less relevant because as you mentioned it is something that should be in the documentation. |
Beta Was this translation helpful? Give feedback.
-
My desired API usage job is currently limited to the question: |
Beta Was this translation helpful? Give feedback.
-
I changed it from feature request into Q&A. To avoid it to be closed. |
Beta Was this translation helpful? Give feedback.
-
I wasn't able to find documentation either (how to authorize with an API key). Appears you need another header item Example Windows Curl:
Edit..........the documentation does have the info. However, is not displayed by default and you must hit |
Beta Was this translation helpful? Give feedback.
-
Has the same issue, I wanna call the api with the api key to get the album and image data, but don't want to dive info the immich code, I can not find a way to do this |
Beta Was this translation helpful? Give feedback.
-
For anyone struggling to get a API call working to trigger the library scan, here is what I did: First you need to create an API key by clicking your user icon at the top-right. Then click API Keys, and create a new one. Name it whatever, I named mine Automations. Copy the key to a Notepad. In that same Notepad, a few lines down, paste this, then move the API key to where it says "APIKEYHERE"
Change the x in the IP address to your Immich IP address. Change the PORT to whatever the port number is. Then open a CMD window on your Windows computer (if using CURL). Copy and paste the line from Notepad and hit enter to run it. You'll get a response with a bunch of code looking stuff. The very first one looks like "id":"LONGIDCODE". You want to copy the LONGIDCODE from here, between the quote marks. If you only created one library in your Immich, you should see only one ID. If you created multiple libraries, then you'll get multiple IDs. When you trigger a scan via the API, you have to do this for each library/ID individually. So the below steps, you may have to do it multiple times if you have multiple libraries. Copy the ID(s) from above into your Notepad.
Change the x and PORT and APIKEYHERE again, like you did in the first command. This time you also need to change the IDCODE to the new ID you just pasted into Notepad. Now copy that whole line and paste into the CMD window and hit enter. It should call Immich and trigger the library scan. If it worked, your command result wont show any responses. Now go into Immich>Jobs and refresh the page, you should see it scanning Active. If this worked, you're good to go! You can create a .bat file with the contents of your last command and save it to the desktop or somewhere else. Now you can just double click this file, and it will trigger Immich to update immediately. If you had multiple libraries, just put each of these commands on a new line and change the IDs in each one (leave all the API keys etc the same). Running the file will trigger all the libraries at once. This is a crude guide, there are many ways you can clean this up and automate it further. For example I am using an automation script to dynamically get the IDs of each library and run the commands for them, within a deeper photo syncing script that I tie into Syncthing. The sky's the limit. |
Beta Was this translation helpful? Give feedback.
-
The feature
immich administrators can automate external libraries to be rescanned in the GUI. This is great, but it is limited.
On the other side, the API has needed functionality:
https://immich.app/docs/api/scan-library/
contains some code, how to refreshAllFiles
https://immich.app/docs/api/remove-offline-files
I want to call this and automate. But how?
There are cURL examples, but I have no idea, what to do and how to use them. I even don't know what cURL is.
Could this be explained in the docs for dummies like me? Some first steps, how to start
Or maybe some links to existing docs. Just to get a point, where to start. I have no idea, how to use the API at all. https://immich.app/docs/api/introduction is empty, and the next page starts with code examples.
And I would like to know if these library commands can be used also with the default library, especially to remove offline files.
How to mark assets as offline, I found a manual way from the maintenance page to export JSON over a script into the database. I can't automate, but at least it is a way.
Platform
Beta Was this translation helpful? Give feedback.
All reactions