Generating a Java client library
How to generate a Java client library.
These instructions show you how to generate a Java client library for the Sellers API using Swagger Code Generator on a computer running Microsoft Windows. The process is the same for users of other operating systems such as macOS or Linux, with the replacement of Windows-specific semantics (for example, C:\). Although these instructions are for the Sellers API, you can modify the instructions to make client libraries for other APIs in the Selling Partner API. See Models for Swagger models for each Selling Partner API section.
While a generated client library can help you make calls to the Selling Partner API, it does not contain code for LWA token exchange and authentication. For that, see Step 1. Request a Login with Amazon access token and Step 4. Create and sign your request. Or, for an SDK that includes LWA token exchange and authentication, see Generating a Java SDK with LWA token exchange and authentication.
To generate a Java client library
-
Install Java 8 or newer, Apache Maven 3.6. or greater, and GNU Wget and make them available in your $PATH.
-
Go to Models.
-
Clone the repository to make a local copy on your computer, if you haven't done so already.
-
Open a command prompt window and navigate to a directory where you want to download the Swagger Code Generator.
-
Download the latest version of the Swagger Code Generator.
For example:
wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.13/swagger-codegen-cli-2.4.13.jar -O swagger-codegen-cli.jar
swagger-codegen-cli.jar downloads to the current directory.
Note: You can also download from maven.org by directing your browser here: https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.13/swagger-codegen-cli-2.4.13.jar
-
Copy swagger-codegen-cli.jar into a directory structure that makes sense for you. For this example, we'll copy it to C:\SwaggerToCL.
-
Navigate to sellers.json in the selling-partner-api-models\models\sellers-api-model folder of your local copy of the repository.
-
Copy sellers.json into C:\SwaggerToCL.
-
Generate the client Library.
For example:
java -jar C:\SwaggerToCL\swagger-codegen-cli.jar generate -i C:\SwaggerToCL\Sellers.json -l java -o C:\SwaggerToCL\Sellers_JavaCL
The client library is copied to C:\SwaggerToCL\Sellers_JavaCL.
After you have generated your client library you can use it to help you make calls to the Selling Partner API. See Connecting to Selling Partner API.
Updated 11 months ago