Immich. API
(ex_immich v0.1.1)
Copy Markdown
Public facade for the most common Immich API workflows.
This module combines:
- OAuth bootstrap (
authorize/2,callback/3) - Authenticated user lookup (
current_user/2) - Sync stream consumption (
sync_stream/3) - Sync acknowledgement posting (
sync_ack/3)
Most request functions accept shared_opts so callers can inject a custom
client implementation (for example in tests) while keeping the same API.
Typical usage
- Call
authorize/2and open the returned login URL. - After redirect, call
callback/3to build an authenticatedSession. - Use that
Sessionwithcurrent_user/2,sync_stream/3, andsync_ack/3.
Summary
Types
Standard API error shape returned by the configured client.
Options shared by authenticated API functions.
Sync acknowledgement identifier sent back to the server.
Options for sync_stream/3.
Sync type identifier sent to Immich sync APIs.
Functions
Initiates the OAuth flow by requesting PKCE parameters and an authorization URL.
Completes OAuth callback exchange and returns an authenticated session.
Fetches the currently authenticated user for a session.
Posts sync acknowledgements.
Opens the Immich sync stream and returns decoded NDJSON events.
Types
@type api_error() :: Immich.API.Client.api_error()
Standard API error shape returned by the configured client.
This includes transport failures, authentication/authorization failures,
and non-success HTTP responses mapped by Immich.API.Client.
@type sync_ack() :: String.t()
Sync acknowledgement identifier sent back to the server.
Each acknowledgement corresponds to an event previously received from
sync_stream/3.
@type sync_stream_opts() :: [reset?: boolean(), client: Immich.API.Client.t()]
Options for sync_stream/3.
Supported options:
- all
shared_opts :reset?- whentrue, requests a reset sync from the server (defaults tofalse)
@type sync_type() :: String.t()
Sync type identifier sent to Immich sync APIs.
Values are expected to match server-recognized type names (for example
"AssetsV1", "StacksV1").
Functions
@spec authorize(Immich.API.OAuth.redirect_uri(), Immich.API.OAuth.shared_opts()) :: {:ok, Immich.API.OAuth.login_url(), Immich.API.OAuth.oauth_context()} | {:error, Immich.API.OAuth.oauth_error()}
Initiates the OAuth flow by requesting PKCE parameters and an authorization URL.
Returns the login URL and OAuth context required by callback/3.
This delegates to Immich.API.OAuth.authorize/2.
See Immich.API.OAuth.authorize/2 for details.
@spec callback( Immich.API.OAuth.callback_uri(), Immich.API.OAuth.oauth_context(), Immich.API.OAuth.shared_opts() ) :: {:ok, Immich.API.Session.t()} | {:error, Immich.API.OAuth.oauth_error()}
Completes OAuth callback exchange and returns an authenticated session.
The provided oauth_context must be the exact context returned by authorize/2.
This delegates to Immich.API.OAuth.callback/3.
See Immich.API.OAuth.callback/3 for details.
@spec current_user(Immich.API.Session.t(), shared_opts()) :: {:ok, map()} | {:error, api_error()}
Fetches the currently authenticated user for a session.
Uses session.base_url to build /api/users/me and attaches a bearer token
from session.access_token.
@spec sync_ack(Immich.API.Session.t(), [sync_ack()], shared_opts()) :: {:ok, map() | term()} | {:error, api_error()}
Posts sync acknowledgements.
Sends acknowledgements to /api/sync/ack using the authenticated session.
@spec sync_stream(Immich.API.Session.t(), [sync_type()], sync_stream_opts()) :: {:ok, Enumerable.t(map())} | {:error, api_error()}
Opens the Immich sync stream and returns decoded NDJSON events.
The request payload is forwarded as:
"types"fromsync_types"reset"fromopts[:reset?](defaults tofalse)
Returned events are yielded as a lazy enumerable of decoded maps.