List of published resources
The API returns a list of resources published on the user's Yandex Disk. Resources in the list are sorted in order of publishing, from latest to earliest.
The list can be filtered by resource type to get only files or folders.
Request format
Use the GET method to send a request for the list of published resources.
https://cloud-api.yandex.net/v1/disk/resources/public
? [limit=<number of files in the list>]
& [offset=<offset from the top of the list>]
& [type=<type of requested files>]
& [fields=<properties to include in the response>]
& [preview_size=<preview size>]
- limit
-
The number of published files that should be described in the response (for example, for paginated output).
The default value is 20.
- 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 there are three published files on the user's Disk. If you request a list of them with the
offset=1
parameter, the Yandex Disk API returns only the descriptions of the second and third files. - type
-
Resource type. Supported values:
"dir"
: folder."file"
: file.
- 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.
-
Response format
If the request is processed without errors, the API returns the 200 OK
code. The response body contains meta information about the number of requested files within the PublicResourcesList object.
If the request caused an error, the relevant response code is returned, and the response body contains an error description.
Sample response:
{
"items": [
{
"public_key": "HQsmHLoeyBlJf8Eu1jlmzuU+ZaLkjPkgcvmokRUCIo8=",
"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
},
{
"public_key": "kLsmHRoeyBlJf8Eu1jlmzuU+ZaLkjPkgcvmokRUCIo8=",
"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
}
],
"type": "file",
"limit": 20,
"offset": 0
}
Response elements
Element |
Description |
|
Array of recently uploaded files (Resource). |
|
The maximum number of items in the |
|
Resource type:
|
|
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 published files that should be described in the response (for example, for paginated output).
The default value is 20.
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 there are three published files on the user's Disk. If you request a list of them with the offset=1
parameter, the Yandex Disk API returns only the descriptions of the second and third files.
Resource type. Supported values:
"dir"
: folder."file"
: file.
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.
-
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.