Flat list of all files
The API returns a flat list of all files on Yandex Disk in alphabetical order. The flat list doesn't reflect the folder structure and can be used for searching for files of a specific type in different folders.
Request format
Use the GET method to send a request for a list of all files.
https://cloud-api.yandex.net/v1/disk/resources/files
? [limit=<number of files in the list>]
& [media_type=<type of requested files>]
& [offset=<offset from the top of the list>]
& [fields=<properties to include in the response>]
& [preview_size=<preview size>]
& [preview_crop=<preview crop flag>]
- limit
-
The number of files that should be described in the response (for example, for paginated output).
The default value is 20.
- media_type
-
File types to include in the list. Yandex Disk identifies the type of each uploaded file.
To request multiple file types, list them in the parameter value separated by commas. For example,media_type="audio,video"
.
Supported file types:
audio
: audio files.backup
: backup and temporary files.book
: e-books.compressed
: compressed and archived files.data
: database files.development
: code files (C++, Java, XML, and others) and IDE system files.diskimage
: images of media devices and associated files, such as ISO and CUE.document
: office documents (Word, OpenOffice, and others).encoded
: encoded files.executable
: executable files.flash
: flash video or animation files.font
: font files.image
: Images.settings
: settings files for various programs.spreadsheet
: spreadsheet files (Excel, Numbers, Lotus).text
: text files.unknown
: unknown file type.video
: video files.web
: various files used by sites and browsers (CSS, certificates, bookmark files).
- offset
-
The number of resources starting from the top of the list that should be skipped in the response (for example, for paginated output).
Let's say the
/foo
folder contains three files. If you request the folder meta information with the offset parameter set to 1 (offset=1
), the Yandex Disk API returns only the second and third file information. - fields
-
List of JSON properties to include in the response. Keys not specified in this list are omitted when generating a response. If the parameter isn't specified, the response is returned in full without omitting anything.
Key names should be separated by commas, and embedded keys should be separated by dots. For example:name,_embedded.items.path
. - preview_size
-
The required size of the reduced image (file preview). Its link should be returned in the
preview
key.
You can specify the exact preview dimensions or the length of one side. The resulting image can be cropped to a square using thepreview_crop
parameter.Possible values
-
Predefined length of the longest side.
The image is reduced to the specified size along its larger dimension while preserving the aspect ratio of the original image. For example, for the "S" size and a 120×200 image, a 90×150 preview is generated. For a 300×100 image, the preview is 150×50.
Supported values:
-
"S"
: 150 pixels.
-"M"
: 300 pixels.
-"L"
: 500 pixels.
-"XL"
: 800 pixels.
-"XXL"
: 1024 pixels.
-"XXXL"
: 1280 pixels. -
Exact width (for example,
"120"
or"120x"
) or exact height (for example,"x145"
).The image is reduced to the specified width or height while preserving the aspect ratio of the original image.
If the
preview_crop
parameter is passed, a square with the specified side length is cropped out of the center of the reduced image. -
Exact size (in the
<width>x<height>
format, for example,"120x240"
).The image is reduced to the smallest of the specified dimensions while preserving the aspect ratio of the original image.
If the
preview_crop
is passed, a section of maximum size with the specified aspect ratio (in the example: 1 to 2) is cropped out of the center of the original image. Then the cropped section is scaled to the specified dimensions.
-
- preview_crop
-
This parameter crops the preview to the size specified in the
preview_size
parameter.
Supported values:
false
: the parameter is ignored (default value).true
: the preview is cropped as follows:
- If only the width or height is passed, the image is reduced to this size with the same aspect ratio. Then a square with the specified side length is cropped out of the center of the reduced image.
- If the exact size is passed (for example, "120x240"), a section of maximum size with the specified aspect ratio is cropped out of the center of the source image. Then the cropped section is scaled to the specified dimensions.
- If only the width or height is passed, the image is reduced to this size with the same aspect ratio. Then a square with the specified side length is cropped out of the center of the reduced image.
Response format
If the request is processed without errors, the API returns the 200 OK
code. The FilesResourceList object in the response body contains meta information about the number of requested files.
If the request caused an error, the relevant response code is returned, and the response body contains an error description.
Sample response:
{
"items": [
{
"name": "photo2.png",
"preview": "https://downloader.disk.yandex.ru/preview/...",
"created": "2014-04-22T14:57:13+04:00",
"modified": "2014-04-22T14:57:14+04:00",
"path": "disk:/foo/photo2.png",
"md5": "53f4dc6379c8f95ddf11b9508cfea271",
"type": "file",
"mime_type": "image/png",
"size": 54321
},
{
"name": "photo1.png",
"preview": "https://downloader.disk.yandex.ru/preview/...",
"created": "2014-04-21T14:57:13+04:00",
"modified": "2014-04-21T14:57:14+04:00",
"path": "disk:/foo/photo1.png",
"md5": "4334dc6379c8f95ddf11b9508cfea271",
"type": "file",
"mime_type": "image/png",
"size": 34567
}
],
"limit": 20,
"offset": 0
}
Response elements
Element |
Description |
|
Array of recently uploaded files (Resource). |
|
The maximum number of items in the |
|
The offset from the first resource in the folder to the top of the list. |
Element |
Description |
|
Key of a published resource. It's included in the response only if the specified file or folder is published. |
|
Link to a published resource. It's included in the response only if the specified file or folder is published. |
|
The resources in the folder (contains the ResourceList object). It's included in the response only when the folder meta information is requested. |
|
Link to a preview image of the file. It's included in the response only for supported image formats. The preview can only be requested with the OAuth token of a user who has access to the file. |
|
Resource name. |
|
The object contains all attributes specified by the Adding resource meta information request. Contains only keys of the |
|
The date and time when the resource was created, in ISO 8601 format. |
|
The date and time when the resource was modified, in ISO 8601 format. |
|
Full path to the resource on Yandex Disk. The meta information of the published folder indicates paths relative to the folder. For published files, the key value is always "/". For a resource in Trash, this attribute may have a unique ID added to it (for example, |
|
Path to the resource before it was moved to Trash. Only included in the response to a meta information request related to a resource in Trash. |
|
MD5 hash of the file. |
|
Resource type:
|
|
The MIME type of the file. |
|
File size. |
The number of files that should be described in the response (for example, for paginated output).
The default value is 20.
File types to include in the list. Yandex Disk identifies the type of each uploaded file.
To request multiple file types, list them in the parameter value separated by commas. For example, media_type="audio,video"
.
Supported file types:
audio
: audio files.backup
: backup and temporary files.book
: e-books.compressed
: compressed and archived files.data
: database files.development
: code files (C++, Java, XML, and others) and IDE system files.diskimage
: images of media devices and associated files, such as ISO and CUE.document
: office documents (Word, OpenOffice, and others).encoded
: encoded files.executable
: executable files.flash
: flash video or animation files.font
: font files.image
: Images.settings
: settings files for various programs.spreadsheet
: spreadsheet files (Excel, Numbers, Lotus).text
: text files.unknown
: unknown file type.video
: video files.web
: various files used by sites and browsers (CSS, certificates, bookmark files).
The number of resources starting from the top of the list that should be skipped in the response (for example, for paginated output).
Let's say the /foo
folder contains three files. If you request the folder meta information with the offset parameter set to 1 (offset=1
), the Yandex Disk API returns only the second and third file information.
List of JSON properties to include in the response. Keys not specified in this list are omitted when generating a response. If the parameter isn't specified, the response is returned in full without omitting anything.
Key names should be separated by commas, and embedded keys should be separated by dots. For example: name,_embedded.items.path
.
The required size of the reduced image (file preview). Its link should be returned in the preview
key.
You can specify the exact preview dimensions or the length of one side. The resulting image can be cropped to a square using the preview_crop
parameter.
Possible values
-
Predefined length of the longest side.
The image is reduced to the specified size along its larger dimension while preserving the aspect ratio of the original image. For example, for the "S" size and a 120×200 image, a 90×150 preview is generated. For a 300×100 image, the preview is 150×50.
Supported values:
-
"S"
: 150 pixels.
-"M"
: 300 pixels.
-"L"
: 500 pixels.
-"XL"
: 800 pixels.
-"XXL"
: 1024 pixels.
-"XXXL"
: 1280 pixels. -
Exact width (for example,
"120"
or"120x"
) or exact height (for example,"x145"
).The image is reduced to the specified width or height while preserving the aspect ratio of the original image.
If the
preview_crop
parameter is passed, a square with the specified side length is cropped out of the center of the reduced image. -
Exact size (in the
<width>x<height>
format, for example,"120x240"
).The image is reduced to the smallest of the specified dimensions while preserving the aspect ratio of the original image.
If the
preview_crop
is passed, a section of maximum size with the specified aspect ratio (in the example: 1 to 2) is cropped out of the center of the original image. Then the cropped section is scaled to the specified dimensions.
This parameter crops the preview to the size specified in the preview_size
parameter.
Supported values:
false
: the parameter is ignored (default value).true
: the preview is cropped as follows:
- If only the width or height is passed, the image is reduced to this size with the same aspect ratio. Then a square with the specified side length is cropped out of the center of the reduced image.
- If the exact size is passed (for example, "120x240"), a section of maximum size with the specified aspect ratio is cropped out of the center of the source image. Then the cropped section is scaled to the specified dimensions.
- If only the width or height is passed, the image is reduced to this size with the same aspect ratio. Then a square with the specified side length is cropped out of the center of the reduced image.