Scan a Partial Library
As you add media items to a library, you will need to scan the library to have the items appear in Plex. If you have a many media items in a library, the scan can take a long time if you scan the whole library.
The solution is to only scan the items that have been added to the folder associated with the library.
This API command will allow you to scan a specific folder that contains the media item for a library, which will reduce the amount of time needed for scanning.
URL
GET http://{ip_address}:32400/library/sections/{id}/refresh?path={folder}&X-Plex-Token={plex_token}
Parameters
Name | Description |
---|---|
ip_address | The IP address of the Plex Media server. |
plex_token | The Plex token. |
id | The key associated with the library. This key can be found by calling the Libraries API command. |
folder | The path of the folder to be scanned for new media items. This value needs to be URL encoded. |
Return Status
HTTP Code | Description |
---|---|
200 | Success - The request was successful. |
401 | Unauthorized - The Plex token provided was not valid. |
Response
No response is returned. You will be able to see the scan API command run from the Plex console.
Remarks
This command will return immediately, but the scan will still be running on the Plex server.
Whenever you want to add movies, add TV shows, or add music to Plex, you will first add the media files to your Plex library location, and then run this scan.
Examples
curl -X GET http://{ip_address}:32400/library/sections/{id}/refresh?path={folder}&X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/library/sections/{id}/refresh?path={folder}&X-Plex-Token={plex_token} response = requests.get(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/sections/{id}/refresh?path={folder}&X-Plex-Token={plex_token}' -Method 'GET' Write-Output $response
Script examples
Below are a list of post and articles that provide an example that use this API endpoint: