Skip to main content

Async wrapper for Trace.moe API

Project description

AioTraceMoeAPI

MIT License PyPi Package Version Downloads Supported python versions

A simple, but extensible asynchronous Python wrapper for the trace.moe API.

Key Features

  • Async: Built on top of httpx for high-performance asynchronous HTTP requests.
  • Typed: Fully typed codebase for better developer experience and IDE support.
  • Pydantic v2: Uses Pydantic v2 for robust data validation and serialization.

Installation

You can install the package using uv or pip:

uv add aiotracemoeapi

or

pip install aiotracemoeapi

Usage Examples

Basic Search by URL

import asyncio
from aiotracemoeapi import TraceMoe

async def main():
    api = TraceMoe()
    
    # Search by URL
    # Note: is_url=True is required when passing a URL string
    result = await api.search("https://images.plurk.com/32B15UXxymfSMwKGTObY5e.jpg", is_url=True)
    
    if result.result:
        print(f"Anime: {result.result[0].filename}")
        print(f"Similarity: {result.result[0].similarity}")
    else:
        print("No results found.")

if __name__ == "__main__":
    asyncio.run(main())

Running Examples

Examples can be run using uv run:

uv run examples/console.py

Search by File Upload

You can search using a local file path.

import asyncio
from aiotracemoeapi import TraceMoe

async def main():
    api = TraceMoe()
    
    # Search by local file path
    # Ensure 'image.jpg' exists in your directory
    try:
        result = await api.search("image.jpg")
        
        if result.result:
            print(f"Anime: {result.result[0].filename}")
            print(f"Episode: {result.result[0].episode}")
    except FileNotFoundError:
        print("File not found!")

if __name__ == "__main__":
    asyncio.run(main())

Checking Account Status

You can check your API usage limits and quota.

import asyncio
from aiotracemoeapi import TraceMoe

async def main():
    # Initialize with your API token (optional, but recommended for higher limits)
    # Get your token from https://trace.moe/account
    api = TraceMoe(token="your_token_here")
    
    me = await api.me()
    
    print(f"ID: {me.id}")
    print(f"Priority: {me.priority}")
    print(f"Quota Used: {me.quota_used}")
    print(f"Quota Total: {me.quota}")

if __name__ == "__main__":
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiotracemoeapi-3.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiotracemoeapi-3.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file aiotracemoeapi-3.1.0.tar.gz.

File metadata

  • Download URL: aiotracemoeapi-3.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for aiotracemoeapi-3.1.0.tar.gz
Algorithm Hash digest
SHA256 29638269a16a7e96fe8c181cf000e1cbea1ac0bc3588368a754db7268620c29b
MD5 5031c0e9837ade073e300e9aaf117a61
BLAKE2b-256 73759da85a9d921986e82c9cfb28f796f512248ae2e33188121fc75fce7252e1

See more details on using hashes here.

File details

Details for the file aiotracemoeapi-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: aiotracemoeapi-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for aiotracemoeapi-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77b05861753de04b0127e04845e6c55e9435eab2385cc781e43d3f726e907dc8
MD5 43cdcd238ab69652308f5122ea5064ed
BLAKE2b-256 73ada6153678fc8882d6122868dc25bacc98bd19ba89045467ea4b37c28fa606

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page