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 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.

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.

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

items

Array of recently uploaded files (Resource).

limit

The maximum number of items in the items array set in the request.

offset

The offset from the first resource in the folder to the top of the list.

Element

Description

public_key

Key of a published resource.

It's included in the response only if the specified file or folder is published.

public_url

Link to a published resource.

It's included in the response only if the specified file or folder is published.

_embedded

The resources in the folder (contains the ResourceList object).

It's included in the response only when the folder meta information is requested.

preview

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.

name

Resource name.

custom_properties

The object contains all attributes specified by the Adding resource meta information request. Contains only keys of the name:value type (can't contain objects or arrays).

created

The date and time when the resource was created, in ISO 8601 format.

modified

The date and time when the resource was modified, in ISO 8601 format.

path

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, trash:/foo_1408546879). This ID differentiates it from other deleted resources with the same name.

origin_path

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

MD5 hash of the file.

type

Resource type:

  • "dir" — folder.
  • "file" — file.

mime_type

The MIME type of the file.

size

File size.