Skip to main content

Java SDK

The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers support for entity management, search, lineage, and authentication with a JWT token.

Installation

Maven

Add the OpenMetadata Java SDK dependency to your pom.xml:

Gradle

Add the dependency to your build.gradle:

Quick Start

Basic Connection

For more information about getting a token, see Authentication.

Core Functionality

Working with Entities

Every entity type has a service on the client, such as client.databaseServices(), client.tables(), and client.users(). These services offer methods such as create, get, getByName, list, update, delete, and restore.

Database Services

Tables

Entity Operations

CRUD Operations

Search and Filtering

Advanced Features

Authentication

The Java SDK authenticates with a JWT access token. When your token changes, create a new client with the new token:

Error Handling

Async Operations

The service methods are blocking. To run them in parallel, wrap them in a CompletableFuture:

Configuration Options

Client Configuration

Common Use Cases

Metadata Discovery

Bulk Operations

Lineage Operations

For more information about the fluent API for lineage, see Java SDK for Lineage.

Use the Client in Your Application

Create one OpenMetadataClient and share it across your application. If you use a framework such as Spring Boot, register the client as a singleton bean.

Best Practices

  • Reuse the client: Create one client and share it instead of creating a new one per request.
  • Handle errors: Catch OpenMetadataException and check the status code.
  • Protect authentication: Keep your JWT token in a secret store, not in source code.
  • Use async operations: Wrap calls in CompletableFuture for better performance in concurrent scenarios.
  • Handle pagination: Always handle pagination for large datasets.
  • Cache entities: Implement caching for frequently accessed entities.

Performance Tips

  • Create one client and reuse it.
  • Cache frequently accessed metadata.
  • Run independent calls in parallel with CompletableFuture.
  • Specify only required fields when fetching entities.
  • Use filters to narrow lists before you read them.