Downloading a file from Yandex.Disk

To download a file from Yandex.Disk:

  1. Download the file from the address you were given, indicating the same OAuth token as in the original request.

Request for a download URL

To get a URL for directly downloading a file, send the API the path on Yandex.Disk where the file to download should be accessible.

Request format

Use the GET method to send the request for a download URL.

https://cloud-api.yandex.net/v1/disk/resources/download
 ? path=<path to the file to download>
 & [fields=<properties to include in the response>]
path *

The path to the file to download. For example, %2Fbar%2Fphoto.png

The path in the parameter value should be URL-encoded.

fields

List of JSON keys to include in the response. Keys that are not included in this list will be discarded when forming the response. If the parameter is omitted, the response is returned in full, without discarding anything.

Key names should be comma-separated, and embedded keys should be separated by dots. For example: name, _embedded. items. path.

path *

The path to the file to download. For example, %2Fbar%2Fphoto.png

The path in the parameter value should be URL-encoded.

fields

List of JSON keys to include in the response. Keys that are not included in this list will be discarded when forming the response. If the parameter is omitted, the response is returned in full, without discarding anything.

Key names should be comma-separated, and embedded keys should be separated by dots. For example: name, _embedded. items. path.

* Required

Response format

If the request was processed without errors, the API responds with the code 200 OK. The Link object in the response body returns the generated URL for downloading the file.

If the request caused an error, the relevant response code is returned, and the response body contains the error description.

Sample response:

{  "href": "https://downloader.dst.yandex.ru/disk/...",  "method": "GET",  "templated": false}
Response elements
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. Before sending a request to this address, put the desired parameter values in place of the values in curly brackets.
  • “false” — The URL can be requested without changes.
Response elements
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. Before sending a request to this address, put the desired parameter values in place of the values in curly brackets.
  • “false” — The URL can be requested without changes.

Downloading a file from the given URL

Use the GET method to download a file:

https://downloader.dst.yandex.ru/disk/53139aa0et584d3bac7eeab405d3574b/535320b4/YyjTJtEHob8R5WbpojJbiiUuU2HC_2JSTU0gW9qE0NHGW2uncmBjM_-IXun3Msyij96FTHQGSX-fDL-XwokDvA%3D%3D?uid=202727674&filename=photo.png&disposition=attachment&hash=&limit=0&content_type=application%2Fx-www-form-urlencoded&fsize=34524&hid=93528043563b8r55723a253f4730290a&media_type=document

If the request was processed without errors, the API responds with a file with the code 200 OK.