Installation
Add the keyport-java dependency to your project:
<dependency>
<groupId>sbs.keyport</groupId>
<artifactId>keyport-java</artifactId>
<version>1.0.1</version>
</dependency>
Setup and usage
Initialize the client
Create a KeyPort instance with your API key, or load it from a config file:KeyPort client = new KeyPort("kp_live_xxx");
Validate a license key
Call client.validate with the license key you want to check:ValidateResponse response = client.validate("ABCD-EFGH-IJKL-MNOP", null, null);
This sends a POST /api/v1/validate request and returns a ValidateResponse. Retrieve license details
Call client.getLicense with the license key to fetch full license details:LicenseDetailResponse detail = client.getLicense("ABCD-EFGH-IJKL-MNOP");
This sends a GET /api/v1/license/:key request and returns a LicenseDetailResponse.
Full examples
KeyPort client = new KeyPort("kp_live_xxx");
// Validate a license key
ValidateResponse response = client.validate("ABCD-EFGH-IJKL-MNOP", null, null);
// Retrieve full license details
LicenseDetailResponse detail = client.getLicense("ABCD-EFGH-IJKL-MNOP");
Store your API key in an environment variable or a keyport.json config file rather than hard-coding it in your source code.