Skip to content

The WooCommerce REST API Client for Java provides easy access to the features of the e-commerce platform's API.

Notifications You must be signed in to change notification settings

wtx-labs/woocommerce-api-client-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

The WooCommerce REST API Client for Java

The WooCommerce REST API client library for Java provides easy access to the features of the e-commerce platform's API. The client supports the WooCommerce REST API in the latest v3 version.


⚠️ Note: This is a development version!

The API client is under development and will be gradually expanded to cover the key API functionalities of the commerce engine.


Setup

  1. Download this project and build it to create a new artifact in the local Maven repository using the following command:
mvn clean install
  1. After a successful build, you can use the newly created woocommerce-api-client artifact as a dependency in your Java project.:
<dependency>
    <groupId>wtx.woocommerce</groupId>
    <artifactId>woocommerce-api-client</artifactId>
    <version>0.1.0</version>
</dependency>

Usage

Below is an example usage of the WooCommerceApiClient:

package wtx.woocommerce;

import java.util.List;

import wtx.woocommerce.api.client.CustomersApi;
import wtx.woocommerce.api.client.invoker.ApiException;
import wtx.woocommerce.api.client.model.Customer;

public class WooCommerceApiClientUsageDemo {

    public static void main(String[] args) {

        System.out.println(">>> Start running the WooCommerceApiClientUsageDemo...");

        // Use WooCommerceApiClient(true) if you need to log API communication messages.
        WooCommerceApiClient apiClient = new WooCommerceApiClient();

        // TODO: Set your host and credentials!
        apiClient.setBasePath("https://your-woocommerce-shop.com/wp-json/wc/v3");
        apiClient.setUsername("TODO_SET_API_USERNAME");
        apiClient.setPassword("TODO_SET_API_PASSWORD");

        CustomersApi customersApi = new CustomersApi(apiClient);

        try {

            List<Customer> customers = customersApi.listAllCustomers(null, null, null, null, null, null, null, null, null, null, null);

            // Example list of customer emails:
            for (Customer customer : customers) {
                System.out.println("Customer: " + customer.getEmail());
            }

        } catch (ApiException e) {
            System.err.println("Error occurred during API call: " + e);
        }

        System.out.println("<<< The WooCommerceApiClientUsageDemo has been finished.");

    }

}

Stay Connected!

The WooCommerce API client library is evolving with exciting new features and improvements on the way.
We can't wait to share more with you - stay tuned! 😊

Releases

No releases published

Packages

No packages published

Languages