- Updated: March 21, 2026
- 6 min read
Getting Started with the OpenClaw Rating API Java/Kotlin SDK
The OpenClaw Rating API Java/Kotlin SDK can be installed, coded, and deployed on UBOS in under 30 minutes, giving developers a ready‑to‑use rating service with full type‑safe client libraries for both Java and Kotlin.
1. Introduction
OpenClaw is a lightweight, open‑source rating engine that exposes a RESTful API for creating, updating, and retrieving product or content ratings. UBOS, the Enterprise AI platform by UBOS, provides a one‑click hosting environment for OpenClaw, allowing you to focus on code rather than infrastructure.
This tutorial walks software developers through the entire lifecycle:
- Prerequisites you need before you start.
- Step‑by‑step setup of the Java and Kotlin SDKs.
- Fully functional code samples.
- Integration guide, deployment on UBOS, and testing tips.
2. Prerequisites
Before you dive into the SDK, make sure you have the following tools installed on your workstation:
| Tool | Minimum Version |
|---|---|
| Java Development Kit (JDK) | 17 (LTS) or newer |
| Kotlin Compiler | 1.8.0+ |
| Maven or Gradle | 3.8+ (Maven) / 7.0+ (Gradle) |
| Git | 2.30+ |
| Docker (optional for local testing) | 20.10+ |
Additionally, you need a UBOS account. If you haven’t signed up yet, head over to the OpenClaw hosting page on UBOS and create a free trial.
3. Setting up the OpenClaw Rating API SDK
Java setup
UBOS publishes the Java client as a Maven artifact. Add the following dependency to your pom.xml:
<dependency>
<groupId>tech.ubos.openclaw</groupId>
<artifactId>openclaw-java-sdk</artifactId>
<version>1.2.0</version>
</dependency>
If you prefer Gradle, insert this line into your build.gradle.kts:
implementation("tech.ubos.openclaw:openclaw-java-sdk:1.2.0")
Kotlin setup
The Kotlin SDK is a thin wrapper around the Java client, exposing coroutine‑friendly APIs. Add the Kotlin artifact:
<dependency>
<groupId>tech.ubos.openclaw</groupId>
<artifactId>openclaw-kotlin-sdk</artifactId>
<version>1.2.0</version>
</dependency>
Or with Gradle Kotlin DSL:
implementation("tech.ubos.openclaw:openclaw-kotlin-sdk:1.2.0")
4. Code Samples
Java example
The following Java snippet demonstrates how to create a new rating, fetch it, and update the score.
import tech.ubos.openclaw.client.OpenClawClient;
import tech.ubos.openclaw.model.Rating;
import java.util.UUID;
public class RatingDemo {
public static void main(String[] args) {
// Initialise the client – replace with your actual endpoint and API key
OpenClawClient client = OpenClawClient.builder()
.baseUrl("https://api.your-openclaw-instance.com")
.apiKey("YOUR_API_KEY")
.build();
// 1️⃣ Create a rating
Rating newRating = Rating.builder()
.entityId(UUID.randomUUID().toString())
.score(4.5)
.comment("Excellent product!")
.build();
Rating created = client.ratings().create(newRating);
System.out.println("Created rating ID: " + created.getId());
// 2️⃣ Retrieve the rating
Rating fetched = client.ratings().get(created.getId());
System.out.println("Fetched rating score: " + fetched.getScore());
// 3️⃣ Update the rating score
fetched.setScore(4.8);
Rating updated = client.ratings().update(fetched);
System.out.println("Updated rating score: " + updated.getScore());
}
}
Kotlin example
Using Kotlin coroutines makes the same flow even more concise.
import tech.ubos.openclaw.kotlin.client.OpenClawClient
import tech.ubos.openclaw.model.Rating
import kotlinx.coroutines.runBlocking
import java.util.UUID
fun main() = runBlocking {
// Initialise the client – replace with your actual endpoint and API key
val client = OpenClawClient.builder()
.baseUrl("https://api.your-openclaw-instance.com")
.apiKey("YOUR_API_KEY")
.build()
// 1️⃣ Create a rating
val newRating = Rating.builder()
.entityId(UUID.randomUUID().toString())
.score(4.5)
.comment("Great experience!")
.build()
val created = client.ratings.create(newRating)
println("Created rating ID: ${created.id}")
// 2️⃣ Retrieve the rating
val fetched = client.ratings.get(created.id)
println("Fetched rating score: ${fetched.score}")
// 3️⃣ Update the rating score
val updated = client.ratings.update(fetched.copy(score = 4.9))
println("Updated rating score: ${updated.score}")
}
5. Step‑by‑step Integration Guide
- Clone the starter repository. UBOS maintains a minimal GitHub starter kit that already contains the SDK dependencies.
- Configure environment variables. Create a
.envfile at the project root:OPENCLAW_BASE_URL=https://api.your-openclaw-instance.com OPENCLAW_API_KEY=your-secret-key - Run the build. With Maven:
mvn clean installOr with Gradle:
./gradlew build - Implement the business logic. Use the code samples above as a template. Insert the rating calls wherever your application needs user feedback (e.g., after a purchase or content view).
- Handle errors gracefully. The SDK throws
OpenClawExceptionfor HTTP errors. Wrap calls in try‑catch blocks and map status codes to user‑friendly messages. - Write unit tests. UBOS recommends JUnit 5 for Java and Kotest for Kotlin. Mock the
OpenClawClientwithMockitoorMockKto verify request payloads.
6. Deployment Guidance on UBOS
UBOS abstracts away server provisioning, SSL termination, and CI/CD pipelines. Follow these steps to push your rating service to production:
- Connect your Git repository. In the UBOS dashboard, click New App → Connect Repository and select the branch containing your compiled JAR or Docker image.
- Configure environment variables. Replicate the
.envvalues in the UBOS Settings → Environment section. - Select a runtime. Choose Java 17 (OpenJDK) for Java projects or Kotlin (JVM) for Kotlin projects. UBOS automatically detects the
mainClassfrom yourpom.xmlorbuild.gradle.kts. - Enable auto‑scaling. Set the desired CPU and memory limits; UBOS will spin up additional containers under load.
- Deploy. Hit the Deploy button. UBOS builds the artifact, runs tests (if you enabled the CI step), and publishes a live endpoint like
https://myapp.ubos.tech.
After deployment, you can monitor request latency, error rates, and rating volume directly from the UBOS Observability tab.
7. Testing the Integration
Robust testing ensures that your rating workflow behaves correctly in production. UBOS provides two testing layers:
Unit & Integration Tests
Write JUnit 5 tests that mock the HTTP client. Example for Java:
@Test
void shouldCreateRating() {
OpenClawClient mockClient = mock(OpenClawClient.class);
Rating payload = Rating.builder().entityId("123").score(5).build();
when(mockClient.ratings().create(any())).thenReturn(payload);
RatingService service = new RatingService(mockClient);
Rating result = service.createRating("123", 5);
assertEquals(5, result.getScore());
verify(mockClient.ratings()).create(any());
}
End‑to‑End (E2E) Tests
Deploy a temporary staging instance on UBOS and run a Postman collection or a Cypress script that exercises the full HTTP flow (POST /ratings, GET /ratings/{id}, PATCH /ratings/{id}).
Load Testing
Use k6 or Locust to simulate 1,000 concurrent rating submissions. Verify that UBOS auto‑scaling keeps latency under 200 ms.
8. Conclusion
The OpenClaw Rating API Java/Kotlin SDK, combined with UBOS’s one‑click deployment, gives developers a production‑ready rating service without the usual ops overhead. By following the steps above you can:
- Integrate rating functionality in both Java and Kotlin projects.
- Leverage UBOS’s CI/CD, auto‑scaling, and observability out of the box.
- Maintain high code quality through unit, integration, and load testing.
Start building smarter feedback loops today—your users will thank you, and your analytics will become richer.
For a deeper dive into hosting OpenClaw on the UBOS platform, visit the OpenClaw hosting page on UBOS.