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.

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

href

URL. It may be a URL template. See the templated key.

method

The HTTP method for requesting the URL from the href key.

templated

Indicates a URL template according to RFC 6570. Possible values:

  • "true" — URL template. To send a request to this address, replace the placeholder values in the curly brackets with the parameter values.
  • "false" — The URL can be requested without changes.

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

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.

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

sort

The field by which the list is sorted.

public_key

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.

items

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.

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.

path

The path to the folder whose contents are described in the ResourceList object.

For a public folder, the attribute value is always "/".

total

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

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.

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

items

Array of recently uploaded files (Resource).

limit

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

PublicResourcesList

List of files published on Yandex Disk.

{
  "items": [ /* array of Resource objects */ ],
  "type": "dir",
  "limit": 20,
  "offset": 0
}

Element

Description

items

Array of recently uploaded files (Resource).

limit

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

type

Resource type:

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

offset

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

trash_size

Space used by files in Trash (bytes).

total_space

Space available to the user on Yandex Disk (bytes).

used_space

Space used by files on Yandex Disk (bytes).

system_folders

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:

  • Applications — Folder for app files.
  • Downloads — Folder for files downloaded from the internet (not from the user's device).

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

status

Operation status. Possible values:

  • success — Operation successfully completed.
  • failed — Operation failed. Try repeating the original copy, move, or delete request.
  • in-progress — Operation has started but not finished yet.

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

description

Detailed error description to assist developers.

error

Error ID for automatic processing.