PY

Python SDK

Official Python client for AI Body Scan API.

Installation

pip install aiscan-sdk

Quick Start

# Python example
import aiscan

# Initialize with your API key
client = aiscan.Client("sk_live_your_api_key")

# Extract measurements
result = client.measurements.extract(
    front="front.jpg",
    side="side.jpg",
    height=175,
    gender="male"
)

# Access measurements
print(result.measurements["Shoulder"])  # 46.4
print(result.accuracy)  # "±1-3cm"

API Reference

Client

aiscan.Client

Main client for interacting with the API.

client = aiscan.Client(api_key, base_url="https://api.aiscan.io")

Methods

extract()

Extract measurements from photos.

result = client.measurements.extract(
    front="photo.jpg",      # Required
    side="side.jpg",        # Required
    height=175,            # Required (cm)
    gender="male"         # "male" or "female"
)
estimate()

Estimate measurements from height only.

result = client.measurements.estimate(
    height=175,
    gender="male"
)

Error Handling

try:
    result = client.measurements.extract(
        front="front.jpg",
        side="side.jpg",
        height=175
    )
except aiscan.APIError as e:
    print(f"API Error: {e.message}")
except aiscan.AuthenticationError as e:
    print(f"Auth Error: {e.message}")
except aiscan.RateLimitError as e:
    print(f"Rate limited. Retry after: {e.retry_after}s")

Async Support

import aioaiscan

# Async client
client = aioaiscan.AsyncClient("sk_live_key")

# Extract with async/await
result = await client.measurements.extract(
    front="front.jpg",
    side="side.jpg",
    height=175
)