staddress (Python)
Staddress AI API 公式 Python SDK。
ステータス
Phase 3 — v0.1 実装済み(parse_address / parse_batch / get_usage、同期・非同期対応)
- HTTP:
httpx(sync + async) - 型:
pydanticv2 モデル(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 を出力
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 staddress-0.1.0.tar.gz.
File metadata
- Download URL: staddress-0.1.0.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31d102b22b619c04c59d59d6a707251a0fc169d4c20f5dc779e4bf4932a18f5d
|
|
| MD5 |
73995208e5732570cf913dd3458ede0e
|
|
| BLAKE2b-256 |
990368e5fb35a6e2e4d1e7527ba86dd95f6a08e2033c8c492eb580629875363d
|
Provenance
The following attestation bundles were made for staddress-0.1.0.tar.gz:
Publisher:
publish-python.yml on StaddressAI/staddress-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
staddress-0.1.0.tar.gz -
Subject digest:
31d102b22b619c04c59d59d6a707251a0fc169d4c20f5dc779e4bf4932a18f5d - Sigstore transparency entry: 2387835689
- Sigstore integration time:
-
Permalink:
StaddressAI/staddress-tools@d336d7bcf06595ac2f8330f439cbedf2cb51701f -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/StaddressAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@d336d7bcf06595ac2f8330f439cbedf2cb51701f -
Trigger Event:
push
-
Statement type:
File details
Details for the file staddress-0.1.0-py3-none-any.whl.
File metadata
- Download URL: staddress-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb935a1155d040c6c6cf14eebc9ac3ea0c91049c270f20732790d16f49c13d18
|
|
| MD5 |
4efd1ef6654629038be3f2f7ab24c0f9
|
|
| BLAKE2b-256 |
05484c441ef287af1f87345a9ecaad5ccf93d47a935e8974e4de3203e57cd41d
|
Provenance
The following attestation bundles were made for staddress-0.1.0-py3-none-any.whl:
Publisher:
publish-python.yml on StaddressAI/staddress-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
staddress-0.1.0-py3-none-any.whl -
Subject digest:
cb935a1155d040c6c6cf14eebc9ac3ea0c91049c270f20732790d16f49c13d18 - Sigstore transparency entry: 2387835695
- Sigstore integration time:
-
Permalink:
StaddressAI/staddress-tools@d336d7bcf06595ac2f8330f439cbedf2cb51701f -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/StaddressAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@d336d7bcf06595ac2f8330f439cbedf2cb51701f -
Trigger Event:
push
-
Statement type: