Jellyfin Forum
API endpoint to scan a single library - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions)
+--- Thread: API endpoint to scan a single library (/t-api-endpoint-to-scan-a-single-library)



API endpoint to scan a single library - alextruppel - 2025-02-12

Hi everyone! I know this can be used to trigger a scan of all libraries in Jellyfin:

Code:
http://jellyfin-ip-etc.../library/refresh?api_key=my-api-key

But is there a way to trigger a refresh of just a single library? This is because I have multiple libraries, some smaller libraries have new files being constantly added, whereas some large libraries almost never change and also take easily 1 hour or more to scan, not to mention that they pull 80MB/s from my NAS during the entire time of the scan. Ideally, I'd be able to trigger a re-scan of only some libraries when they change.

Thank you!


RE: API endpoint to scan a single library - TheDreadPirate - 2025-02-12

When I go to Dashboard > Libraries, and scan for updates on an individual library I see this in the browser developer console.

Code:
https://jellyfin-testing.domain.tld/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Refresh?Recursive=true&ImageRefreshMode=Default&MetadataRefreshMode=Default&ReplaceAllImages=false&RegenerateTrickplay=false&ReplaceAllMetadata=false

Looks like the library has an Items ID that you need to use?


RE: API endpoint to scan a single library - arjuan - 2025-03-31

The API documentation is a good place to start for this type of question Smiling-face

https://api.jellyfin.org/#tag/Library/operation/PostUpdatedMedia

Here's an example cURL query to update a specific library path:


curl -H "X-MediaBrowser-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -H "Content-Type: application/json" -d '{"Updates": [{"Path":"/path/to/folder/","UpdateType":"scan"}]}' https://jellyfin.example.com/Library/Media/Updated



RE: API endpoint to scan a single library - I-G-1-1 - 2025-07-11

I know this post is old, but to trigger a single Library scan thanks to "url scheme" suggested by TheDreadPirate I solved writing this script:

Code:
#!/bin/sh

# CHANGE THESE:
JELLYFIN_SERVER="http://192.168.1.1:8096"
API_KEY="<YOUR_API_KEY>"

echo "Retrieving available libraries..."

# Get the list of libraries from the Jellyfin server using the API key for authentication
LIBRARIES=$(curl -s -H "X-Emby-Token: $API_KEY" "$JELLYFIN_SERVER/Library/VirtualFolders")

# Extract the names of the libraries from the JSON response
NAMES=$(echo "$LIBRARIES" | grep -o '"Name":"[^"]*"' | sed 's/"Name":"\(.*\)"/\1/')
# Extract the IDs of the libraries from the JSON response
IDS=$(echo "$LIBRARIES" | grep -o '"ItemId":"[^"]*"' | sed 's/"ItemId":"\(.*\)"/\1/')

# Combine and print the name and ID of each library in a readable format
paste <(echo "$NAMES") <(echo "$IDS") | while IFS=$'\t' read -r name id; do
  echo "Name: $name | ID: $id"
done

echo
read -p "Enter the ID of the library to scan: " LIBRARY_ID

if [[ -z "$LIBRARY_ID" ]]; then
  echo "Library ID not provided. Exiting."
  exit 1
fi

echo "Starting scan of library $LIBRARY_ID ..."
# Send a POST request to trigger a scan/refresh of the specified library on the Jellyfin server
curl -X POST "$JELLYFIN_SERVER/Items/$LIBRARY_ID/Refresh?Recursive=true&ImageRefreshMode=Default&MetadataRefreshMode=Default&ReplaceAllImages=false&RegenerateTrickplay=false&ReplaceAllMetadata=false" \
  -H "Content-Type: application/json" \
  -H "X-Emby-Token: $API_KEY"

echo
echo "Scan started (check the Jellyfin dashboard for status)."

exit 0