Amazon
service_omni — Endpoints: Amazon¶
Location: backend/service_omni/app/api/v1/endpoints/amazon.py
Summary
- Manage Amazon SP-API credentials used for order and report downloads.
Routes
-
GET /amazon/— List Amazon credentials. Query params:skip,limit. Response:List[AmazonCredentialResponse]. -
POST /amazon/— Create Amazon credentials. Body model:AmazonCredentialCreate(example fields:name,lwa_client_id,lwa_client_secret,role_arn,marketplace_ids,is_active).
Example request:
{
"name": "ACME Merchant",
"lwa_client_id": "amzn1.application-oa2-client.xxxx",
"lwa_client_secret": "secret",
"role_arn": "arn:aws:iam::123456789012:role/SpApiRole",
"marketplace_ids": ["A1PA6795UKMFR9"],
"is_active": true
}
Curl:
curl -X POST "http://localhost:8000/api/v1/amazon/" \
-H "Content-Type: application/json" \
-d '{"name":"ACME Merchant","lwa_client_id":"...","lwa_client_secret":"...","role_arn":"...","marketplace_ids":["A1PA6795UKMFR9"],"is_active":true}'
GET /amazon/{id}— Retrieve a credential by id. Response:AmazonCredentialResponse.PUT /amazon/{id}— Update credential (AmazonCredentialUpdate).DELETE /amazon/{id}— Delete a credential.POST /amazon/{id}/toggle-active— Toggle active status.
Implementation & notes
- Endpoint implementation: backend/service_omni/app/api/v1/endpoints/amazon.py
-
SP-API helpers: backend/service_omni/app/services/amazon/spapi_client.py
-
Operational notes: Amazon SP-API requires LWA credentials and AWS role ARNs. Large report downloads should run as background tasks; persist results to disk/DB. Ensure tokens are refreshable and AWS roles are configured per merchant.