Python client library for the Rapidgator API
Project description
Rapidgator API Client
This Python package provides a comprehensive client for interacting with the Rapidgator API. It allows you to manage files, folders, and perform various operations on your Rapidgator account programmatically.
Installation
You can install the package using pip:
pip install rapidgator-api-client
Usage
Here are some examples of how to use the Rapidgator API Client:
Initializing the Client
from rapidgator_api import RapidgatorClient
# Initialize with login credentials
client = RapidgatorClient(login='your_email@example.com', password='your_password')
# Or initialize with an existing token
client = RapidgatorClient(token='your_access_token')
User Information
user_info = client.get_user_info()
print(f"Email: {user_info.email}")
print(f"Premium: {user_info.is_premium}")
print(f"Storage left: {user_info.storage.left} bytes")
Folder Operations
# Create a folder
new_folder = client.create_folder(name='My New Folder')
print(f"Created folder: {new_folder.name} (ID: {new_folder.folder_id})")
# Get folder content
content = client.get_folder_content(folder_id=new_folder.folder_id)
print(f"Subfolders: {len(content['folder'].folders)}")
print(f"Files: {len(content['files'])}")
# Rename a folder
renamed_folder = client.rename_folder(folder_id=new_folder.folder_id, name='Renamed Folder')
print(f"Renamed to: {renamed_folder.name}")
# Delete a folder
result = client.delete_folder(folder_ids=new_folder.folder_id)
print(f"Deletion result: {result}")
File Operations
# Upload a file
uploaded_file = client.upload_file('/path/to/local/file.txt')
print(f"Uploaded file: {uploaded_file.name} (ID: {uploaded_file.file_id})")
# Get file info
file_info = client.get_file_info(file_id=uploaded_file.file_id)
print(f"File size: {file_info.size} bytes")
# Rename a file
renamed_file = client.rename_file(file_id=uploaded_file.file_id, new_name='renamed_file.txt')
print(f"Renamed to: {renamed_file.name}")
# Move a file
result = client.move_file(file_ids=uploaded_file.file_id, dest_folder_id='destination_folder_id')
print(f"Move result: {result}")
# Download a file
client.download_file(file_id=uploaded_file.file_id, local_path='/path/to/save/file.txt')
# Delete a file
result = client.delete_file(file_ids=uploaded_file.file_id)
print(f"Deletion result: {result}")
Trash Can Operations
# Get trash can content
trash_content = client.get_trashcan_content()
print(f"Files in trash: {len(trash_content['files'])}")
# Restore files from trash
result = client.restore_trashcan_files(file_ids=['file_id1', 'file_id2'])
print(f"Restoration result: {result}")
# Empty trash can
result = client.empty_trashcan()
print(f"Trash can emptied: {result}")
Remote Upload
# Create a remote upload job
jobs = client.create_remote_upload_job(urls='http://example.com/file.zip')
print(f"Created job ID: {jobs[0].job_id}")
# Get remote upload job info
job_info = client.get_remote_upload_info(job_ids=jobs[0].job_id)
print(f"Job status: {job_info[0].state_label}")
# Delete a remote upload job
result = client.delete_remote_upload_job(job_ids=jobs[0].job_id)
print(f"Job deletion result: {result}")
Upload a Local Folder
uploaded_folder = client.upload_folder('/path/to/local/folder')
print(f"Uploaded folder: {uploaded_folder.name} (ID: {uploaded_folder.folder_id})")
Error Handling
The client raises custom exceptions for different error scenarios. You can catch these exceptions to handle errors gracefully:
from rapidgator_api import RapidgatorAPIError, RapidgatorAuthenticationError
try:
client.upload_file('/path/to/nonexistent/file.txt')
except RapidgatorAPIError as e:
print(f"An API error occurred: {str(e)}")
except RapidgatorAuthenticationError as e:
print(f"Authentication failed: {str(e)}")
Notes
- This client implements automatic retries (up to 3 times) for failed requests.
- Upload and download operations display progress bars using the
tqdmlibrary. - Always ensure you have the necessary permissions and comply with Rapidgator's terms of service when using this client.
License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rapidgator_api-1.1.0.tar.gz.
File metadata
- Download URL: rapidgator_api-1.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee73bf2b07cc5b8a702d2e508e6d833c4bd8558f27e8de3caa8c2a7727c24cb6
|
|
| MD5 |
e59a3b11ee20abc7db88e0428d821266
|
|
| BLAKE2b-256 |
2207e73a640e21e6e88d5e4774ff3152ba9c3877c86067d17ede8eb5476fbb65
|
File details
Details for the file rapidgator_api-1.1.0-py3-none-any.whl.
File metadata
- Download URL: rapidgator_api-1.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9e4e2a1362624681ad4ee60dc0a3bba7c28d13d6b2a67f081b33003dce83d09
|
|
| MD5 |
46bf0ef072ec2f1e567148a99460aacd
|
|
| BLAKE2b-256 |
56337faaf080d55f8c960ed80b9758f8c94a28611027f15cffc6a0ef8080c935
|