已经开发部分的SP-API代码,包括获取订单、亚马逊管理库存等;
技术框架:springboot+xxlJob+Redis+Mysql+sentinel+swagger2,可配置多数据源;
销售伙伴 API 是一个基于 REST 的 API,亚马逊卖家可以使用这些接口,以编程方式访问他们有关商品、订单、付款、报告等的数据。使用销售伙伴 API 的应用程序可以提高销售效率,减少人力需求并缩短响应客户的时间,从而帮助卖家发展业务。销售伙伴 API 基于亚马逊商城网络服务(亚马逊 MWS)的功能构建,但提供了一些功能,帮助开发者及其卖家合作伙伴提高可用性和安全性。
主要功能
使用销售伙伴 API,您可以:
设置卖家从商城应用商店详情页面或从您自己的网站启动的 OAuth 授权工作流程。
生成可以帮助您进行 LWA 令牌交换和身份验证的 SDK。
创建混合应用程序,可同时调用销售伙伴 API 和亚马逊 MWS。
通过调用沙箱环境来测试应用程序。
public OrdersV0Api api(){
UUID uuid = UUID.randomUUID();
// Step 1. Configure your AWS credentials
//accessKeyId Your AWS access key Id, from Step 2. Create an IAM user. Yes
//secretKey Your AWS secret access key, from Step 2. Create an IAM user. Yes
//region The AWS region to which you are directing your call. For more information, see Selling Partner API endpoints. Yes
AWSAuthenticationCredentials awsAuthenticationCredentials = AWSAuthenticationCredentials.builder()
.accessKeyId("")
.secretKey("")
.region("us-east-1")//北美
.build();
// Step 2. Configure your AWS credentials provider
// roleArn The ARN of the IAM role that you created in Step 4. Create an IAM role. Yes
//roleSessionName An identifier for the session that you define. We recommend using a Universally Unique Identifier (UUID). Yes
AWSAuthenticationCredentialsProvider awsAuthenticationCredentialsProvider = AWSAuthenticationCredentialsProvider.builder()
.roleArn("")
.roleSessionName(uuid.toString())
.build();
// Step 3. Configure your LWA credentials 在店铺后台开发者应用里面的参数
LWAAuthorizationCredentials lwaAuthorizationCredentials = LWAAuthorizationCredentials.builder()
.clientId("")
.clientSecret("")
.refreshToken("")
.endpoint("https://api.amazon.com/auth/o2/token")
.build();
return new OrdersV0Api.Builder().awsAuthenticationCredentials(awsAuthenticationCredentials)
.lwaAuthorizationCredentials(lwaAuthorizationCredentials)
.awsAuthenticationCredentialsProvider(awsAuthenticationCredentialsProvider)
.endpoint("https://sellingpartnerapi-na.amazon.com") //北美
.build();
}
@Test
public void getOrdersTest() throws ApiException {
List<String> marketplaceIds = new ArrayList<>();
marketplaceIds.add("ATVPDKIKX0DER");
String createdAfter = "2020-12-30T16:51:15.429Z";
String createdBefore = "2021-01-20T09:38:15.429Z";
String lastUpdatedAfter = null;
String lastUpdatedBefore = null;
List<String> orderStatuses = null;
List<String> fulfillmentChannels = null;
List<String> paymentMethods = null;
String buyerEmail = null;
String sellerOrderId = null;
Integer maxResultsPerPage = null;
List<String> easyShipShipmentStatuses = null;
String nextToken = null;
List<String> amazonOrderIds = null;
GetOrdersResponse response = api().getOrders(marketplaceIds, createdAfter, createdBefore, lastUpdatedAfter, lastUpdatedBefore, orderStatuses, fulfillmentChannels, paymentMethods, buyerEmail, sellerOrderId, maxResultsPerPage, easyShipShipmentStatuses, nextToken, amazonOrderIds);
System.out.println(response);
// TODO: test validations
}