Skip to content

GetStream/stream-chat-java

Repository files navigation

Official Java SDK for Stream Chat

Maven Central build

Official Java API client for Stream Chat, a service for building chat applications.
Explore the docs »

JavaDoc · Code Samples · Report Bug · Request Feature

📝 About Stream

You can sign up for a Stream account at our Get Started page.

You can use this library to access chat API endpoints server-side.

For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries (docs).

⚙️ Installation

The Stream chat Java SDK requires Java 11+. It supports latest LTS.

The Stream chat Java SDK is compatible with Groovy, Scala, Kotlin and Clojure.

Installation for Java

Gradle

dependencies {
    implementation "io.getstream:stream-chat-java:$stream_version"
}

Maven

<dependency>
  <groupId>io.getstream</groupId>
  <artifactId>stream-chat-java</artifactId>
  <version>$stream_version</version>
</dependency>

Installation for Groovy

Gradle

dependencies {
    implementation 'io.getstream:stream-chat-java:$stream_version'
}

You can see an example project at GetStream/stream-chat-groovy-example.

Installation for Scala

Gradle

dependencies {
    implementation 'io.getstream:stream-chat-java:$stream_version'
}

You can see an example project at GetStream/stream-chat-scala-example.

Installation for Kotlin

Gradle

dependencies {
    implementation("io.getstream:stream-chat-java:$stream_version")
}

You can see an example project at GetStream/stream-chat-kotlin-example.

Installation for Clojure

Leiningen

:dependencies [[io.getstream/stream-chat-java "$stream_version"]]

You can see an example project at GetStream/stream-chat-clojure-example.

🔀 Dependencies

This SDK uses lombok (code generation), retrofit (http client), jackson (json) and jjwt (jwt).

You can find the exact versions in build.gradle.

✨ Getting started

Configuration

To configure the SDK you need to provide required properties

Property ENV Default Required
io.getstream.chat.apiKey STREAM_KEY - Yes
io.getstream.chat.apiSecret STREAM_SECRET - Yes
io.getstream.chat.timeout STREAM_CHAT_TIMEOUT 10000 No
io.getstream.chat.url STREAM_CHAT_URL https://chat.stream-io-api.com No

You can also use your own CDN by creating an implementation of FileHandler and setting it this way

Message.fileHandlerClass = MyFileHandler.class

All setup must be done prior to any request to the API.

Print Chat app configuration

Java
System.out.println(App.get().request());
Groovy
println App.get().request()
Scala
println(App.get.request)
Kotlin
println(App.get().request())
Clojure
println (.request (App/get))

📚 Code examples

Head over to DOCS.md for code snippets.

🙋 FAQ

  1. If you get this exception: java.lang.ClassNotFoundException: io.jsonwebtoken.SignatureAlgorithm:

See issue #16 for a work around. We only provide runtime only dependency for JWT per recommendation. That's why it might be missing in your runtime and by addding implementation library into your deps, it should be gone.

✍️ Contributing

We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.

Head over to CONTRIBUTING.md for some development tips.

🧑‍💻 We are hiring!

We've recently closed a $38 million Series B funding round and we keep actively growing. Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.

Check out our current openings and apply via Stream's website.