Skip to main content

staddress (Python)

Staddress AI API 公式 Python SDK。

ステータス

Phase 3 — v0.1 実装済み(parse_address / parse_batch / get_usage、同期・非同期対応)

  • HTTP: httpx(sync + async)
  • 型: pydantic v2 モデル(py.typed 同梱)

インストール

pip install staddress
# または
uv add staddress
poetry add staddress

使い方(同期)

from staddress import StaddressClient, StaddressError

client = StaddressClient(
    api_key="sk_xxx",              # 省略時は環境変数 STADDRESS_API_KEY
    base_url="https://api.staddress.com",  # 省略時は既定値
    timeout=30.0,                  # 任意(秒)
)

# 単件解析
result = client.parse_address(input="六本木ヒルズ 森タワー 52F", postal_code="106-6100")
print(result.normalized, result.components.pref)

# 一括解析(Standard プラン以上、最大100件)
results = client.parse_batch([
    {"id": "1", "address": "東京都渋谷区道玄坂1-2-3"},
    {"id": "2", "address": "大阪府大阪市北区梅田1-1-1"},
])

# 利用状況
usage = client.get_usage()

client.close()  # または with StaddressClient(...) as client:

使い方(非同期)

import asyncio
from staddress import StaddressAsyncClient

async def main():
    async with StaddressAsyncClient(api_key="sk_xxx") as client:
        result = await client.parse_address(input="六本木ヒルズ 森タワー 52F")
        print(result.normalized)

asyncio.run(main())

エラーハンドリング

API エラー・ネットワークエラーは StaddressError として送出されます。

from staddress import StaddressClient, StaddressError

try:
    client.parse_address(input="...")
except StaddressError as err:
    print(err.code)         # 例: "unauthorized", "quota_exceeded", "unresolved"
    print(err.http_status)  # HTTP ステータス(ネットワークエラー時は 0)
    print(err.request_id)   # サポート問い合わせ用(あれば)
    print(err.retry_after)  # 再試行可能日時(あれば)

API

メソッド HTTP 説明
parse_address(input, postal_code=None) POST /api/v1/addresses/parse 単件解析 → ParseResult
parse_batch(items) POST /api/v1/addresses/parse/batch 一括解析 → list[BatchItemResult]
get_usage() GET /api/v1/usage 利用状況 → UsageResponse

同名の非同期メソッドを StaddressAsyncClient が提供します(await して呼び出し)。

開発

cd packages/python
uv sync --extra dev
uv run ruff check .
uv run pytest
uv build            # dist/ に sdist + wheel を出力

詳細: docs/plan-tools.md §3.5

Metadata

Release files for staddress 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for staddress 0.1.0
File Size Uploaded
staddress-0.1.0.tar.gz 24.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for staddress 0.1.0
File Interpreter ABI Platform
staddress-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.0 kB

Release files / staddress-0.1.0.tar.gz

Download URL staddress-0.1.0.tar.gz
Size 24.0 kB
Tags Source
SHA-256 checksum
How to use checksums
31d102b22b619c04c59d59d6a707251a0fc169d4c20f5dc779e4bf4932a18f5d
BLAKE2b-256 checksum
How to use checksums
990368e5fb35a6e2e4d1e7527ba86dd95f6a08e2033c8c492eb580629875363d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.

Transparency log

Release files / staddress-0.1.0-py3-none-any.whl

Download URL staddress-0.1.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb935a1155d040c6c6cf14eebc9ac3ea0c91049c270f20732790d16f49c13d18
BLAKE2b-256 checksum
How to use checksums
05484c441ef287af1f87345a9ecaad5ccf93d47a935e8974e4de3203e57cd41d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page