Octri

Languages

Java

The Java SDK publishes to Maven Central.

Install

xml
<dependency>
  <groupId>com.your-org</groupId>
  <artifactId>api-client</artifactId>
  <version>1.0.0</version>
</dependency>

Options

OptionValuesDefault
Client styleclass-namespaced, class, namespaced, functionsclass-namespaced
Argument styleobject, positionalobject
Namespacetags, pathtags
Method namingshort, fullshort
Doc commentsfull, minimalfull
File headeromit, includeinclude
Usage examplefull, concisefull
No HTTP engine choice for Java

Kotlin offers okhttp or ktor; Java does not expose the choice.

Leave the client style alone for Java

class-namespaced is already the default, and it is the shape a Java caller expects. The functions override maps awkwardly onto a language with no free functions, so it is rarely what you want here.

Package name

Maven coordinates are groupId:artifactId, and the groupId must be a domain you control:

text
com.acme:api-client
Maven Central verifies the groupId

Central requires proof you own the domain behind the groupId, and releases are signed. That's more setup than npm, and it's worth starting before the day you want to ship.

Central releases are immutable

A published version can never be changed or removed. See Publishing.

What callers write

java
var config = new SdkConfig.ClientConfig();
config.baseUrl = "https://api.acme.com/v1";
var auth = new SdkConfig.ClientAuthConfig();
auth.bearerAuth = System.getenv("ACME_TOKEN");
config.auth = auth;

var acme = new Acme(config);

// Namespaces are final fields on the client, not accessor methods.
acme.users.listPaginated(
    ListUsersRequest.builder().limit(100).build(),
    user -> {
        System.out.println(user.getId());
        return true;
    });