INNER CODE UNIT · Python
batch_create_accounts
CassiopeiaCode/q2api · account-feeder/app.py:306
async def batch_create_accounts(request: BatchCreateRequest):
"""批量创建账号(调用主服务统一feed接口)"""
try:
headers = {"content-type": "application/json"}
if API_SERVER_PASSWORD:
headers["Authorization"] = f"Bearer {API_SERVER_PASSWORD}"
async with httpx.AsyncClient(timeout=60.0) as client:
r = await client.post(
f"{API_SERVER}/v2/accounts/feed",
json={"accounts": request.accounts},
headers=headers,
)
r.raise_for_status()
return r.json()
except httpx.HTTPStatusError as e:
raise HTTPException(
status_code=e.response.status_code,