Skip to main content

Java OpenSDK Introduction

What is it?

Lovrabet Java OpenSDK is a lightweight Java client library for accessing the Lovrabet Cloud Rabbit Platform's OpenAPI services in Java applications.

With this SDK, you can easily:

  • 📊 Read Data - Retrieve business data from the Lovrabet Cloud Rabbit Platform
  • ✏️ Write Data - Create and update your business records
  • 🔐 Secure Access - Automatic signature authentication to ensure data security
  • 🚀 Quick Integration - Complete integration with just a few lines of code

What problems does it solve?

Scenario 1: Integrating Lovrabet Data into Existing Java Systems

Problem: You manage customer, order, and sales funnel data on the Lovrabet Cloud Rabbit Platform and need to use this data in your own Java backend system.

Using OpenSDK:

// In your Spring Boot application
@Service
public class CustomerService {
private final LovrabetSDKClient sdkClient;

public List<Customer> getSalesLeads() {
LovrabetRequest request = new LovrabetRequest();
request.setAppCode("app-xxx");
request.setModelCode("customer-dataset");

// Get sales leads data
LovrabetResult<?> result = sdkClient.getList(request);

if (result.isSuccess()) {
return parseCustomers(result.getData());
}
return Collections.emptyList();
}
}

Value:

  • ✅ No need to manually manage HTTP requests and signature logic
  • ✅ Type-safe API calls
  • ✅ Unified error handling
  • ✅ Out-of-the-box authentication mechanism

Scenario 2: Syncing Data from Java Applications to Lovrabet

Problem: Your Java system generates new business data (such as orders, work orders) that needs to be synced to the Lovrabet Cloud Rabbit Platform for visualization analysis and report generation.

Using OpenSDK:

// In your order service
@Service
public class OrderSyncService {
private final LovrabetSDKClient sdkClient;

public void syncOrder(Order order) {
LovrabetRequest request = new LovrabetRequest();
request.setAppCode("app-xxx");
request.setModelCode("orders-dataset");

// Build order data
Map<String, Object> orderData = new HashMap<>();
orderData.put("order_no", order.getOrderNo());
orderData.put("amount", order.getAmount());
orderData.put("customer_name", order.getCustomerName());
orderData.put("create_date", order.getCreateDate());
request.setParamMap(orderData);

// Create order record
LovrabetResult<String> result = sdkClient.create(request);

if (result.isSuccess()) {
logger.info("Order synced successfully: {}", result.getData());
} else {
logger.error("Order sync failed: {}", result.getResultMsg());
}
}
}

Value:

  • ✅ Real-time data synchronization
  • ✅ Reduce manual data import work
  • ✅ Unified data source supporting cross-system analysis

Scenario 3: Building a Data Platform in Microservices Architecture

Problem: In a microservices architecture, multiple services need to access unified data from Lovrabet, but you don't want each service to directly interface with the OpenAPI.

Using OpenSDK:

// Build a unified data service
@RestController
@RequestMapping("/api/data")
public class DataGatewayController {
private final LovrabetSDKClient sdkClient;

// Provide unified data access interface for internal microservices
@GetMapping("/customers")
public ResponseEntity<List<Map<String, Object>>> getCustomers(
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "20") int size
) {
LovrabetRequest request = new LovrabetRequest();
request.setAppCode("app-xxx");
request.setModelCode("customers");

Map<String, Object> params = new HashMap<>();
params.put("currentPage", page);
params.put("pageSize", size);
request.setParamMap(params);

LovrabetResult<?> result = sdkClient.getList(request);

if (result.isSuccess()) {
return ResponseEntity.ok((List<Map<String, Object>>) result.getData());
}
return ResponseEntity.status(500).build();
}
}

Value:

  • ✅ Unified data access layer
  • ✅ Centralized credential management
  • ✅ Reduced system coupling
  • ✅ Support for access control and auditing

Applicable Scenarios

ScenarioApplicableNotes
✅ Spring Boot Backend AppsRecommendedPerfect integration with Spring ecosystem
✅ Scheduled Tasks/Data SyncRecommendedBuild reliable data sync services with OpenSDK
✅ Microservices Data PlatformRecommendedBuild unified data access layer
✅ Traditional Java Web AppsApplicableWorks with Servlet, Struts, JSP, etc.
⚠️ Direct Frontend CallsNot RecommendedUse Node.js SDK or browser-side SDK for frontend
⚠️ Android AppsNot RecommendedPlease use dedicated mobile SDKs

Core Advantages

1. Simple and Easy to Use

// Complete data query in just 3 steps
LovrabetSDKClient client = new LovrabetSDKClient(accessKey, baseUrl);
LovrabetRequest request = new LovrabetRequest();
request.setAppCode("app-xxx");
LovrabetResult<?> result = client.getDatasetCodeList(request);

2. Secure and Reliable

  • Automatic Signing - SDK automatically handles HMAC-SHA256 signing without manual calculation
  • Key Protection - AccessKey is only used on the server side and not exposed to the frontend
  • HTTPS Transport - All requests transmitted over HTTPS encryption

3. Complete Error Handling

LovrabetResult<?> result = client.getOne(request);

if (result.isSuccess()) {
// Success: process business data
Object data = result.getData();
} else {
// Failure: get error code and message
String errorCode = result.getResultCode();
String errorMsg = result.getResultMsg();
logger.error("Query failed [{}]: {}", errorCode, errorMsg);
}

4. Production-Grade Quality

  • ✅ Thread-safe, supports high concurrency
  • ✅ Unified response format
  • ✅ Detailed error messages
  • ✅ Support for retry and timeout control

Quick Start

1. Add Dependency

<dependency>
<groupId>com.lovrabet.runtime</groupId>
<artifactId>lovrabet-runtime-opensdk</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

2. Get Access Credentials

  1. Log in to Lovrabet Cloud Rabbit Platform
  2. Go to Application Management to get the Application Code (AppCode)
  3. Enable OpenAPI functionality and generate an Access Key (AccessKey)

3. Write Your First Program

import com.lovrabet.runtime.opensdk.client.LovrabetSDKClient;
import com.lovrabet.runtime.opensdk.model.LovrabetRequest;
import com.lovrabet.runtime.opensdk.model.LovrabetResult;

public class HelloLovrabet {
public static void main(String[] args) {
// 1. Create client
String accessKey = "ak-your-access-key";
String baseUrl = "https://runtime.lovrabet.com/openapi";
LovrabetSDKClient client = new LovrabetSDKClient(accessKey, baseUrl);

// 2. Build request
LovrabetRequest request = new LovrabetRequest();
request.setAppCode("app-xxx");

// 3. Call API
LovrabetResult<?> result = client.getDatasetCodeList(request);

// 4. Process result
if (result.isSuccess()) {
System.out.println("Dataset list: " + result.getData());
} else {
System.err.println("Failed: " + result.getResultMsg());
}
}
}

4. Learning Path

Follow this order to progressively master SDK usage:

  1. 📖 Quick Start - Complete your first CRUD program in 5 minutes
  2. 📚 Core Concepts - Understand SDK working principles in depth
  3. 📋 API Reference - Consult complete interface documentation
  4. 💡 Examples - Learn implementations of 5 real-world scenarios
  5. 🚀 Best Practices - Master production environment optimization techniques
  6. FAQ - Resolve usage questions

Technical Support

If you encounter any issues, please get help through:


Documentation Version: 1.0.0 Last Updated: 2025-10-12 Applicable to: lovrabet-runtime-opensdk 1.0.0+