Skip to main content
Version: 0.4

Reading Online Features for Inference using the Java Client

Tecton provides an open-source client library in Java for reading features from the online store. See the Java Client Demo repo for sample usage of the Java Client.

The Java Client API Reference can be found here.

Authenticating with an API Key​

Generate an API key from your CLI by running the following command:

tecton api-key create --description "A sample key for the documentation"

Adding the Java Client dependency​

The latest version of the Tecton Java Client can be found on Maven.

For a Maven project, add the following dependency to the pom.xml:

<dependency>
<groupId>ai.tecton</groupId>
<artifactId>java-client</artifactId>
<version>0.1.0</version>
</dependency>

For a Gradle project, add the following to the build.gradle:

  repositories {
mavenCentral()
}
dependencies {
implementation 'ai.tecton:java-client:0.1.0'
}

Creating a TectonClient Object​

Create a TectonClient object with your Tecton instance base URL (https://<your Tecton instance prefix>.tecton.ai) and your API key:

TectonClient tectonClient = new TectonClient(url, apiKey);

Calling the get-features Endpoint​

To call the get-features endpoint using the client, create objects from the GetFeaturesRequestData and GetFeaturesRequest classes.

GetFeaturesRequestData getFeaturesRequestData =
new GetFeaturesRequestData()
.addJoinKey("user_id", "123")
.addJoinKey("merchant", "xyz")
.addRequestContext("amt", 500.00);

GetFeaturesRequest getFeaturesRequest = new GetFeaturesRequest("prod","fraud_detection_feature_service", getFeaturesRequestData);

Now, call the getFeatures() method in the tectonClient and pass the getFeaturesRequest object as a parameter.

This method:

  • Creates an HTTP request using the URL, apiKey and the getFeaturesRequest object
  • Calls the FeatureService API
  • Receives the response from the API and deserializes it into the getFeaturesResponse object
GetFeaturesResponse getFeaturesResponse = tectonClient.getFeatures(getFeaturesRequest);

The feature vector can be accessed as a list from the getFeaturesResponse using the getFeatureValues() method.

GetFeaturesResponse getFeaturesResponse = tectonClient.getFeatures(getFeaturesRequest);

Was this page helpful?

Happy React is loading...