ApikeeApikeeDocs
SDKs

Java SDK

Integrate Apikee with Spring Boot using the Java SDK. Configure API key authentication, scoped access, servlet filters, and SpringDoc.

Maven Central

<dependency>
  <groupId>dev.apikee</groupId>
  <artifactId>apikee-spring</artifactId>
  <version>0.1.0</version>
</dependency>
implementation("dev.apikee:apikee-spring:0.1.0")

Configure

The servlet filter and the SpringDoc security customizer auto-configure as soon as the dependency is on the classpath.

apikee:
  secrets:
    - ${APIKEE_SECRET}          # required; a list, so you can rotate
  header-name: x-api-key        # default

  # Server mode (optional)
  server-key: ${APIKEE_SERVER_KEY}
  project-env: payments-api-production
  fail-open: true

Reading claims

@RestController
public class UserController {

    @GetMapping("/v1/users")
    public Map<String, Object> listUsers(HttpServletRequest request) {
        ApikeeClaims claims = (ApikeeClaims) request.getAttribute("apikee.claims");
        return Map.of(
            "tenant",  claims.tenant(),
            "scopes",  claims.scopes(),
            "expires", claims.expiresAt()
        );
    }
}

Requiring a scope

ApikeeClaims claims = (ApikeeClaims) request.getAttribute("apikee.claims");
if (!claims.scopes().contains("admin")) {
    throw new AccessDeniedException("admin scope required");
}

Issuing keys

ApikeeKeyEngine engine = new ApikeeKeyEngine(List.of(System.getenv("APIKEE_SECRET")));

String key = engine.create(KeyOptions.builder()
    .tenant("acme")
    .scopes(List.of("read:users"))
    .expiresIn(Duration.ofDays(90))
    .build());
// apikee_… — returned once

Describing endpoints

server.ensureEndpointAsync("GET", "/v1/users", EndpointMetadata.builder()
    .description("List users in the caller's tenant.")
    .scopes(List.of("read:users"))
    .tags(List.of("users"))
    .build());

Best-effort and asynchronous — a registration failure never affects a live request. See Endpoints.

Server client

ApikeeServer server = new ApikeeServer(ServerConfig.builder()
    .serverKey(System.getenv("APIKEE_SERVER_KEY"))
    .projectEnv("payments-api-production")
    .build());

server.createClientWithKey(CreateClientRequest.builder()
    .name("Acme mobile app")
    .clientType("company")
    .build());

Swagger

With SpringDoc on the classpath, every operation gets the Apikee security scheme automatically — no annotation needed per route.

On this page