Async wrapper for Trace.moe API
Project description
AioTraceMoeAPI
A simple, but extensible asynchronous Python wrapper for the trace.moe API.
Key Features
- Async: Built on top of
httpxfor 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())
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
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
aiotracemoeapi-3.0.0.tar.gz
(5.4 kB
view details)
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 aiotracemoeapi-3.0.0.tar.gz.
File metadata
- Download URL: aiotracemoeapi-3.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1278ecfe42f2fe27ead983afc4a2d73e545d7d8944217ef779311ac68a8a1cee
|
|
| MD5 |
5d6963c577cdcdcc1c749340109a32d9
|
|
| BLAKE2b-256 |
069273461426304db95cd672eeb598cfa727fa87444b0e43f8e40310fed70b5f
|
File details
Details for the file aiotracemoeapi-3.0.0-py3-none-any.whl.
File metadata
- Download URL: aiotracemoeapi-3.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df3d77a1444fdaa52a4937f5faeca197a64a9807a645039f3006306548522ab1
|
|
| MD5 |
22de07944ceb1cb52ac81fc8e9a2c579
|
|
| BLAKE2b-256 |
2bf7aa804f2bfdcdcd3dbf5f222063f163e12b3a2b465dbc315b5bd54e51cc23
|