Tutorial: Automate your SP-API Calls using prebuilt Java SDK
Automate your SP-API calls using prebuilt Java SDK.
This tutorial shows you how to install and integrate prebuilt Java SDK. You will learn the prerequisites required to install the prebuilt Java SDK and also view an example using the Selling Partner API for Sellers.
Tutorial
The Java SDK is published on Maven Central and supports Java 11 or higher. You can integrate Java SDK to your application using Maven or Gradle.
Step 1. Add the Java SDK dependency to your application
You can add the Java SDK dependency to your application using Maven or Gradle. You can get the latest SDK version from the release version.
Maven
Add the following code as a dependency in the pom.xml
file.
<dependency>
<groupId>software.amazon.spapi</groupId>
<artifactId>spapi-sdk</artifactId>
<version>1.0.0</version>
</dependency>
Gradle
Add the following code as a dependency in the build.gradle
file.
implementation 'software.amazon.spapi:spapi-sdk:0.1.0'
Step 2. Connect the Java SDK to SP-API
To connect the Java SDK to the SP-API, you must:
- Configure your Login with Amazon credentials
- Create an instance for a specific API
- Call an operation
For an example, refer to the following sample code:
// Configure LWA credentials
LWAAuthorizationCredentials credentials = LWAAuthorizationCredentials.builder()
.clientId("amzn1.application-*********************")
.clientSecret("***********************************")
.refreshToken("Atzr|******************************")
.endpoint("https://api.amazon.com/auth/o2/token")
.build();
// Create an instance of Sellers API
SellersApi api = new SellersApi.Builder()
.lwaAuthorizationCredentials(credentials)
.endpoint("https://sellingpartnerapi-na.amazon.com")
.build();
// Call an operation from Sellers API
GetMarketplaceParticipationsResponse response = api.getMarketplaceParticipations();
Report Issues
You can report issues on GitHub.
Updated 4 days ago