Skip to main content

Python MediaFire client library

Project description

Python implementation of MediaFire Core API.

This SDK contains three entities: API client, uploader and high-level client.

What should I use?

High-level client is a work in progress, so you may want to stick to MediaFireApi and MediaFireUploader as these are covered by tests.

If you don’t mind having breaking changes introduced here and there as the high-level API is being shaped, then use MediaFireClient.

API Client library

API Client library provides a low-level interface to MediaFire API. It handles requests, signatures and errors. Uses python-requests for streaming uploads and does not require the whole file to be loaded in memory.


from mediafire.api import MediaFireApi

api = MediaFireApi()
session_result = api.user_get_session_token(


response = api.user_get_info()

# Or directly for methods that are not yet wrapped
response = api.request("upload/add_web_upload", {
    "url": "",
    "filename": "mf-logo.png"})

response = api.request("upload/get_web_uploads",
                    {"key": status['upload_key']})

API Client library supports operation w/o session_token. In this case all operations that do require session_token will fail with Access denied error.


MediaFire supports several upload methods and MediaFireUploader exposes a single upload method to make things easier:

from mediafire.api import MediaFireApi
from mediafire.uploader import MediaFireUploader

api = MediaFireApi()
uploader = MediaFireUploader(api)

fd = open('/path/to/file', 'rb')

result = uploader.upload(fd, 'Some filename.txt',


High-level Client Library

High-level client library wraps API calls and presents simplified interface.

Supported operations:

  • File upload

  • File download (direct download link)

  • Listing directories

  • Creating directories

  • Removing files and directories

  • Getting info about files and directories

MediaFire resources can be referenced by path or by quickkey/folderkey.

  • path: mf:/Pictures/Sample.jpg or /Pictures/Sample.jpg

  • folder_key: mf:6302u1a9p0a9x (folder_key is 13 chars long)

  • quick_key: mf:46d3y4p8542kiyp (quick_key is 15 chars long)

from mediafire.client import (MediaFireClient, File, Folder)

client = MediaFireClient()

client.upload_file("flower.jpg", "mf:/Pictures/")

for item in client.get_folder_contents_iter("mf:/Pictures"):
    if type(item) is File:
        print("File: {}".format(item['filename']))
    elif type(item) is Folder:
        print("Folder: {}".format(item['foldername']))

See examples/ for high-level client usage.

Example CLI Interface

Work in progress. Can be used for basic tasks, such as directory listing, uploads, downloads, getting resource information and removing files and folders from the command line.

usage: examples/ [-h] [--debug] [--email EMAIL] [--password PASSWORD]

Command-line interface to MediaFire Simple File Sharing and Storage

optional arguments:
-h, --help            show this help message and exit
--debug               Enable debug output
--email EMAIL
--password PASSWORD

ls                  List directory contents
file-upload         Upload files
file-download       Download file
folder-create       Create folder
resource-delete     Delete resource
                    Update file metadata
                    Update folder metadata
debug-get-resource  Get resource info (debug)

Use –debug option to see API calls and internal debug information.


  • python 2.7 or 3.4

  • six

  • requests

  • requests_toolbelt

  • responses (for testing)


$ pip install mediafire


Test suite is located under tests/

Run it with:

cd mediafire-python-open-sdk
PYTHONPATH=. python3 -munittest

About and License

Copyright (c) 2014, Roman Yepishev. All rights reserved. Website :

This project was forked by MediaFire with explicit permission from Roman Yepishev on 10.24.2014

This project is made under BSD license. See LICENSE file for more information.

MediaFire® is a registered trademark of the MediaFire, LLC.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mediafire-0.2.0.tar.gz (16.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page