This is a set of simple samples written in Java, which provide a minimal example of Google Shopping integration within a command line application.
This starter project provides a great place to start your experimentation into the Merchant API.
- Java: Java 8+ is required.
- Maven: Used for dependency management and running the samples.
Navigate to the java/ directory and build/compile the project:
cd java/
mvn compileIf you have not already done so, please read the top-level README.md to
discover how to set up both authentication and the common sample configuration.
All commands should be run from the java/ directory.
Before calling any v1 Merchant API method, you must register the GCP project
used to call the APIs. You only need to do this once.
mvn exec:java -Dexec.mainClass="shopping.merchant.samples.accounts.developerregistration.v1.RegisterGcpSample"For more information, see Register as a developer.
To run a specific sample, use mvn exec:java and specify the main class. For
example, to list your products, run:
mvn exec:java -Dexec.mainClass="shopping.merchant.samples.products.v1.ListProductsSample"By default, alpha samples (such as reviews) are excluded from the build because they require alpha client libraries that are not installed by default.
To compile and run alpha samples:
- Install the alpha client library on your local machine by following the instructions in the alpha client repository.
- Build the project using the
allow-alphaprofile:
mvn compile -Pallow-alphaUse the same profile when executing alpha samples. For example:
mvn exec:java -Dexec.mainClass="shopping.merchant.samples.reviews.v1alpha.ListProductReviewsSample" -Pallow-alphaExamine your shell output, be inspired, and start working on an amazing new app!