Response Objects

class yadisk.objects.AsyncFilesResourceListObject(files_resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: FilesResourceListObject

Flat list of files.

Parameters:
  • files_resource_list – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • items – list, flat list of files (AsyncResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

class yadisk.objects.AsyncLastUploadedResourceListObject(last_uploaded_resources_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: LastUploadedResourceListObject

List of last uploaded resources.

Parameters:
  • last_uploaded_resources_list – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • items – list, list of resources (AsyncResourceObject)

  • limit – int, maximum number of elements in the list

class yadisk.objects.AsyncOperationLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: OperationLinkObject

Operation link object.

Parameters:
  • link – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

async get_status(**kwargs) → Literal['in-progress', 'success', 'failed'][source]

Get operation status.

Parameters:
  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

OperationNotFoundError – requested operation was not found

Returns:

str, "in-progress" indicates that the operation is currently running, "success" indicates that the operation was successful, "failed" means that the operation failed

async wait(**kwargs) → None[source]

Wait until an operation is completed. If the operation fails, an exception is raised. Waiting is performed by calling asyncio.sleep.

Parameters:
  • poll_interval – float, interval in seconds between subsequent operation status queries

  • poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
class yadisk.objects.AsyncPublicResourceLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: PublicResourceLinkObject, AsyncResourceObjectMethodsMixin

Public resource link object.

Parameters:
  • link – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

  • public_key – str, public key of the resource

  • public_url – str, public URL of the resource

class yadisk.objects.AsyncPublicResourceListObject(public_resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: PublicResourceListObject

List of public resources.

Parameters:
  • public_resource_list – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • sort – str, sort type

  • items – list, list of resources (AsyncResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

  • path – str, path to the directory that contains the elements of the list

  • total – int, number of elements in the list

  • public_key – str, public key of the resource

class yadisk.objects.AsyncPublicResourceObject(public_resource: dict | None = None, yadisk: Any | None = None)[source]

Bases: PublicResourceObject, AsyncResourceObjectMethodsMixin

Public resource object.

Parameters:
  • resource – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • antivirus_status – str, antivirus check status

  • file – str, download URL

  • size – int, file size

  • public_key – str, public resource key

  • sha256 – str, SHA256 hash

  • md5 – str, MD5 hash

  • embedded – AsyncPublicResourceObject, list of nested resources

  • name – str, filename

  • exif – EXIFObject, EXIF metadata

  • resource_id – str, resource ID

  • custom_properties – dict, custom resource properties

  • public_url – str, public URL

  • share – ShareInfoObject, shared folder information

  • modified – datetime.datetime, date of last modification

  • created – datetime.datetime, date of creation

  • photoslice_time – datetime.datetime, photo/video creation date

  • mime_type – str, MIME type

  • path – str, path to the resource

  • preview – str, file preview URL

  • comment_ids – CommentIDsObject, comment IDs

  • type – str, type (“file” or “dir”)

  • media_type – str, file type as determined by Yandex.Disk

  • revision – int, Yandex.Disk revision at the time of last modification

  • view_count – int, number of times the public resource was viewed

  • owner – UserPublicInfoObject, owner of the public resource

class yadisk.objects.AsyncPublicResourcesListObject(public_resources_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: PublicResourcesListObject

List of public resources.

Parameters:
  • public_resources_list – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • items – list, list of public resources (AsyncPublicResourceObject)

  • type – str, resource type to filter by

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

class yadisk.objects.AsyncResourceLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: ResourceLinkObject, AsyncResourceObjectMethodsMixin

Resource link object.

Parameters:
  • link – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

  • path – str, path to the resource

class yadisk.objects.AsyncResourceListObject(resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: ResourceListObject

List of resources.

Parameters:
  • resource_list – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • sort – str, sort type

  • items – list, list of resources (AsyncResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

  • path – str, path to the directory that contains the elements of the list

  • total – int, number of elements in the list

class yadisk.objects.AsyncResourceObject(resource: dict | None = None, yadisk: Any | None = None)[source]

Bases: ResourceObject, AsyncResourceObjectMethodsMixin

Resource object.

Parameters:
  • resource – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • antivirus_status – str, antivirus check status

  • file – str, download URL

  • size – int, file size

  • public_key – str, public resource key

  • sha256 – str, SHA256 hash

  • md5 – str, MD5 hash

  • embedded – AsyncResourceListObject, list of nested resources

  • name – str, filename

  • exif – EXIFObject, EXIF metadata

  • resource_id – str, resource ID

  • custom_properties – dict, custom resource properties

  • public_url – str, public URL

  • share – ShareInfoObject, shared folder information

  • modified – datetime.datetime, date of last modification

  • created – datetime.datetime, date of creation

  • photoslice_time – datetime.datetime, photo/video creation date

  • mime_type – str, MIME type

  • path – str, path to the resource

  • preview – str, file preview URL

  • comment_ids – CommentIDsObject, comment IDs

  • type – str, type (“file” or “dir”)

  • media_type – str, file type as determined by Yandex.Disk

  • revision – int, Yandex.Disk revision at the time of last modification

  • sizes – dict[str, str], mapping of all preview sizes, where keys are names and values are download links

class yadisk.objects.AsyncTrashResourceListObject(trash_resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: TrashResourceListObject

List of trash resources.

Parameters:
  • trash_resource_list – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • sort – str, sort type

  • items – list, list of resources (AsyncTrashResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

  • path – str, path to the directory that contains the elements of the list

  • total – int, number of elements in the list

class yadisk.objects.AsyncTrashResourceObject(trash_resource: dict | None = None, yadisk: Any | None = None)[source]

Bases: TrashResourceObject

Trash resource object.

Parameters:
  • trash_resource – dict or None

  • yadisk – AsyncClient or None, YaDisk object

Variables:
  • antivirus_status – str, antivirus check status

  • file – str, download URL

  • size – int, file size

  • public_key – str, public resource key

  • sha256 – str, SHA256 hash

  • md5 – str, MD5 hash

  • embedded – AsyncTrashResourceListObject, list of nested resources

  • name – str, filename

  • exif – EXIFObject, EXIF metadata

  • resource_id – str, resource ID

  • custom_properties – dict, custom resource properties

  • public_url – str, public URL

  • share – ShareInfoObject, shared folder information

  • modified – datetime.datetime, date of last modification

  • created – datetime.datetime, date of creation

  • photoslice_time – datetime.datetime, photo/video creation date

  • mime_type – str, MIME type

  • path – str, path to the resource

  • preview – str, file preview URL

  • comment_ids – CommentIDsObject, comment IDs

  • type – str, type (“file” or “dir”)

  • media_type – str, file type as determined by Yandex.Disk

  • revision – int, Yandex.Disk revision at the time of last modification

  • origin_path – str, original path

  • deleted – datetime.datetime, date of deletion

  • sizes – dict[str, str], mapping of all preview sizes, where keys are names and values are download links

async exists(relative_path: str | None = None, /, **kwargs) → bool[source]

Check whether the trash resource exists.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

async get_meta(relative_path: str | None = None, /, **kwargs) → AsyncTrashResourceObject[source]

Get meta information about a trash resource.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_crop – bool, cut the preview to the size specified in the preview_size

  • sort – str, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

AsyncTrashResourceObject

async get_type(relative_path: str | None = None, /, **kwargs) → str[source]

Get trash resource type.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

“file” or “dir”

async is_dir(relative_path: str | None = None, /, **kwargs) → bool[source]

Check whether resource is a trash directory.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

async is_file(relative_path: str | None = None, /, **kwargs) → bool[source]

Check whether resource is a trash file.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a file, False otherwise (even if it doesn’t exist)

async listdir(relative_path: str | None = None, /, **kwargs) → AsyncGenerator[AsyncTrashResourceObject, None][source]

Get contents of a trash resource.

Parameters:
  • relative_path – str or None, relative path to the directory in the trash bin

  • max_items – int or None, maximum number of returned items (None means unlimited)

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_crop – bool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

generator of AsyncTrashResourceObject

async remove(relative_path: str | None = None, /, **kwargs) → AsyncOperationLinkObject | None[source]

Remove a trash resource.

Parameters:
  • relative_path – str or None, relative path to the trash resource to be deleted

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • wait – bool, if True, the method will wait until the asynchronous operation is completed

  • poll_interval – float, interval in seconds between subsequent operation status queries

  • poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

AsyncOperationLinkObject if the operation is performed asynchronously, None otherwise

async restore(dst_path: str, /, **kwargs) → AsyncResourceLinkObject | 'AsyncOperationLinkObject'[source]
async restore(relative_path: str | None, dst_path: str, /, **kwargs) → AsyncResourceLinkObject | 'AsyncOperationLinkObject'

Restore a trash resource. Returns a link to the newly created resource or a link to the asynchronous operation.

This method takes 1 or 2 positional arguments:

  1. restore(dst_path, /, **kwargs)

  2. restore(relative_path=None, dst_path, /, **kwargs)

Parameters:
  • relative_path – str or None, relative path to the trash resource to be restored

  • dst_path – destination path

  • overwrite – bool, determines whether the destination can be overwritten

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • wait – bool, if True, the method will wait until the asynchronous operation is completed

  • poll_interval – float, interval in seconds between subsequent operation status queries

  • poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • aiohttp_args – dict, additional parameters for AIOHTTPSession

  • httpx_args – dict, additional parameters for AsyncHTTPXSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

AsyncResourceLinkObject or AsyncOperationLinkObject

class yadisk.objects.AvailableUntilVerboseObject(available_until_verbose: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Verbose information about the expiration date of a shared resource.

Variables:
  • enabled – bool, whether the expiration date is enabled

  • value – int, timestamp of the expiration date

class yadisk.objects.CommentIDsObject(comment_ids: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Comment IDs object.

Parameters:
Variables:
  • private_resource – str, comment ID for private resources

  • public_resource – str, comment ID for public resources

class yadisk.objects.DeviceCodeObject(device_code_object: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Result of Client.get_device_code() / AsyncClient.get_device_code().

Parameters:
  • device_code_object – dict or None

  • yadisk – YaDisk or None, YaDisk object

Variables:
  • device_code – str, device code that can be used for obtaining the token

  • user_code – str, code that the user should enter on the OAuth page

  • verification_url – str, URL of the OAuth page where user is expected to enter the user_code

  • interval – int, the minimum interval (in seconds) with which the app must request an OAuth token. If requests come more often, Yandex OAuth may respond with an error

  • expires_in – int, amount of time before the codes expire

class yadisk.objects.DiskInfoObject(disk_info: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Disk information object.

Parameters:
  • disk_info – dict or None

  • yadisk – YaDisk or None, YaDisk object

Variables:
  • deletion_restriction_days – int, number of days before file deletion after account lock

  • free_photounlim_end_date – int, timestamp in ms of expiration date of unlimited photo upload

  • hide_screenshots_in_photoslice – bool, tells whether the screenshots are hidden in photoslice

  • is_idm_managed_folder_address_access – bool, not clear what this is for

  • is_idm_managed_public_access – bool, not clear what this is for

  • is_legal_entity – bool, tells if the account belongs to a legal entity

  • is_paid – bool, tells if the account is paid or not

  • max_file_size – int, maximum supported file size (bytes)

  • paid_max_file_size – int, maximum supported file size for a paid account (bytes)

  • payment_flow – bool, tells if the user is involved in payment_flow

  • photounlim_size – int, total file size in unlimited photos

  • reg_time – datetime.datetime, Disk registration date

  • revision – int, current revision of Yandex.Disk

  • system_folders – SystemFoldersObject, paths to the system folders

  • total_space – int, total disk size (bytes)

  • trash_size – int, amount of space used by trash (bytes), part of used_space

  • unlimited_autoupload_enabled – bool, tells whether unlimited autoupload from mobile devices is enabled

  • used_space – int, amount of space used (bytes)

  • user – UserObject, owner of the disk

  • will_be_overdrawn – bool, tells if the user will be in overdraft upon reaching free_photounlim_end_date

class yadisk.objects.EXIFObject(exif: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

EXIF metadata object.

Parameters:
Variables:
  • date_time – datetime.datetime, capture date

  • gps_longitude – float, longitude of the photo’s location

  • gps_latitude – float, latitude of the photo’s location

class yadisk.objects.ErrorObject(error=None, yadisk=None)[source]

Bases: YaDiskObject

Mirrors Yandex.Disk REST API error object.

Parameters:
  • error – dict or None

  • yadisk – YaDisk or None, YaDisk object

Variables:
  • message – str, human-readable error message

  • description – str, technical error description

  • error – str, error code

class yadisk.objects.ExternalOrganizationIdVerboseObject(external_organization_id_verbose: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Verbose information about the external organization ID of a shared resource.

Variables:
  • enabled – bool, whether the external organization ID is enabled

  • value – str, external organization ID

class yadisk.objects.FilesResourceListObject(files_resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Flat list of files.

Parameters:
  • files_resource_list – dict or None

  • yadisk – Client/AsyncClient or None, YaDisk object

Variables:
  • items – list, flat list of files (ResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

class yadisk.objects.LastUploadedResourceListObject(last_uploaded_resources_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

List of last uploaded resources.

Parameters:
  • last_uploaded_resources_list – dict or None

  • yadisk – Client/AsyncClient or None, YaDisk object

Variables:
  • items – list, list of resources (ResourceObject)

  • limit – int, maximum number of elements in the list

class yadisk.objects.LinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Link object.

Parameters:
Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

class yadisk.objects.OperationLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: LinkObject

Operation link object.

Parameters:
Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

class yadisk.objects.OperationStatusObject(operation_status: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Operation status object.

Parameters:
  • operation_status – dict or None

  • yadisk – YaDisk or None, YaDisk object

Variables:

status – str, status of the operation

class yadisk.objects.PasswordVerboseObject(password_verbose: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Verbose information about the password of shared resource.

Variables:
  • enabled – bool, whether the password is enabled

  • value – str, password value

class yadisk.objects.PublicAccessObject(public_access: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Access settings of a shared resource.

Variables:
  • macros – List[Union[Literal[“employees”], Literal[“all”]]],, specifies who has access to the shared resource, must contain only one element

  • type – str, specifies the type of access, must be one of the following:

  • macro: access for all employees or all users

  • user: access for a specific user

  • group: access for a specific group

  • department: access for a specific department

Variables:
  • org_id – int, organization ID

  • id – str, user, group or department ID

  • rights – List[str], specifies the access rights

Valid access rights:

  • write: write access

  • read: read access

  • read_without_download: read access without download

  • read_with_password: read access with password

  • read_with_password_without_download: read access with password and without download

class yadisk.objects.PublicAvailableSettingsObject(public_available_settings: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Public settings of a shared resource for the current OAuth token owner.

Variables:
  • permissions – List[str], list of available permissions

  • address_access_sharing –

    str, specifies who has access to the shared resource, must be one of the following:

    • all: access for all users

    • inner: access for all employees

  • use_sharing – bool, whether the resource can be shared

  • macro_sharing –

    str, specifies who has access to the shared resource, must be one of the following:

    • all: access for all users

    • inner: access for all employees

  • default – List[PublicDefault], default public settings

class yadisk.objects.PublicDefaultObject(public_default: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Access settings of a shared resource.

Variables:
  • macros – List[Union[Literal[“employees”], Literal[“all”]]],, specifies who has access to the shared resource, must contain only one element

  • org_id – int, organization ID

  • rights – List[str], specifies the access rights

Valid access rights:

  • write: write access

  • read: read access

  • read_without_download: read access without download

  • read_with_password: read access with password

  • read_with_password_without_download: read access with password and without download

class yadisk.objects.PublicResourceLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: LinkObject

Public resource link object.

Parameters:
Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

  • public_key – str, public key of the resource

  • public_url – str, public URL of the resource

class yadisk.objects.PublicResourceListObject(public_resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: ResourceListObject

List of public resources.

Parameters:
  • public_resource_list – dict or None

  • yadisk – Client/AsyncClient or None, YaDisk object

Variables:
  • sort – str, sort type

  • items – list, list of resources (ResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

  • path – str, path to the directory that contains the elements of the list

  • total – int, number of elements in the list

  • public_key – str, public key of the resource

class yadisk.objects.PublicResourceObject(public_resource=None, yadisk=None)[source]

Bases: ResourceObject

Public resource object.

Parameters:
Variables:
  • antivirus_status – str, antivirus check status

  • file – str, download URL

  • size – int, file size

  • public_key – str, public resource key

  • sha256 – str, SHA256 hash

  • md5 – str, MD5 hash

  • embedded – PublicResourceObject, list of nested resources

  • name – str, filename

  • exif – EXIFObject, EXIF metadata

  • resource_id – str, resource ID

  • custom_properties – dict, custom resource properties

  • public_url – str, public URL

  • share – ShareInfoObject, shared folder information

  • modified – datetime.datetime, date of last modification

  • created – datetime.datetime, date of creation

  • photoslice_time – datetime.datetime, photo/video creation date

  • mime_type – str, MIME type

  • path – str, path to the resource

  • preview – str, file preview URL

  • comment_ids – CommentIDsObject, comment IDs

  • type – str, type (“file” or “dir”)

  • media_type – str, file type as determined by Yandex.Disk

  • revision – int, Yandex.Disk revision at the time of last modification

  • view_count – int, number of times the public resource was viewed

  • owner – UserPublicInfoObject, owner of the public resource

class yadisk.objects.PublicResourcesListObject(public_resources_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

List of public resources.

Parameters:
  • public_resources_list – dict or None

  • yadisk – Client/AsyncClient or None, YaDisk object

Variables:
  • items – list, list of public resources (PublicResourceObject)

  • type – str, resource type to filter by

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

class yadisk.objects.PublicSettingsObject(public_settings: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Public settings of a shared resource.

Variables:
  • available_until – int, timestamp indicating the expiration date of the link

  • read_only – bool, whether the resource is read-only

  • available_until_verbose – AvailableUntilVerboseObject, verbose information about the expiration date

  • password – str, password to access the resource

  • password_verbose – PasswordVerboseObject, verbose information about the password

  • external_organization_id – str, external organization ID

  • external_organization_id_verbose – ExternalOrganizationIdVerboseObject, verbose information about the external organization ID

  • accesses – List[PublicSettingsAccessObject], list of access settings

class yadisk.objects.ResourceDownloadLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: LinkObject

Resource download link.

Parameters:
Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

class yadisk.objects.ResourceLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: LinkObject

Resource link object.

Parameters:
Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

  • path – str, path to the resource

class yadisk.objects.ResourceListObject(resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

List of resources.

Parameters:
  • resource_list – dict or None

  • yadisk – Client/AsyncClient or None, YaDisk object

Variables:
  • sort – str, sort type

  • items – list, list of resources (ResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

  • path – str, path to the directory that contains the elements of the list

  • total – int, number of elements in the list

class yadisk.objects.ResourceObject(resource: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Resource object.

Parameters:
Variables:
  • antivirus_status – str, antivirus check status

  • file – str, download URL

  • size – int, file size

  • public_key – str, public resource key

  • sha256 – str, SHA256 hash

  • md5 – str, MD5 hash

  • embedded – ResourceListObject, list of nested resources

  • name – str, filename

  • exif – EXIFObject, EXIF metadata

  • resource_id – str, resource ID

  • custom_properties – dict, custom resource properties

  • public_url – str, public URL

  • share – ShareInfoObject, shared folder information

  • modified – datetime.datetime, date of last modification

  • created – datetime.datetime, date of creation

  • photoslice_time – datetime.datetime, photo/video creation date

  • mime_type – str, MIME type

  • path – str, path to the resource

  • preview – str, file preview URL

  • comment_ids – CommentIDsObject, comment IDs

  • type – str, type (“file” or “dir”)

  • media_type – str, file type as determined by Yandex.Disk

  • revision – int, Yandex.Disk revision at the time of last modification

  • sizes – dict[str, str], mapping of all preview sizes, where keys are names and values are download links

class yadisk.objects.ResourceUploadLinkObject(resource_upload_link: dict | None = None, yadisk: Any | None = None)[source]

Bases: LinkObject

Resource upload link.

Parameters:
  • resource_upload_link – dict or None

  • yadisk – Client/AsyncClient or None, YaDisk object

Variables:
  • operation_id – str, ID of the upload operation

  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

class yadisk.objects.ShareInfoObject(share_info: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Shared folder information object.

Parameters:
Variables:
  • is_root – bool, tells whether the folder is root

  • is_owned – bool, tells whether the user is the owner of this directory

  • rights – str, access rights

class yadisk.objects.SyncFilesResourceListObject(files_resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: FilesResourceListObject

Flat list of files.

Parameters:
  • files_resource_list – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • items – list, flat list of files (SyncResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

class yadisk.objects.SyncLastUploadedResourceListObject(last_uploaded_resources_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: LastUploadedResourceListObject

List of last uploaded resources.

Parameters:
  • last_uploaded_resources_list – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • items – list, list of resources (SyncResourceObject)

  • limit – int, maximum number of elements in the list

class yadisk.objects.SyncOperationLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: OperationLinkObject

Operation link object.

Parameters:
  • link – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

get_status(**kwargs) → Literal['in-progress', 'success', 'failed'][source]

Get operation status.

Parameters:
  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

OperationNotFoundError – requested operation was not found

Returns:

str, "in-progress" indicates that the operation is currently running, "success" indicates that the operation was successful, "failed" means that the operation failed

wait(**kwargs) → None[source]

Wait until an operation is completed. If the operation fails, an exception is raised. Waiting is performed by calling time.sleep.

Parameters:
  • poll_interval – float, interval in seconds between subsequent operation status queries

  • poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
class yadisk.objects.SyncPublicResourceLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: PublicResourceLinkObject, ResourceObjectMethodsMixin

Public resource link object.

Parameters:
  • link – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

  • public_key – str, public key of the resource

  • public_url – str, public URL of the resource

class yadisk.objects.SyncPublicResourceListObject(public_resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: PublicResourceListObject

List of public resources.

Parameters:
  • public_resource_list – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • sort – str, sort type

  • items – list, list of resources (SyncResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

  • path – str, path to the directory that contains the elements of the list

  • total – int, number of elements in the list

  • public_key – str, public key of the resource

class yadisk.objects.SyncPublicResourceObject(public_resource: dict | None = None, yadisk: Any | None = None)[source]

Bases: PublicResourceObject, ResourceObjectMethodsMixin

Public resource object.

Parameters:
  • resource – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • antivirus_status – str, antivirus check status

  • file – str, download URL

  • size – int, file size

  • public_key – str, public resource key

  • sha256 – str, SHA256 hash

  • md5 – str, MD5 hash

  • embedded – SyncPublicResourceObject, list of nested resources

  • name – str, filename

  • exif – EXIFObject, EXIF metadata

  • resource_id – str, resource ID

  • custom_properties – dict, custom resource properties

  • public_url – str, public URL

  • share – ShareInfoObject, shared folder information

  • modified – datetime.datetime, date of last modification

  • created – datetime.datetime, date of creation

  • photoslice_time – datetime.datetime, photo/video creation date

  • mime_type – str, MIME type

  • path – str, path to the resource

  • preview – str, file preview URL

  • comment_ids – CommentIDsObject, comment IDs

  • type – str, type (“file” or “dir”)

  • media_type – str, file type as determined by Yandex.Disk

  • revision – int, Yandex.Disk revision at the time of last modification

  • view_count – int, number of times the public resource was viewed

  • owner – UserPublicInfoObject, owner of the public resource

class yadisk.objects.SyncPublicResourcesListObject(public_resources_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: PublicResourcesListObject

List of public resources.

Parameters:
  • public_resources_list – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • items – list, list of public resources (SyncPublicResourceObject)

  • type – str, resource type to filter by

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

class yadisk.objects.SyncResourceLinkObject(link: dict | None = None, yadisk: Any | None = None)[source]

Bases: ResourceLinkObject, ResourceObjectMethodsMixin

Resource link object.

Parameters:
  • link – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • href – str, link URL

  • method – str, HTTP method

  • templated – bool, tells whether the URL is templated

  • path – str, path to the resource

class yadisk.objects.SyncResourceListObject(resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: ResourceListObject

List of resources.

Parameters:
  • resource_list – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • sort – str, sort type

  • items – list, list of resources (SyncResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

  • path – str, path to the directory that contains the elements of the list

  • total – int, number of elements in the list

class yadisk.objects.SyncResourceObject(resource: dict | None = None, yadisk: Any | None = None)[source]

Bases: ResourceObject, ResourceObjectMethodsMixin

Resource object.

Parameters:
  • resource – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • antivirus_status – str, antivirus check status

  • file – str, download URL

  • size – int, file size

  • public_key – str, public resource key

  • sha256 – str, SHA256 hash

  • md5 – str, MD5 hash

  • embedded – SyncResourceListObject, list of nested resources

  • name – str, filename

  • exif – EXIFObject, EXIF metadata

  • resource_id – str, resource ID

  • custom_properties – dict, custom resource properties

  • public_url – str, public URL

  • share – ShareInfoObject, shared folder information

  • modified – datetime.datetime, date of last modification

  • created – datetime.datetime, date of creation

  • photoslice_time – datetime.datetime, photo/video creation date

  • mime_type – str, MIME type

  • path – str, path to the resource

  • preview – str, file preview URL

  • comment_ids – CommentIDsObject, comment IDs

  • type – str, type (“file” or “dir”)

  • media_type – str, file type as determined by Yandex.Disk

  • revision – int, Yandex.Disk revision at the time of last modification

  • sizes – dict[str, str], mapping of all preview sizes, where keys are names and values are download links

class yadisk.objects.SyncTrashResourceListObject(trash_resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: TrashResourceListObject

List of trash resources.

Parameters:
  • trash_resource_list – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • sort – str, sort type

  • items – list, list of resources (SyncTrashResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

  • path – str, path to the directory that contains the elements of the list

  • total – int, number of elements in the list

class yadisk.objects.SyncTrashResourceObject(trash_resource: dict | None = None, yadisk: Any | None = None)[source]

Bases: TrashResourceObject

Trash resource object.

Parameters:
  • trash_resource – dict or None

  • yadisk – Client or None, YaDisk object

Variables:
  • antivirus_status – str, antivirus check status

  • file – str, download URL

  • size – int, file size

  • public_key – str, public resource key

  • sha256 – str, SHA256 hash

  • md5 – str, MD5 hash

  • embedded – SyncTrashResourceListObject, list of nested resources

  • name – str, filename

  • exif – EXIFObject, EXIF metadata

  • resource_id – str, resource ID

  • custom_properties – dict, custom resource properties

  • public_url – str, public URL

  • share – ShareInfoObject, shared folder information

  • modified – datetime.datetime, date of last modification

  • created – datetime.datetime, date of creation

  • photoslice_time – datetime.datetime, photo/video creation date

  • mime_type – str, MIME type

  • path – str, path to the resource

  • preview – str, file preview URL

  • comment_ids – CommentIDsObject, comment IDs

  • type – str, type (“file” or “dir”)

  • media_type – str, file type as determined by Yandex.Disk

  • revision – int, Yandex.Disk revision at the time of last modification

  • origin_path – str, original path

  • deleted – datetime.datetime, date of deletion

  • sizes – dict[str, str], mapping of all preview sizes, where keys are names and values are download links

exists(relative_path: str | None = None, /, **kwargs) → bool[source]

Check whether the trash resource exists.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

get_meta(relative_path: str | None = None, /, **kwargs) → SyncTrashResourceObject[source]

Get meta information about a trash resource.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_crop – bool, cut the preview to the size specified in the preview_size

  • sort – str, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

SyncTrashResourceObject

get_type(relative_path: str | None = None, /, **kwargs) → str[source]

Get trash resource type.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

“file” or “dir”

is_dir(relative_path: str | None = None, /, **kwargs) → bool[source]

Check whether resource is a trash directory.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

is_file(relative_path: str | None = None, /, **kwargs) → bool[source]

Check whether resource is a trash file.

Parameters:
  • relative_path – str or None, relative path to the trash resource

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a file, False otherwise (even if it doesn’t exist)

listdir(relative_path: str | None = None, /, **kwargs) → Generator[SyncTrashResourceObject, None, None][source]

Get contents of a trash resource.

Parameters:
  • relative_path – str or None, relative path to the directory in the trash bin

  • max_items – int or None, maximum number of returned items (None means unlimited)

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_crop – bool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

generator of SyncTrashResourceObject

remove(relative_path: str | None = None, /, **kwargs) → SyncOperationLinkObject | None[source]

Remove a trash resource.

Parameters:
  • relative_path – str or None, relative path to the trash resource to be deleted

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • wait – bool, if True, the method will wait until the asynchronous operation is completed

  • poll_interval – float, interval in seconds between subsequent operation status queries

  • poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

SyncOperationLinkObject if the operation is performed asynchronously, None otherwise

restore(dst_path: str, /, **kwargs) → SyncResourceLinkObject | 'SyncOperationLinkObject'[source]
restore(relative_path: str | None, dst_path: str, /, **kwargs) → SyncResourceLinkObject | 'SyncOperationLinkObject'

Restore a trash resource. Returns a link to the newly created resource or a link to the asynchronous operation.

This method takes 1 or 2 positional arguments:

  1. restore(dst_path, /, **kwargs)

  2. restore(relative_path=None, dst_path, /, **kwargs)

Parameters:
  • relative_path – str or None, relative path to the trash resource to be restored

  • dst_path – destination path

  • overwrite – bool, determines whether the destination can be overwritten

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • wait – bool, if True, the method will wait until the asynchronous operation is completed

  • poll_interval – float, interval in seconds between subsequent operation status queries

  • poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeout – float or tuple, request timeout

  • headers – dict or None, additional request headers

  • n_retries – int, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_on – tuple, additional exception classes to retry on

  • requests_args – dict, additional parameters for RequestsSession

  • httpx_args – dict, additional parameters for HTTPXSession

  • curl_options – dict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

SyncResourceLinkObject or SyncOperationLinkObject

class yadisk.objects.SystemFoldersObject(system_folders: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Object, containing paths to system folders.

Parameters:
  • system_folders – dict or None

  • yadisk – YaDisk or None, YaDisk object

Variables:
  • odnoklassniki – str, path to the Odnoklassniki folder

  • google – str, path to the Google+ folder

  • instagram – str, path to the Instagram folder

  • vkontakte – str, path to the VKontakte folder

  • attach – str, path to the mail attachments folder

  • mailru – str, path to the My World folder

  • downloads – str, path to the Downloads folder

  • applications – str path to the Applications folder

  • facebook – str, path to the Facebook folder

  • social – str, path to the social networks folder

  • messenger – str, path to the Messenger Files folder

  • calendar – str, path to the Meeting Materials folder

  • photostream – str, path to the camera folder

  • screenshots – str, path to the screenshot folder

  • scans – str, path to the Scans folder

class yadisk.objects.TokenObject(token: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Token object.

Parameters:
  • token – dict or None

  • yadisk – YaDisk or None, YaDisk object

Variables:
  • access_token – str, token string

  • refresh_token – str, the refresh-token

  • token_type – str, type of the token

  • expires_in – int, amount of time before the token expires

  • scope – str, list of rights requested by the application, returned only if the token has a smaller set of rights than requested

class yadisk.objects.TokenRevokeStatusObject(token_revoke_status: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

Result of token revocation request.

Parameters:
  • token_revoke_status – dict or None

  • yadisk – YaDisk or None, YaDisk object

Variables:

status – str, status of the operation

class yadisk.objects.TrashResourceListObject(trash_resource_list: dict | None = None, yadisk: Any | None = None)[source]

Bases: ResourceListObject

List of trash resources.

Parameters:
  • trash_resource_list – dict or None

  • yadisk – Client/AsyncClient or None, YaDisk object

Variables:
  • sort – str, sort type

  • items – list, list of resources (TrashResourceObject)

  • limit – int, maximum number of elements in the list

  • offset – int, offset from the beginning of the list

  • path – str, path to the directory that contains the elements of the list

  • total – int, number of elements in the list

class yadisk.objects.TrashResourceObject(trash_resource: dict | None = None, yadisk: Any | None = None)[source]

Bases: ResourceObject

Trash resource object.

Parameters:
  • trash_resource – dict or None

  • yadisk – Client/AsyncClient or None, YaDisk object

Variables:
  • antivirus_status – str, antivirus check status

  • file – str, download URL

  • size – int, file size

  • public_key – str, public resource key

  • sha256 – str, SHA256 hash

  • md5 – str, MD5 hash

  • embedded – TrashResourceListObject, list of nested resources

  • name – str, filename

  • exif – EXIFObject, EXIF metadata

  • resource_id – str, resource ID

  • custom_properties – dict, custom resource properties

  • public_url – str, public URL

  • share – ShareInfoObject, shared folder information

  • modified – datetime.datetime, date of last modification

  • created – datetime.datetime, date of creation

  • photoslice_time – datetime.datetime, photo/video creation date

  • mime_type – str, MIME type

  • path – str, path to the resource

  • preview – str, file preview URL

  • comment_ids – CommentIDsObject, comment IDs

  • type – str, type (“file” or “dir”)

  • media_type – str, file type as determined by Yandex.Disk

  • revision – int, Yandex.Disk revision at the time of last modification

  • origin_path – str, original path

  • deleted – datetime.datetime, date of deletion

  • sizes – dict[str, str], mapping of all preview sizes, where keys are names and values are download links

class yadisk.objects.UserObject(user: dict | None = None, yadisk: Any | None = None)[source]

Bases: YaDiskObject

User object.

Parameters:
  • user – dict or None

  • yadisk – YaDisk or None, YaDisk object

Variables:
  • reg_time – datetime.datetime, Disk registration date

  • display_name – str, user’s display name

  • uid – str, user’s UID

  • country – str, user’s country

  • is_child – bool, tells whether it’s a child account

  • login – str, user’s login

class yadisk.objects.UserPublicInfoObject(public_user_info: dict | None = None, yadisk: Any | None = None)[source]

Bases: UserObject

Public user information object. Inherits from UserObject for compatibility.

Parameters:
  • public_user_info – dict or None

  • yadisk – YaDisk or None, YaDisk object

Variables:
  • login – str, user’s login

  • display_name – str, user’s display name

  • uid – str, user’s UID

class yadisk.objects.YaDiskObject(field_types: dict | None = None, yadisk: Any | None = None)[source]

Bases: object

Base class for all objects mirroring the ones returned by Yandex.Disk REST API. It must have a fixed number of fields, each field must have a type. It also supports subscripting and access of fields through the . operator.

Parameters:
  • field_types – dict or None

  • yadisk – YaDisk or None, YaDisk object

__matmul__(name: str) → Any[source]

The @ operator. Same as YaDiskObject.field(). Can be used like this:

# if embedded or embedded.total turn out to be None, we'll get a ValueError
file_count = client.get_meta("/some_folder") @ "embedded" @ "total"
print(f"/some_folder contains {file_count} files")
Parameters:

name – str, name of the field

Raises:

ValueError – value of the given field is None

Returns:

field’s value

field(name: str) → Any[source]

Get value of field name, guarantee it’s not None or raise a ValueError.

Parameters:

name – str, name of the field

Raises:

ValueError – value of the given field is None

Returns:

field’s value

import_fields(source_dict: dict | None) → None[source]

Set all the fields of the object to the values in source_dict. All the other fields are ignored

Parameters:

source_dict – dict or None (nothing will be done in that case)

remove_alias(alias: str) → None[source]

Remove an alias.

Parameters:

alias – str

remove_field(field: str) → None[source]

Remove field.

Parameters:

field – str

set_alias(alias: str, name: str) → None[source]

Set an alias.

Parameters:
  • alias – str, alias to add

  • name – str, field name

set_field_type(field: str, type: Callable) → None[source]

Set field type.

Parameters:
  • field – str

  • type – type or factory

set_field_types(field_types: dict) → None[source]

Set the field types of the object

Parameters:

field_types – dict, where keys are the field names and values are types (or factories)