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.1.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.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiotracemoeapi-3.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 251e5cb8265c6ae171868c3dc0f33d8426029d03fd2e170d3a0ef80cd331b2a2
MD5 078847caabb1da7f37d9a1b4229b1971
BLAKE2b-256 77aceeaf3cb1e4b7f9c9d8ac5903ab71440a1f8df862fb6acc2898be9ec73427

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiotracemoeapi-3.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3044d27e8130f5269f90bfcdc3620d1530d0d06768d7bdd9333edce89d9321dd
MD5 a74eaff871d0f8f3e8f2838fb498688a
BLAKE2b-256 e76ffc73d10971637a9cfd2084e9ac81dcee1c03c4b23cfd2dfaf27c67924bbd

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