Skip to main content

catboxpy

catboxpy is a Python wrapper for Catbox, which allows you to easily upload files, manage albums, and interact with the Catbox service. This package supports both synchronous and asynchronous usage.

Installation

From PyPI

You can easily install the stable version of catboxpy from PyPI using pip:

pip install catboxpy

From GitHub Repository

Alternatively, if you wish to access the latest (potentially unstable) version directly from the GitHub repository, you can execute the following command:

pip install git+https://github.com/anshonweb/catboxpy.git

Features

  • Upload files to Catbox.
  • Create and manage albums (synchronous and asynchronous support).
  • Delete files from Catbox.
  • Both synchronous and asynchronous methods for flexible usage.

Installation

To install catboxpy, simply use pip:

pip install catboxpy

Usage

Synchronous Usage

The synchronous interface is simple to use for blocking operations. Here is how to use it:

1. Uploading a File

from catboxpy.catbox import CatboxClient

client = CatboxClient(userhash="your_userhash_here")
file_url = client.upload("path/to/your/file.jpg")
print(f"File uploaded to: {file_url}")

2. Uploading a URL

You can upload files directly from a URL:

url = client.upload('https://example.com/your_image.jpg')
print(f"URL uploaded to: {url}")

3. Creating an Album

To create an album:

album_url = client.album.create("My Album", "Album description", ["file1.jpg", "file2.jpg"])
print(f"Album created at: {album_url}")

4. Deleting a File

To delete a file by its URL:

client.delete_file("file_url")

Asynchronous Usage

The asynchronous interface allows you to perform operations without blocking the execution of other tasks, making it ideal for applications that need to handle multiple requests concurrently.

1. Uploading a File Asynchronously

import asyncio
from catboxpy.catbox import AsyncCatboxClient

async def upload_file():
    client = AsyncCatboxClient(userhash="your_userhash_here")
    file_url = await client.upload("path/to/your/file.jpg")
    print(f"File uploaded to: {file_url}")

# Running the async function
asyncio.run(upload_file())

2. Uploading a URL Asynchronously

import asyncio
from catboxpy.catbox import AsyncCatboxClient

async def upload_url():
    client = AsyncCatboxClient(userhash="your_userhash_here")
    url = await client.upload('https://example.com/your_image.jpg')
    print(f"URL uploaded to: {url}")

# Running the async function
asyncio.run(upload_url())

3. Creating an Album Asynchronously

import asyncio
from catboxpy.catbox import AsyncCatboxClient

async def create_album():
    client = AsyncCatboxClient(userhash="your_userhash_here")
    album_url = await client.album.create("My Album", "Album description", ["file1.jpg", "file2.jpg"])
    print(f"Album created at: {album_url}")

# Running the async function
asyncio.run(create_album())

4. Deleting a File Asynchronously

import asyncio
from catboxpy.catbox import AsyncCatboxClient

async def delete_file():
    client = AsyncCatboxClient(userhash="your_userhash_here")
    await client.delete_file("file_url")

# Running the async function
asyncio.run(delete_file())

Litterbox Usage

from catboxpy import LitterboxClient

uploader = LitterboxClient()
try:
    url = uploader.upload_file("filepath", expire_time="1h")
    print(f"Uploaded to: {url}")
except Exception as e:
    print(f"Upload failed: {e}")

Authentication

For most operations, such as uploading or managing albums, you need a valid userhash. You can obtain the userhash by logging in to Catbox and accessing your user settings.

  • If you're performing anonymous uploads, you can omit the userhash. However, operations like creating and managing albums require a valid userhash.

Notes

  • Album Limitations: Catbox albums currently allow a maximum of 500 files. This limit may change in the future.
  • Anonymous Albums: Anonymous albums cannot be edited or deleted, and they also cannot contain more than 500 files.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For issues, bugs, or suggestions, please open an issue on the GitHub repository.


Metadata

Release files for catboxpy 0.1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for catboxpy 0.1.1.1
File Size Uploaded Provenance Actions
catboxpy-0.1.1.1.tar.gz 6.6 kB Without provenance Details for catboxpy-0.1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for catboxpy 0.1.1.1
File Interpreter ABI Platform Actions
catboxpy-0.1.1.1-py3-none-any.whl Python 3 none any Details for catboxpy-0.1.1.1-py3-none-any.whl

Total release size: 14.5 kB

Release files / catboxpy-0.1.1.1.tar.gz

Download URL catboxpy-0.1.1.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a7cd37e18e88ea86c2d15c384d23c021603b5bde67fa9c2cd4f6e9ab7b812314
BLAKE2b-256 checksum
How to use checksums
91924e719d1bf2146ab07a3e7238b92a4159b142f0ef7ccb61a1c10cfdbb260d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / catboxpy-0.1.1.1-py3-none-any.whl

Download URL catboxpy-0.1.1.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
021535e5c64f965ad92e2589b31ed89f31a7c56d24af253e1e4f8c4106acf564
BLAKE2b-256 checksum
How to use checksums
30031c67ac821bbd81bef034f0ba3e69a5340560a147f9dac433b6712817c8d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Security for catboxpy 0.1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page