Coder Social home page Coder Social logo

mega-api's Introduction

Python MEGA API Wrapper

mega_api_logo_2

Overview

This Python API provides a seamless interface with MEGA, offering functionalities to upload, download, delete, and list files stored on MEGA, with a special focus on multimedia content such as photos and videos. It's tailored to handle media files efficiently, making it ideal for personal media management or integration into larger media-focused applications.

Library Utilization

Due to the discontinuation of the original mega.py library, I've incorporated it locally and made necessary modifications to ensure continued functionality. The adapted library can be found at mega.py on PyPI.

Vercel Deployment

The codebase is prepared for deployment on Vercel with the included vercel.json file. Deploying a Python function on Vercel is straightforward:

  1. Ensure you have the Vercel CLI installed and configured.
  2. Clone this repository and navigate to the project directory.
  3. Run vercel to deploy the project.
  4. Follow the prompts to link your project to a Vercel account and deploy your API.

Environment Variables

Before deployment, ensure that the environment variables are set up correctly. These are critical for the API's operation and include your MEGA account's email and password. The necessary environment variables are:

  • EMAIL: Your MEGA account email.
  • PASS: Your MEGA account password.
  • JWT_SECRET_KEY: A secret key for JWT token generation.
  • JWT_USERNAME: The username for API authentication.
  • JWT_PASSWORD: The password for API authentication.
  • UPLOAD_FOLDER: The local folder for temporarily storing files during upload/download operations.

Remember to replace these with your actual credentials and preferred configuration.

Authentication

All methods require authentication. The API utilizes JWT for secure access. The user credentials are defined in the environment variables, enabling a database-less authentication mechanism for quick and straightforward setup.

Endpoints

  • /list: Lists all files in the linked MEGA account.
  • /upload: Uploads a file to the MEGA account.
  • /download/<file_key>: Downloads a file based on its MEGA key.
  • /delete/<file_key>: Deletes a file based on its MEGA key.
  • /details: Retrieves details of the linked MEGA account.

Future implementations may include /download and /delete by URL. While file name-based operations are possible, they are currently not supported due to potential issues with duplicate names and ASCII character encoding.

Installation

Before running the API, install the required dependencies with the following command:

pip install -r requirements.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.