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:
- Files /api/v2/users/files.json
- Folders /api/v2/users/folders.json
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:
Zone | URL |
---|---|
Russia Moscow | http://msk.ru.mng.zerocdn.com/api/v2/users/ |
Belarus Minsk | http://minsk.by.mng.zerocdn.com/api/v2/users/ |
Russia Krasnoyarsk | http://kry.ru.mng.zerocdn.com/api/v2/users/ |
Belarus Minsk2 | http://minsk2.by.mng.zerocdn.com/api/v2/users/ |
USA Reston | http://rst.us.mng.zerocdn.com/api/v2/users/ |
Belarus Minsk3 | http://minsk3.by.mng.zerocdn.com/api/v2/users/ |
Russia Moscow2 | http://msk2.ru.mng.zerocdn.com/api/v2/users/ |
Russia Ryazan | http://rzn.ru.mng.zerocdn.com/api/v2/users/ |
Russia Rostov-na-Donu | http://rnd.ru.mng.zerocdn.com/api/v2/users/ |
Russia Tver | http://tvr.ru.mng.zerocdn.com/api/v2/users/ |
Russia Krasnodar | http://krd.ru.mng.zerocdn.com/api/v2/users/ |
Ukraine Kiev | http://kiev.ua.mng.zerocdn.com/api/v2/users/ |
USA Miami | http://mia.us.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.
Field | Function |
---|---|
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_url | Public link |
direct_url | Direct 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"