JSON objects in responses
Each response from the Yandex Disk API consists of objects with a specific structure. This section describes all objects that can be found in responses.
Link
An object containing the URL for requesting resource metadata.
Sample object:
{
"href": "https://cloud-api.yandex.net/v1/disk/resources?path=disk%3A%2Ffoo%2Fphoto.png",
"method": "GET",
"templated": false
}
Element |
Description |
|
URL. It may be a URL template. See the |
|
The HTTP method for requesting the URL from the |
|
Indicates a URL template according to RFC 6570. Possible values:
|
Resource
Resource description and meta information of files and folders. Included in the response to the meta information request.
{
"public_key": "HQsmHLoeyBlJf8Eu1jlmzuU+ZaLkjPkgcvmoktUCIo8=",
"_embedded": { /* объект ResourceList */ },
"name": "photo.png",
"created": "2014-04-21T14:57:13+04:00",
"custom_properties": {"foo": "1", "bar": "2"},
"public_url": "https://yadi.sk/d/AaaBbb1122Ccc",
"origin_path": "disk:/foo/photo.png",
"modified": "2014-04-21T14:57:14+04:00",
"path": "disk:/foo/photo.png",
"md5": "4334dc6379c8f95ddf11b8508cfea271",
"type": "file",
"mime_type": "application/x-www-form-urlencoded",
"size": 34567
}
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. |
ResourceList
The list of resources in the folder. Contains Resource objects and list properties.
{
"sort": "",
"public_key": "HQsmHLoeyBlJf8Eu1jlmzuU+ZaLkjPkgcvmoktUCIo8=",
"items": [ /* array of Resource objects */ ],
"path": "disk:/foo",
"limit": 20,
"offset": 0,
"total": 3
}
Element |
Description |
|
The field by which the list is sorted. |
|
The key of the published folder that contains resources from this list. It's included in the response only if a public folder's meta information is requested. |
|
Array of resources (Resource) located in the folder. Regardless of the requested sort, resources in the array are ordered by type: nested folders go first, followed by folder files. |
|
The maximum number of items in the |
|
The offset from the first resource in the folder to the top of the list. |
|
The path to the folder whose contents are described in the For a public folder, the attribute value is always "/". |
|
The total number of resources in the folder. |
FilesResourceList
Flat list of all files on Yandex Disk in alphabetical order.
{
"items": [ /* array of Resource objects */ ],
"limit": 20,
"offset": 0
}
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. |
LastUploadedResourceList
A list of files recently added to Yandex Disk, sorted by upload date (from later to earlier).
{
"items": [ /* array of Resource objects */ ],
"limit": 20
}
Element |
Description |
|
Array of recently uploaded files (Resource). |
|
The maximum number of items in the |
PublicResourcesList
List of files published on Yandex Disk.
{
"items": [ /* array of Resource objects */ ],
"type": "dir",
"limit": 20,
"offset": 0
}
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. |
Disk
Data about available and used space on Yandex Disk.
Sample response with this data:
{
"trash_size": 4631577437,
"total_space": 319975063552,
"used_space": 26157681270,
"system_folders":
{
"applications": "disk:/Applications",
"downloads": "disk:/Downloads/"
}
}
Element |
Description |
|
Space used by files in Trash (bytes). |
|
Space available to the user on Yandex Disk (bytes). |
|
Space used by files on Yandex Disk (bytes). |
|
Absolute paths of Yandex Disk system folders. Folder names depend on the interface language used when the user's personal Yandex Disk was created. For example, the Downloads folder is created for an English-speaking user, Загрузки for a Russian-speaking user, and so on. The following folders are currently supported:
|
Operation
Operation status. Operations are launched when you copy, move, or delete non-empty folders. The URL for requesting status is returned in response to these types of requests.
Sample response with an operation status:
{
"status":"success"
}
Element |
Description |
|
Operation status. Possible values:
|
Error processing request
An error can occur if the request was formed incorrectly, the specified resource doesn't exist on the server, the server isn't working, and so on. All errors are returned with HTTP response codes. All the possible response codes and explanations are given in Sandbox in the section Response messages (to see them, expand the desired request).
Errors are additionally described by a JSON object. For example:
{
"description": "resource already exists",
"error": "PlatformResourceAlreadyExists"
}
Element |
Description |
|
Detailed error description to assist developers. |
|
Error ID for automatic processing. |