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.2.tar.gz (6.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.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiotracemoeapi-3.1.2.tar.gz
  • Upload date:
  • Size: 6.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.2.tar.gz
Algorithm Hash digest
SHA256 81cbb692d36b3c56b72fc7d30afafbf4c8c0248de92be251351585cd4a272711
MD5 00a71f44a3a2afab597d150e487e9edc
BLAKE2b-256 e5ffa2ecb5084cd041adadada3a2c0301450c4d1c636de56b38d9abe6b12d9a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiotracemoeapi-3.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0d237cf87febc0f2264afe829669851c868710e2e1c1a354e6da819621d700e
MD5 61e0eb27c45bca24e479313e98923ab1
BLAKE2b-256 569c28555b373f3823fbf1b6fbd341cdd4ecde01f4469043f4355df77945793b

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