# md_api
`md_api` is an asynchronous Rust client for the MediaFire API, allowing you to:
- Fetch file metadata
- Fetch folder metadata
- Fetch paginated folder contents
- Extract file and folder keys from MediaFire URLs
- Handle rate-limited requests with automatic retries
Built with `tokio`, `reqwest`, `serde`, and `regex`.
## Features
- Async API requests using Tokio runtime
- Automatic retry with exponential backoff for rate-limited endpoints
- Support for proxies
- Extract keys from MediaFire URLs (files and folders)
- Fetch both files and subfolders in a single request
## Installation
Add this to your `Cargo.toml`:
```toml
md_api = "0.1"
```
## Usage Example
```rust
use md_api::Api;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize API client with max 5 retries
let api = Api::new(5)?;
// Extract keys from URLs
let urls = vec!["https://www.mediafire.com/file/j2tq12gr15jhq2r".to_string()];
let keys = api.extract_keys_from_url(&urls)?;
// Fetch file info
for key in keys.iter() {
let info = api.get_info(&key).await?;
println!("{:#?}", info);
}
Ok(())
}
```
## API Highlights
- `Api::new(max_retries: u64)` – Create a new client.
- `Api::with_proxies(proxies: Vec<String>)` – Configure HTTP proxies.
- `Api::get_info(&Key)` – Fetch file or folder metadata.
- `Api::get_folder_content(&Key, ContentType, chunk)` – Fetch folder content paginated.
- `Api::get_folder_and_file_content(&Key, chunk)` – Fetch both files and folders in a single call.
- `Api::extract_keys_from_url(&Vec<String>)` – Extract MediaFire keys from URLs.
## Requirements
- Rust 1.75+
- Tokio runtime
## License
Licensed under MIT