REST API

General information

Address: http://mng.zerocdn.com/api/v2/users/

ZeroCDN implements API access as REST resources. The following resources are currently available:

Attention! By default, the user cannot upload more than 5 files per minute. To remove this restriction, you must contact the administration.

Working with zones

By default, when uploading through the api at the URL mng.zerocdn.com , the file will be automatically uploaded to the zone closest to you.

To control this behavior, you need to use the zone-specific URL.

The following zones are currently available:

ZoneURL
Russia Moscowhttp://msk.ru.mng.zerocdn.com/api/v2/users/
Belarus Minskhttp://minsk.by.mng.zerocdn.com/api/v2/users/
Russia Krasnoyarskhttp://kry.ru.mng.zerocdn.com/api/v2/users/
Belarus Minsk2http://minsk2.by.mng.zerocdn.com/api/v2/users/
USA Restonhttp://rst.us.mng.zerocdn.com/api/v2/users/
Belarus Minsk3http://minsk3.by.mng.zerocdn.com/api/v2/users/
Russia Moscow2http://msk2.ru.mng.zerocdn.com/api/v2/users/
Russia Ryazanhttp://rzn.ru.mng.zerocdn.com/api/v2/users/
Russia Rostov-na-Donuhttp://rnd.ru.mng.zerocdn.com/api/v2/users/
Russia Tverhttp://tvr.ru.mng.zerocdn.com/api/v2/users/
Russia Krasnodarhttp://krd.ru.mng.zerocdn.com/api/v2/users/

Authorization methods

Login/Password:

curl --user USERNAME:PASSWORD "http://mng.zerocdn.com/api/v2/users/files.json"
    

Login/Key:

curl "http://mng.zerocdn.com/api/v2/users/files.json?username=USERNAME&api_key=KEY"

Working with files

Adding a file::

curl -v -H "Content-Type: multipart/form-data" -F file=@/path/to/file -F folder="FOLDER_ID" -X POST http://mng.zerocdn.com/api/v2/users/files.json
    

Adding by link:

curl -v -H "Content-Type: application/json" -X POST --data '{"url" : "URL://TO/FILE", "name": "file.name", "fail_url": "URL://IF/FAILED", "success_url": "URL://IF/SUCCESS", "is_hidden": true, "is_viewable": true, "autodownload": false}' "http://mng.zerocdn.com/api/v2/users/files.json"
    

Attention! Profiles are not applied to the file loaded by the API, all necessary parameters must be explicitly set.

FieldFunction
folder ID of the folder where the file will be loaded (example: 999)
success_url url will be called in case of successful file upload
fail_url url will be called in case of problems with loading
fail_email Email for notification in case of problems with download
autodownload Skip intermediate page before downloading
is_viewable Don't send Content-Disposition: attachment header
is_hidden The file can only be accessed by a signed link. For authorized users who own the file, this restriction does not apply.
public_urlPublic link
direct_urlDirect link
max_speed Speed limit for one connection
max_speed_after Enabling speed limit for one connection after sending the specified amount of traffic in bytes
content_type«Content-type» passed to the client when downloading
force Delete old file in case of name conflict instead of renaming the new one
areas List of names of zones in which to place the file (example: ['msk.ru'] or ['msk.ru', 'minsk.by'])

Getting file data:

curl -v "http://mng.zerocdn.com/api/v1/users/files/FILE_ID.json"

Changing file parameters:

curl -v -H "Content-Type: application/json" -X PATCH --data '{"name": "NEW_NAME"}' "http://zerocdn.com/api/v2/users/files/FILE_ID.json"

Deleting a file:

curl -v -X DELETE "http://mng.zerocdn.com/api/v2/users/files/FILE_ID.json"

List of files:

curl -v "http://mng.zerocdn.com/api/v2/users/files.json"

Filter by nameФильтр по имени:

curl -v "http://mng.zerocdn.com/api/v2/users/files.json?name__endswith=.mp4"

A selection of files larger than 10 bytes:

curl -v "http://mng.zerocdn.com/api/v2/users/files.json?size__gt=10"

Sort by size in reverse order:

curl -v "http://mng.zerocdn.com/api/v2/users/files.json?order_by=-size"

Working with folders

Create a folder:

curl -v -H "Content-Type: application/json" -X POST --data '{"name": "folder-name"}' "http://mng.zerocdn.com/api/v2/users/folders.json"

Create subfolder:

curl -v -H "Content-Type: application/json" -X POST --data '{"name": "sub-folder-name", "folder": "PARENT_FOLDER_ID"}' "http://mng.zerocdn.com/api/v2/users/folders.json"

Folder list:

curl -v "http://mng.zerocdn.com/api/v2/users/folders.json"

Getting a folder by ID:

curl -v "http://mng.zerocdn.com/api/v2/users/folders/FOLDER_ID.json"

Rename folder:

curl -v -H "Content-Type: application/json" -X PATCH --data '{"name": "new-folder-name"}' "http://mng.zerocdn.com/api/v2/users/folders/FOLDER_ID.json"

Delete folder:

curl -v -X DELETE "http://mng.zerocdn.com/api/v2/users/folders/FOLDER_ID.json"

List of subfolders in the folder:

curl -v "http://mng.zerocdn.com/api/v2/users/folders.json?folder=FOLDER_ID"

List of subfolders in the root folder:

curl -v "http://mng.zerocdn.com/api/v2/users/folders.json?folder=null"

Move file to folder:

curl -v -H "Content-Type: application/json" -X PATCH --data '{"folder": "FOLDER_ID"}' "http://mng.zerocdn.com/api/v2/users/files/FILE_ID.json"

Upload file to folder:

curl -v -H "Content-Type: application/json" -X POST --data '{"url" : "URL://TO/FILE", "name": "file.name", "folder": "FOLDER_ID"}' "http://mng.zerocdn.com/api/v2/users/files.json"