Introduction
MegaDownloader includes a robust Java-based API client (ApiClient) that handles all communication with the backend server. The client provides a clean, type-safe interface for authentication, user management, and media operations.
Purpose
The API client serves as the primary interface between the MegaDownloader application and the backend server, providing:- User Authentication - JWT-based login and session management
- User Profile Management - Retrieve user information and nicknames
- Media Operations - Upload, download, list, and filter media files
- Blob Storage Integration - Direct interaction with Azure Blob Storage containers
- Polling Support - Time-based media synchronization using ISO-8601 timestamps
Architecture
The API client is built on Java’s modernHttpClient API (java.net.http) and uses Jackson for JSON serialization/deserialization.
The client uses a 10-second connection timeout and 30-second request timeout by default.
Authentication Flow
- Login - User provides email and password to
/api/Auth/login - Token Receipt - Server returns a JWT token (checked as
token,access_token, orjwt) - Token Storage - Application stores token locally using Java Preferences API
- Authenticated Requests - Token is sent as
Bearertoken inAuthorizationheader - Auto-Login - Stored tokens are validated on application restart
Available Endpoints
Authentication
POST /api/Auth/login- Authenticate and receive JWT token
User Management
GET /api/users/me- Get current user profileGET /api/users/{id}/nickname- Get user nickname by ID
Media Operations
GET /api/files/all- List all media filesGET /api/files/me- List current user’s mediaGET /api/files/user/{userId}- List media by specific userGET /api/files/{id}- Download media file by IDPOST /api/files/upload- Upload new media fileGET /api/files/added-since- Get media added after a timestampGET /api/files- List blobs in container
Data Models
The API client uses two primary model classes:Usuari
User profile data including email, nickname, and registration info
Media
Media file metadata including URLs, MIME types, and blob references
Error Handling
The API client throwsIOException for HTTP errors and network issues:
Next Steps
ApiClient Reference
Detailed method signatures and examples
Authentication Guide
JWT handling and token management

