Skip to content

AsyncClient

immichpy.client.main.AsyncClient

AsyncClient(*, api_key: str | None = None, access_token: str | None = None, base_url: str, http_client: ClientSession | None = None)

Async client for the Immich API.

Parameters:

Name Type Description Default
api_key str | None

The API key to use for authentication.

None
access_token str | None

The access token to use for authentication.

None
base_url str

The base URL of the Immich API.

required
http_client ClientSession | None

Inject your own connection session if you want to control networking.

None
Source code in immichpy/client/main.py
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
def __init__(
    self,
    *,
    api_key: str | None = None,
    access_token: str | None = None,
    base_url: str,
    http_client: ClientSession | None = None,
) -> None:
    """
    :param api_key: The API key to use for authentication.
    :param access_token: The access token to use for authentication.
    :param base_url: The base URL of the Immich API.
    :param http_client: Inject your own connection session if you want to control networking.
    """
    self._owns_http_client = http_client is None
    self._injected_http_client = http_client
    self._config: Final[Configuration] = _build_configuration(
        api_key=api_key,
        access_token=access_token,
        base_url=base_url,
    )
    self.base_client: Final[ApiClient] = ApiClient(configuration=self._config)
    self.base_client.user_agent = "immichpy"

    # Allow caller to inject a pre-configured aiohttp session.
    if http_client is not None:
        self.base_client.rest_client.pool_manager = http_client

    # API groups (single upstream API, not microservices)
    self.activities = ActivitiesApi(self.base_client)
    self.albums = AlbumsApi(self.base_client)
    self.api_keys = APIKeysApi(self.base_client)
    self.assets = AssetsApiWrapped(self.base_client)
    self.auth = AuthenticationApi(self.base_client)
    self.auth_admin = AuthenticationAdminApi(self.base_client)
    self.backups = DatabaseBackupsAdminApi(self.base_client)
    self.deprecated = DeprecatedApi(self.base_client)
    self.download = DownloadApiWrapped(self.base_client)
    self.duplicates = DuplicatesApi(self.base_client)
    self.faces = FacesApi(self.base_client)
    self.jobs = JobsApi(self.base_client)
    self.libraries = LibrariesApi(self.base_client)
    self.maintenance_admin = MaintenanceAdminApi(self.base_client)
    self.map = MapApi(self.base_client)
    self.memories = MemoriesApi(self.base_client)
    self.notifications = NotificationsApi(self.base_client)
    self.notifications_admin = NotificationsAdminApi(self.base_client)
    self.partners = PartnersApi(self.base_client)
    self.people = PeopleApi(self.base_client)
    self.plugins = PluginsApi(self.base_client)
    self.queues = QueuesApi(self.base_client)
    self.search = SearchApi(self.base_client)
    self.server = ServerApi(self.base_client)
    self.sessions = SessionsApi(self.base_client)
    self.shared_links = SharedLinksApi(self.base_client)
    self.stacks = StacksApi(self.base_client)
    self.sync = SyncApi(self.base_client)
    self.system_config = SystemConfigApi(self.base_client)
    self.system_metadata = SystemMetadataApi(self.base_client)
    self.tags = TagsApi(self.base_client)
    self.timeline = TimelineApi(self.base_client)
    self.trash = TrashApi(self.base_client)
    self.users = UsersApiWrapped(self.base_client)
    self.users_admin = UsersAdminApi(self.base_client)
    self.views = ViewsApi(self.base_client)
    self.workflows = WorkflowsApi(self.base_client)

activities instance-attribute

activities: ActivitiesApi = ActivitiesApi(base_client)

An activity is a like or a comment made by a user on an asset or album.

See ActivitiesApi for available methods and Immich API Documentation for more information.

albums instance-attribute

albums: AlbumsApi = AlbumsApi(base_client)

An album is a collection of assets that can be shared with other users or via shared links.

See AlbumsApi for available methods and Immich API Documentation for more information.

api_keys instance-attribute

api_keys: APIKeysApi = APIKeysApi(base_client)

An api key can be used to programmatically access the Immich API.

See APIKeysApi for available methods and Immich API Documentation for more information.

assets instance-attribute

assets: AssetsApiWrapped = AssetsApiWrapped(base_client)

An asset is an image or video that has been uploaded to Immich.

See AssetsApiWrapped for available methods and Immich API Documentation for more information.

auth instance-attribute

auth: AuthenticationApi = AuthenticationApi(base_client)

Endpoints related to user authentication, including OAuth.

See AuthenticationApi for available methods and Immich API Documentation for more information.

auth_admin instance-attribute

auth_admin: AuthenticationAdminApi = AuthenticationAdminApi(base_client)

Administrative endpoints related to authentication.

See AuthenticationAdminApi for available methods and Immich API Documentation for more information.

deprecated instance-attribute

deprecated: DeprecatedApi = DeprecatedApi(base_client)

Deprecated endpoints that are planned for removal in the next major release.

See DeprecatedApi for available methods and Immich API Documentation for more information.

download instance-attribute

download: DownloadApiWrapped = DownloadApiWrapped(base_client)

Endpoints for downloading assets or collections of assets.

See DownloadApiWrapped for available methods and Immich API Documentation for more information.

duplicates instance-attribute

duplicates: DuplicatesApi = DuplicatesApi(base_client)

Endpoints for managing and identifying duplicate assets.

See DuplicatesApi for available methods and Immich API Documentation for more information.

faces instance-attribute

faces: FacesApi = FacesApi(base_client)

A face is a detected human face within an asset, which can be associated with a person. Faces are normally detected via machine learning, but can also be created via manually.

See FacesApi for available methods and Immich API Documentation for more information.

jobs instance-attribute

jobs: JobsApi = JobsApi(base_client)

Queues and background jobs are used for processing tasks asynchronously. Queues can be paused and resumed as needed.

See JobsApi for available methods and Immich API Documentation for more information.

libraries instance-attribute

libraries: LibrariesApi = LibrariesApi(base_client)

An external library is made up of input file paths or expressions that are scanned for asset files. Discovered files are automatically imported. Assets much be unique within a library, but can be duplicated across libraries. Each user has a default upload library, and can have one or more external libraries.

See LibrariesApi for available methods and Immich API Documentation for more information.

maintenance_admin instance-attribute

maintenance_admin: MaintenanceAdminApi = MaintenanceAdminApi(base_client)

Maintenance mode allows you to put Immich in a read-only state to perform various operations.

See MaintenanceAdminApi for available methods and Immich API Documentation for more information.

map instance-attribute

map: MapApi = MapApi(base_client)

Map endpoints include supplemental functionality related to geolocation, such as reverse geocoding and retrieving map markers for assets with geolocation data.

See MapApi for available methods and Immich API Documentation for more information.

memories instance-attribute

memories: MemoriesApi = MemoriesApi(base_client)

A memory is a specialized collection of assets with dedicated viewing implementations in the web and mobile clients. A memory includes fields related to visibility and are automatically generated per user via a background job.

See MemoriesApi for available methods and Immich API Documentation for more information.

notifications instance-attribute

notifications: NotificationsApi = NotificationsApi(base_client)

A notification is a specialized message sent to users to inform them of important events. Currently, these notifications are only shown in the Immich web application.

See NotificationsApi for available methods and Immich API Documentation for more information.

notifications_admin instance-attribute

notifications_admin: NotificationsAdminApi = NotificationsAdminApi(base_client)

Notification administrative endpoints.

See NotificationsAdminApi for available methods and Immich API Documentation for more information.

partners instance-attribute

partners: PartnersApi = PartnersApi(base_client)

A partner is a link with another user that allows sharing of assets between two users.

See PartnersApi for available methods and Immich API Documentation for more information.

people instance-attribute

people: PeopleApi = PeopleApi(base_client)

A person is a collection of faces, which can be favorited and named. A person can also be merged into another person. People are automatically created via the face recognition job.

See PeopleApi for available methods and Immich API Documentation for more information.

plugins instance-attribute

plugins: PluginsApi = PluginsApi(base_client)

A plugin is an installed module that makes filters and actions available for the workflow feature.

See PluginsApi for available methods and Immich API Documentation for more information.

queues instance-attribute

queues: QueuesApi = QueuesApi(base_client)

Queues and background jobs are used for processing tasks asynchronously. Queues can be paused and resumed as needed.

See QueuesApi for available methods and Immich API Documentation for more information.

search instance-attribute

search: SearchApi = SearchApi(base_client)

Endpoints related to searching assets via text, smart search, optical character recognition (OCR), and other filters like person, album, and other metadata. Search endpoints usually support pagination and sorting.

See SearchApi for available methods and Immich API Documentation for more information.

server instance-attribute

server: ServerApi = ServerApi(base_client)

Information about the current server deployment, including version and build information, available features, supported media types, and more.

See ServerApi for available methods and Immich API Documentation for more information.

sessions instance-attribute

sessions: SessionsApi = SessionsApi(base_client)

A session represents an authenticated login session for a user. Sessions also appear in the web application as "Authorized devices".

See SessionsApi for available methods and Immich API Documentation for more information.

shared_links: SharedLinksApi = SharedLinksApi(base_client)

A shared link is a public url that provides access to a specific album, asset, or collection of assets. A shared link can be protected with a password, include a specific slug, allow or disallow downloads, and optionally include an expiration date.

See SharedLinksApi for available methods and Immich API Documentation for more information.

stacks instance-attribute

stacks: StacksApi = StacksApi(base_client)

A stack is a group of related assets. One asset is the "primary" asset, and the rest are "child" assets. On the main timeline, stack parents are included by default, while child assets are hidden.

See StacksApi for available methods and Immich API Documentation for more information.

sync instance-attribute

sync: SyncApi = SyncApi(base_client)

A collection of endpoints for the new mobile synchronization implementation.

See SyncApi for available methods and Immich API Documentation for more information.

system_config instance-attribute

system_config: SystemConfigApi = SystemConfigApi(base_client)

Endpoints to view, modify, and validate the system configuration settings.

See SystemConfigApi for available methods and Immich API Documentation for more information.

system_metadata instance-attribute

system_metadata: SystemMetadataApi = SystemMetadataApi(base_client)

Endpoints to view, modify, and validate the system metadata, which includes information about things like admin onboarding status.

See SystemMetadataApi for available methods and Immich API Documentation for more information.

tags instance-attribute

tags: TagsApi = TagsApi(base_client)

A tag is a user-defined label that can be applied to assets for organizational purposes. Tags can also be hierarchical, allowing for parent-child relationships between tags.

See TagsApi for available methods and Immich API Documentation for more information.

timeline instance-attribute

timeline: TimelineApi = TimelineApi(base_client)

Specialized endpoints related to the timeline implementation used in the web application. External applications or tools should not use or rely on these endpoints, as they are subject to change without notice.

See TimelineApi for available methods and Immich API Documentation for more information.

trash instance-attribute

trash: TrashApi = TrashApi(base_client)

Endpoints for managing the trash can, which includes assets that have been discarded. Items in the trash are automatically deleted after a configured amount of time.

See TrashApi for available methods and Immich API Documentation for more information.

users instance-attribute

users: UsersApiWrapped = UsersApiWrapped(base_client)

Endpoints for viewing and updating the current users, including product key information, profile picture data, onboarding progress, and more.

See UsersApiWrapped for available methods and Immich API Documentation for more information.

users_admin instance-attribute

users_admin: UsersAdminApi = UsersAdminApi(base_client)

Administrative endpoints for managing users, including creating, updating, deleting, and restoring users. Also includes endpoints for resetting passwords and PIN codes.

See UsersAdminApi for available methods and Immich API Documentation for more information.

views instance-attribute

views: ViewsApi = ViewsApi(base_client)

Endpoints for specialized views, such as the folder view.

See ViewsApi for available methods and Immich API Documentation for more information.

workflows instance-attribute

workflows: WorkflowsApi = WorkflowsApi(base_client)

A workflow is a set of actions that run whenever a triggering event occurs. Workflows also can include filters to further limit execution.

See WorkflowsApi for available methods and Immich API Documentation for more information.

__aenter__ async

__aenter__() -> 'AsyncClient'

Enter the context manager.

Source code in immichpy/client/main.py
385
386
387
388
389
390
async def __aenter__(self) -> "AsyncClient":
    """Enter the context manager."""
    if self._injected_http_client is None:
        self._injected_http_client = ClientSession()
    self.base_client.rest_client.pool_manager = self._injected_http_client
    return self

__aexit__ async

__aexit__(exc_type, exc_val, exc_tb) -> None

Exit the context manager.

Source code in immichpy/client/main.py
392
393
394
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
    """Exit the context manager."""
    await self.close()

close async

close() -> None

Close the client and release resources.

Source code in immichpy/client/main.py
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
async def close(self) -> None:
    """Close the client and release resources."""

    rest_client = self.base_client.rest_client
    session = rest_client.pool_manager

    # Always detach so base_client doesn't hold stale refs
    rest_client.pool_manager = None

    # Only close if WE created it
    if self._owns_http_client and session is not None and not session.closed:
        await session.close()

    # Now close higher-level stuff that does NOT own the session
    await self.base_client.close()