npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jesusacd/mediafire

v1.2.0

Published

MediaFire API SDK for Node.js - Upload, download, and manage files on MediaFire

Readme

@jesusacd/mediafire

Complete MediaFire SDK for Node.js. Just use your email and password to access all API features.

npm version

✨ Features

  • 🔐 Simple Authentication - Just email and password, no API keys needed
  • 📁 Full Management - Files and folders (create, move, copy, delete)
  • 📤 File Upload - Supports large files
  • 🔍 Search - Search files in your account
  • 🔗 Direct Links - Get download URLs
  • 📊 TypeScript - Full type definitions included

📦 Installation

npm install @jesusacd/mediafire

🚀 Quick Start

const { MediaFireClient } = require("@jesusacd/mediafire");

const client = new MediaFireClient();

async function main() {
  // Just email and password - that's it!
  await client.login("[email protected]", "your-password");

  // Get user info
  const user = await client.user.getInfo();
  console.log(`Hello, ${user.displayName}!`);

  // Upload a file
  const result = await client.upload.file("./my-file.pdf");
  console.log(`Uploaded: ${result.quickKey}`);

  // Get download link
  const links = await client.files.getLinks(result.quickKey);
  console.log(`Link: ${links.directDownload}`);
}

main();

📚 API Reference

Authentication

const client = new MediaFireClient();

// Login with email and password
await client.login("[email protected]", "password");

// Check if authenticated
client.isAuthenticated(); // true

// Get session data
const session = client.getSession();

// Restore previous session
client.setSession(session);

// Logout
client.logout();

👤 User Module

// User information
const user = await client.user.getInfo();
// { displayName, email, firstName, lastName, gender, birthDate, premium, emailVerified, createdAt }

// Storage info
const storage = await client.user.getStorage();
// { used, total, usedFormatted: "500 MB", totalFormatted: "10 GB", percentUsed: 5 }

📁 Folders Module

// List folder contents
const content = await client.folders.getContent("folderKey");
// { items: [...], moreChunks, chunkNumber }

// Get only files
const files = await client.folders.getFiles("folderKey");

// Get only folders
const folders = await client.folders.getFolders("folderKey");

// Get folder info
const info = await client.folders.getInfo("folderKey");
// { folderKey, name, description, created, privacy, fileCount, folderCount, totalSize }

// Create folder
const newFolder = await client.folders.create("My Folder", "parentKey");
// { folderKey, name }

// Rename folder
await client.folders.rename("folderKey", "New Name");

// Move to another folder
await client.folders.move("folderKey", "destFolderKey");

// Copy folder
const newKey = await client.folders.copy("folderKey", "destFolderKey");

// Change privacy
await client.folders.setPrivacy("folderKey", "public"); // or 'private'

// Delete (move to trash)
await client.folders.delete("folderKey");

// Permanently delete
await client.folders.purge("folderKey");

📄 Files Module

// Get file info
const fileInfo = await client.files.getInfo("quickKey");
// { quickKey, name, size, sizeFormatted, hash, created, privacy, mimeType, ... }

// Get links
const links = await client.files.getLinks("quickKey");
// { viewLink, normalDownload, directDownload }

// Search files
const results = await client.files.search("document");
// { files: [...], total }

// Change privacy
await client.files.setPrivacy("quickKey", "public");
await client.files.makePublic("quickKey"); // Shortcut
await client.files.makePrivate("quickKey"); // Shortcut

// Rename file
await client.files.rename("quickKey", "new-name.pdf");

// Move to another folder
await client.files.move("quickKey", "folderKey");

// Copy file
const newKeys = await client.files.copy("quickKey", "folderKey");

// Delete (move to trash)
await client.files.delete("quickKey");

// Restore from trash
await client.files.restore("quickKey");

// Permanently delete
await client.files.purge("quickKey");

// Get file versions
const versions = await client.files.getVersions("quickKey");

// Get recently modified files
const recent = await client.files.getRecentlyModified();

📤 Upload Module

// Upload file from disk
const result = await client.upload.file("./file.pdf", {
  folderKey: "destFolderKey", // Optional: destination folder
  actionOnDuplicate: "keep", // 'skip' | 'keep' | 'replace'
});
// { quickKey, filename, size, uploadKey }

// Upload from Buffer
const buffer = Buffer.from("File content");
const result = await client.upload.buffer(buffer, "file.txt", {
  folderKey: "destFolderKey",
});

// Check if file exists (for instant upload)
const check = await client.upload.check(sha256Hash, "file.pdf", fileSize);
// { hashExists, inAccount, inFolder, duplicateQuickKey }

// Instant upload (if file already exists on MediaFire)
const result = await client.upload.instant(
  sha256Hash,
  "file.pdf",
  fileSize,
  "folderKey",
);

💡 Usage Examples

Upload multiple files

const files = ["doc1.pdf", "doc2.pdf", "image.png"];

for (const file of files) {
  const result = await client.upload.file(file);
  console.log(`✅ ${file} -> ${result.quickKey}`);
}

Create folder structure

// Create main folder
const main = await client.folders.create("Project 2024");

// Create subfolders
await client.folders.create("Documents", main.folderKey);
await client.folders.create("Images", main.folderKey);
await client.folders.create("Videos", main.folderKey);

Backup local folder

const fs = require("fs");
const path = require("path");

async function backupFolder(localPath, remoteFolderKey) {
  const files = fs.readdirSync(localPath);

  for (const file of files) {
    const filePath = path.join(localPath, file);

    if (fs.statSync(filePath).isFile()) {
      const result = await client.upload.file(filePath, {
        folderKey: remoteFolderKey,
      });
      console.log(`✅ ${file} uploaded`);
    }
  }
}

// Usage
const folder = await client.folders.create("Backup-" + Date.now());
await backupFolder("./my-documents", folder.folderKey);

Get all links from a folder

const files = await client.folders.getFiles("folderKey");

for (const file of files) {
  const links = await client.files.getLinks(file.quickKey);
  console.log(`${file.name}: ${links.directDownload || links.viewLink}`);
}

Search and download

const results = await client.files.search("report");

for (const file of results.files) {
  const links = await client.files.getLinks(file.quickKey);
  console.log(`📄 ${file.name}`);
  console.log(`   Download: ${links.directDownload}`);
}

⚠️ Error Handling

const { MediaFireClient, MediaFireError } = require("@jesusacd/mediafire");

try {
  await client.login("email", "wrong-password");
} catch (error) {
  if (error instanceof MediaFireError) {
    console.log("MediaFire Error:", error.message);
    console.log("Code:", error.code);
  }
}

📊 Limits and Performance

  • Max file size: Depends on your MediaFire plan
  • Upload speed: ~16 MB/s (depends on your connection)
  • Session: Automatically managed with key rotation

🔧 Advanced Configuration

const client = new MediaFireClient({
  appId: "42511", // App ID (optional, uses default)
  apiVersion: "1.3", // API version
  timeout: 30000, // Timeout in ms
});

📋 Available Methods

| Module | Method | Description | | ----------- | ------------------------------- | -------------------- | | Auth | login(email, password) | Log in | | | logout() | Log out | | | isAuthenticated() | Check authentication | | | getSession() | Get session data | | | setSession(session) | Restore session | | User | getInfo() | User info | | | getStorage() | Storage used | | Folders | getContent(key, options) | List contents | | | getFiles(key, options) | List files | | | getFolders(key, options) | List folders | | | getInfo(key) | Folder info | | | create(name, parentKey) | Create folder | | | rename(key, newName) | Rename | | | move(key, destKey) | Move | | | copy(key, destKey) | Copy | | | setPrivacy(key, privacy) | Change privacy | | | delete(key) | Delete (trash) | | | purge(key) | Permanently delete | | Files | getInfo(quickKey) | File info | | | getLinks(quickKey) | Get links | | | search(query, options) | Search files | | | setPrivacy(quickKey, privacy) | Change privacy | | | makePublic(quickKey) | Make public | | | makePrivate(quickKey) | Make private | | | rename(quickKey, newName) | Rename | | | move(quickKey, folderKey) | Move | | | copy(quickKey, folderKey) | Copy | | | delete(quickKey) | Delete (trash) | | | restore(quickKey) | Restore | | | purge(quickKey) | Permanently delete | | | getVersions(quickKey) | Version history | | | getRecentlyModified() | Recent files | | Upload | file(path, options) | Upload from disk | | | buffer(buffer, name, options) | Upload from buffer | | | check(hash, name, size) | Check existence | | | instant(hash, name, size) | Instant upload |


📄 License

MIT © JesusACD