pub struct ImmichClient { /* private fields */ }Expand description
Client for interacting with the Immich REST API.
Handles authentication via API key and provides typed methods for API endpoints.
§Example
use immich_lib::ImmichClient;
let client = ImmichClient::new("https://immich.example.com", "your-api-key")?;
let duplicates = client.get_duplicates().await?;
println!("Found {} duplicate groups", duplicates.len());Implementations§
Source§impl ImmichClient
impl ImmichClient
Sourcepub fn new(base_url: &str, api_key: &str) -> Result<Self>
pub fn new(base_url: &str, api_key: &str) -> Result<Self>
Creates a new ImmichClient with the given base URL and API key.
§Arguments
base_url- The base URL of the Immich server (e.g.,https://immich.example.com)api_key- The API key for authentication (created in Immich web UI)
§Errors
Returns an error if:
- The base_url is not a valid URL
- The api_key is empty or contains invalid characters
- The HTTP client cannot be built
Sourcepub async fn get_duplicates(&self) -> Result<Vec<DuplicateGroup>>
pub async fn get_duplicates(&self) -> Result<Vec<DuplicateGroup>>
Fetches all duplicate groups from the Immich server.
§Returns
A vector of duplicate groups, each containing assets that Immich has identified as duplicates. Returns an empty vector if no duplicates exist.
§Errors
Returns an error if:
- The HTTP request fails (network error, timeout)
- The server returns an error response (401 unauthorized, etc.)
- The response cannot be parsed as JSON
Sourcepub async fn get_all_assets(&self) -> Result<Vec<AssetResponse>>
pub async fn get_all_assets(&self) -> Result<Vec<AssetResponse>>
Fetches all assets from the Immich server.
Uses pagination to handle large libraries. Automatically filters out trashed assets.
§Returns
A vector of all non-trashed assets in the library.
§Errors
Returns an error if:
- The HTTP request fails (network error, timeout)
- The server returns an error response (401 unauthorized, etc.)
- The response cannot be parsed as JSON
Sourcepub async fn get_asset(&self, asset_id: &str) -> Result<AssetResponse>
pub async fn get_asset(&self, asset_id: &str) -> Result<AssetResponse>
Fetches a single asset by ID.
§Arguments
asset_id- The ID of the asset to fetch
§Returns
The asset with its EXIF metadata.
§Errors
Returns an error if:
- The HTTP request fails (network error, timeout)
- The server returns an error response (401 unauthorized, 404 not found)
- The response cannot be parsed as JSON
Sourcepub async fn download_asset(&self, asset_id: &str, path: &Path) -> Result<u64>
pub async fn download_asset(&self, asset_id: &str, path: &Path) -> Result<u64>
Downloads an asset’s original file to the specified path.
Uses streaming to avoid buffering the entire file in memory, making it suitable for large files.
§Arguments
asset_id- The ID of the asset to downloadpath- The destination path to save the file
§Returns
The total number of bytes written to the file.
§Errors
Returns an error if:
- The HTTP request fails
- The server returns an error response
- The file cannot be created or written to
Sourcepub async fn update_asset_metadata(
&self,
asset_id: &str,
latitude: Option<f64>,
longitude: Option<f64>,
date_time_original: Option<&str>,
description: Option<&str>,
) -> Result<()>
pub async fn update_asset_metadata( &self, asset_id: &str, latitude: Option<f64>, longitude: Option<f64>, date_time_original: Option<&str>, description: Option<&str>, ) -> Result<()>
Updates an asset’s metadata fields.
This method allows updating GPS coordinates, date/time, and description for an asset. Only non-None fields will be sent in the update request.
§Arguments
asset_id- The ID of the asset to updatelatitude- New GPS latitude (optional)longitude- New GPS longitude (optional)date_time_original- New original date/time as ISO 8601 string (optional)description- New description (optional)
§Errors
Returns an error if:
- The HTTP request fails
- The server returns an error response
Sourcepub async fn upload_asset(&self, file_path: &Path) -> Result<UploadResponse>
pub async fn upload_asset(&self, file_path: &Path) -> Result<UploadResponse>
Trait Implementations§
Source§impl Clone for ImmichClient
impl Clone for ImmichClient
Source§fn clone(&self) -> ImmichClient
fn clone(&self) -> ImmichClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ImmichClient
impl !UnwindSafe for ImmichClient
impl Freeze for ImmichClient
impl Send for ImmichClient
impl Sync for ImmichClient
impl Unpin for ImmichClient
impl UnsafeUnpin for ImmichClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more