API

File

Upload

URL: http(s)://alfafile.net/api/v1/file/upload
Description: Checks if instant upload is possible and return upload session object with file info or upload URL
Method: (GET|POST)
Required params:
  • token - Access Token to authenticate the user's current session
  • name - The file name
  • hash - MD5 hash of the file
  • size - The file size
Optional params:
  • folder_id - The key that identifies the destination folder. If the folder_id is not passed, will be used the root folder
  • mode - File mode
Possible values of the Mode property:
  • 1 - Public
  • 2 - Private
  • 3 - Hot
Possible values of the State property:
  • 0 - Uploading
  • 1 - Processing
  • 2 - Done
  • 3 - Fail
Upload steps:
  • 1. Do upload API request (see request example and response example 1) If upload state not equal 0 no need other steps
  • 2. Upload file to upload url (see upload form example and response example 2)
  • 3. Do upload_info API request
Request example: http://alfafile.net/api/v1/file/upload?folder_id=E&name=test_2.zip&hash=aed49fdd25ae495e44375f6636aed59c&size=310452&token=arsd4h37ecfkdqd16uolf5nai1
Success response example 1:
        
{
    "response":{
        "upload":{
            "upload_id":"RF",
            "url":"http:\/\/a2.alfafile.net\/ul\/RF",
            "file":[

            ],
            "state":0,
            "state_label":"Uploading"
        }
    },
    "status":200,
    "details":null
}
        
    
Upload form example:
        
<form method="post" action="http://a2.alfafile.net/ul/RF" enctype="multipart/form-data">
    <input type="file" name="file"/>
</form>
        
    
Success response example 2:
        
{
    "response":{
        "upload":{
            "upload_id":"RF",
            "url":"http:\/\/a2.alfafile.net\/ul\/RF",
            "file":{
                "file_id":"GH",
                "mode":2,
                "mode_label":"Private",
                "folder_id":"E",
                "name":"test_2.zip",
                "hash":"aed49fdd25ae495e44375f6636aed59c",
                "size":310452,
                "url":"http:\/\/alfafile.net\/file\/GH",
                "created":1426776799
            },
            "state":2,
            "state_label":"Done"
        }
    },
    "status":200,
    "details":null
}
        
    

Upload info

URL: http(s)://alfafile.net/api/v1/file/upload_info
Description: Checks upload session state.
Method: (GET|POST)
Required params:
  • token - Access Token to authenticate the user's current session
  • upload_id - The upload session id
Optional params:
Possible values of the State property:
  • 0 - Uploading
  • 1 - Processing
  • 2 - Done
  • 3 - Fail
Request example: http://alfafile.net/api/v1/file/upload_info?upload_id=RF&token=arsd4h37ecfkdqd16uolf5nai1
Success response example:
        
{
    "response":{
        "upload":{
            "upload_id":"RF",
            "url":"http:\/\/a2.alfafile.net\/ul\/RF",
            "file":[

            ],
            "state":1,
            "state_label":"Processing"
        }
    },
    "status":200,
    "details":null
}
        
    
Success response example:
        
{
    "response":{
        "upload":{
            "upload_id":"RF",
            "url":"http:\/\/a2.alfafile.net\/ul\/RF",
            "file":{
                "file_id":"GH",
                "mode":2,
                "mode_label":"Private",
                "folder_id":"E",
                "name":"test_2.zip",
                "hash":"aed49fdd25ae495e44375f6636aed59c",
                "size":310452,
                "url":"http:\/\/alfafile.net\/file\/GH",
                "created":1426776799
            },
            "state":2,
            "state_label":"Done"
        }
    },
    "status":200,
    "details":null
}
        
    

Download

URL: http(s)://alfafile.net/api/v1/file/download
Description: Download a file.
Method: (GET|POST)
Required params:
  • token - Access Token to authenticate the user's current session
  • file_id - The key that identifies the file
Optional params:
Request example: /api/v1/file/download?file_id=Gc&token=arsd4h37ecfkdqd16uolf5nai1
Success response example:
        
{
    "response":{
        "download_url":"http://a1.alfafile.net/dl/8j/file_1.zip"
    },
    "status":200,
    "details":null
}
        
    

Info

URL: http(s)://alfafile.net/api/v1/file/info
Description: Returns a file's details
Method: (GET|POST)
Required params:
  • token - Access Token to authenticate the user's current session
  • file_id - The key that identifies the file.
Optional params:
Request example: api/v1/file/info?file_id=GH&token=arsd4h37ecfkdqd16uolf5nai1
Success response example:
        
{
    "response":{
        "file":{
            "file_id":"GH",
            "mode":2,
            "mode_label":"Private",
            "folder_id":"E",
            "name":"test_2.zip",
            "hash":"aed49fdd25ae495e44375f6636aed59c",
            "size":310452,
            "url":"http://alfafile.net/file/GH",
            "created":1426776799
        }
    },
    "status":200,
    "details":null
}
        
    
Error response example:
        
{
    "response":null,
    "status":404,
    "details":"File with file_id: 'Gh' doesn't exist"
}
        
    

Rename

URL: http(s)://alfafile.net/api/v1/file/rename
Description: Rename a file.
Method: (GET|POST)
Required params:
  • token - Access Token to authenticate the user's current session
  • name - The new name of the file
  • file_id - The key that identifies the file to be renamed
Optional params:
Request example: /api/v1/file/rename?name=file_1.zip&file_id=Gu&token=arsd4h37ecfkdqd16uolf5nai1
Success response example:
        
{
    "response":{
        "file":{
            "file_id":"Gu",
            "mode":1,
            "mode_label":"Public",
            "folder_id":"7",
            "name":"file_1.zip",
            "hash":"03a8b5ceb55d9be5ec57aea62d6628d6",
            "size":2010338,
            "url":"http:\/\/alfafile.net\/file\/Gu",
            "created":1426764700
        }
    },
    "status":200,
    "details":null
}
        
    

Copy

URL: http(s)://alfafile.net/api/v1/file/copy
Description: Copy a file to another folder.
Method: (GET|POST)
Required params:
  • token - Access Token to authenticate the user's current session
  • folder_id_dest - The key that identifies the destination folder
  • file_id - The key that identifies the file. You can also specify multiple file keys separated by comma
Optional params:
Request example: /api/v1/file/copy?file_id=Gu&folder_id_dest=E&token=&&token=arsd4h37ecfkdqd16uolf5nai1
Success response example:
        
{
    "response":{
        "result":{
            "success":1,
            "success_ids":[
                "Gu"
            ],
            "fail":0,
            "fail_ids":[

            ],
            "errors":[

            ]
        }
    },
    "status":200,
    "details":null
}
        
    
Error response example:
        
{
    "response":{
        "result":{
            "success":0,
            "success_ids":[

            ],
            "fail":1,
            "fail_ids":[
                "Gu"
            ],
            "errors":[
                "Conflict. File with the same name already exists in destination folder"
            ]
        }
    },
    "status":200,
    "details":null
}
        
    

Move

URL: http(s)://alfafile.net/api/v1/file/move
Description: Move a file to another folder.
Method: (GET|POST)
Required params:
  • token - Access Token to authenticate the user's current session
  • folder_id_dest - The key that identifies the destination folder
  • file_id - The key that identifies the file. You can also specify multiple file keys separated by comma
Optional params:
Request example: /api/v1/file/move?file_id=Gu&folder_id_dest=E&token=&&token=arsd4h37ecfkdqd16uolf5nai1
Success response example:
        
{
    "response":{
        "result":{
            "success":1,
            "success_ids":[
                "Gu"
            ],
            "fail":0,
            "fail_ids":[

            ],
            "errors":[

            ]
        }
    },
    "status":200,
    "details":null
}
        
    
Error response example:
        
{
    "response":{
        "result":{
            "success":0,
            "success_ids":[

            ],
            "fail":1,
            "fail_ids":[
                "Gu"
            ],
            "errors":[
                "Conflict. File with the same name already exists in destination folder"
            ]
        }
    },
    "status":200,
    "details":null
}
        
    

Delete

URL: http(s)://alfafile.net/api/v1/file/delete
Description: Delete a file. The file is basically moved to the Trash Bin.
Method: (GET|POST)
Required params:
  • token - Access Token to authenticate the user's current session
  • file_id - The key that identifies the file. You can also specify multiple file keys separated by comma
Optional params:
Request example: /api/v1/file/delete?file_id=Gu&token=arsd4h37ecfkdqd16uolf5nai1
Success response example:
        
{
    "response":{
        "result":{
            "success":1,
            "success_ids":[
                "Gu"
            ],
            "fail":0,
            "fail_ids":[

            ],
            "errors":[

            ]
        }
    },
    "status":200,
    "details":null
}
        
    

Change mode

URL: http(s)://alfafile.net/api/v1/file/change_mode
Description: Change a file mode.
Method: (GET|POST)
Required params:
  • token - Access Token to authenticate the user's current session
  • file_id - The key that identifies the file
  • mode - New file mode
Optional params:
Possible values of the Mode property:
  • 1 - Public
  • 2 - Private
  • 3 - Hot
Request example: /api/v1/file/change_mode?file_id=GH&mode=1&token=arsd4h37ecfkdqd16uolf5nai1
Success response example:
        
{
    "response":{
        "file":{
            "file_id":"GH",
            "mode":"1",
            "mode_label":"Public",
            "folder_id":"E",
            "name":"test_2.zip",
            "hash":"aed49fdd25ae495e44375f6636aed59c",
            "size":310452,
            "url":"http://alfafile.net/file/GH",
            "created":1426776799
        }
    },
    "status":200,
    "details":null
}