The com.canarygate:sdk Maven artifact is the official client for integrating CanaryGate into Java applications.
Compatibility
| Environment | Support |
|---|---|
| Java 17+ | Yes |
The SDK fetches flags via a snapshot request (/sdk/flags) and optionally keeps them in sync with the server through SSE streaming when stream is enabled.
Installation
<dependency>
<groupId>com.canarygate</groupId>
<artifactId>sdk</artifactId>
<version>0.1.0</version>
</dependency>Full API
| Method | Description |
|---|---|
CanaryGateClient(apiKey, Options) | Creates the client |
init() | Loads flags via snapshot; starts SSE when stream is enabled |
getFlag(key, context) | Returns FlagData or null |
getFlags(context) | Returns List<FlagData> (all flags) |
isStale() | true if the connection is degraded |
getLastSyncAt() | ISO String of the last sync or null |
disconnect() | Closes the stream connection (if any) and releases resources |
The client also implements AutoCloseable, so it can be used in a try-with-resources block.
Next steps
Last updated on