<dependency>
<groupId>io.getstream</groupId>
<artifactId>stream-sdk-java</artifactId>
<version>7.1.0</version>
</dependency>Installation
Maven
Add the following dependency to your pom.xml:
Use the latest available SDK release when starting a new integration.
Check stream-sdk-java releases and replace the version if a newer one is available.
Gradle
Add the following to your build.gradle:
implementation 'io.getstream:stream-sdk-java:7.1.0'GitHub repository: https://github.com/GetStream/stream-sdk-java. Feel free to submit bug reports and feature requests.
The package is tested against these environments:
- Java 8+
- Java 11+
- Java 17+
- Java 21+
To create a client, you'll need your API key and secret. Both of them can be found in your Stream Dashboard.
You can optionally configure request timeouts and the HTTP connection pool. The default request timeout is 30 seconds.
import io.getstream.services.Feeds;
import io.getstream.services.framework.StreamSDKClient;
public class StreamExample {
public static void main(String[] args) {
String apiKey = "";
String secret = "";
// Create client with default settings (30s request timeout)
StreamSDKClient client = new StreamSDKClient(apiKey, secret);
// Get the feeds client
Feeds feeds = client.feeds();
// Your feeds operations here...
}
}Connection pool and timeouts
The SDK uses OkHttp with a connection pool and keep-alive enabled by default. Tune it with StreamClientOptions:
| Option | Default | Description |
|---|---|---|
setRequestTimeout | 30s | Per-request timeout. |
setMaxConnsPerHost | 5 | Maximum concurrent connections per host. |
setIdleTimeout | 55s | Idle connection lifetime. |
setConnectTimeout | 10s | TCP + TLS handshake timeout. |
import io.getstream.services.framework.StreamClientOptions;
import io.getstream.services.framework.StreamSDKClient;
import java.time.Duration;
StreamClientOptions options = new StreamClientOptions()
.setMaxConnsPerHost(10)
.setIdleTimeout(Duration.ofSeconds(55))
.setConnectTimeout(Duration.ofSeconds(10))
.setRequestTimeout(Duration.ofSeconds(30));
StreamSDKClient client = new StreamSDKClient(apiKey, secret, options);The request timeout and idle timeout can also be set with the STREAM_API_TIMEOUT (milliseconds) and STREAM_API_CONNECTION_MAX_AGE (seconds) environment variables.
To take full control of the HTTP stack, pass your own OkHttpClient via setHttpClient(...) (or the new StreamSDKClient(apiKey, secret, okHttpClient) constructor). When set, the pool options above are not applied.