API

API Libraries

Python

Download URL: Python client library
Requirements: Python 3 with requests python package
Usage: Download and extract archive to your application folder or install it into your site-packages folder
Install requests: pip install requests
Usage example:
        
from alfafile import Client

client = Client('your login', 'your password')

user = client.login()
print(user.email)
print(user.traffic.total)
print(user.traffic.left)

folder = client.folder_info()
print(folder.name, folder.url)

file = client.upload_file('~/Uploads/my_file.ext', folder.folder_id)
print(file.name, file.url)
        
    
Or use it as standalone application
        
$ alfafile/client.py --help
usage: client.py [-h] --login LOGIN --password PASSWORD Path

Upload file or folder with all it files and sub folders to alfafile.net

positional arguments:
Path                 path to file or folder

optional arguments:
-h, --help           show this help message and exit
--login LOGIN        user login
--password PASSWORD  user password




$ alfafile/client.py --login MyLogin --password MyPassword ~/folder/to/upload/
http://alfafile.net/folder/szdkaw
http://alfafile.net/file/CDgan/001.png
http://alfafile.net/file/AGHiTy/002.png
http://alfafile.net/file/AHiGp/003.png
        
    

PHP

Download URL: Php client library
Requirements: PHP 5.4+ with CURL extension
Usage: Download and extract archive to your application folder
Usage example:
        
<?php
require_once('AlfaFile/Client.php');

$client = new AlfaFile\Client();
$client->login($login, $password);

$folder = $client->createFolder('My first folder');
$file = $client->uploadFile('/path/to/file', $folder->folder_id);

$download_url = $client->downloadFile($file->file_id);
        
    

JavaScript

Download URL: JS client library
Requirements: ES5-compatible browser (Optional ES6 promises for the `promised` APIs)
Usage: Download and extract archive to your front-end code folder.
Usage example:
        
// with Promises (note the AFClient.promised)
AFClient.promised.folderContent().then(function(result) {
  var folderId = result.folder_id;
  var folderName = result.name;
  var folderCount = result.nb_folders;
  var fileCount = result.nb_files;
  console.log('ROOT folder ' + folderName + ' contains ' + 
              folderCount + ' folders and ' + fileCount + ' files.')
}).catch(function(err) {
  console.warn('Something went wrong while fetching ROOT folder contents!');
  console.error(err);
});

// node-style callbacks (with ES6 arrow functions and template strings)
AFClient.folderContent((err, result) => {
  if (err) {
    console.warn('Something went wrong while fetching ROOT folder contents!');
    console.error(err);
  } else {
    let folderId = result.folder_id;
    let folderName = result.name;
    let folderCount = result.nb_folders;
    let fileCount = result.nb_files;
    console.log(
      `ROOT folder ${folderName} contains ${folderCount} folders and ${fileCount} files.`
    );
  }
});