Skip to content
Skip to main content

Using the Kotlin/Java SDK

As of August 2023, Nylas offers a Kotlin/Java SDK as part of Nylas v3, in addition to the legacy Java-only v2.7 SDK.

Before you can start using the Nylas Kotlin/Java SDK, make sure you have done the following:

For the following examples, replace X.X.X with the version you want to use. See the list of Kotlin/Java SDK releases to learn about the available versions.

If you’re using Gradle, add the following code to the dependencies section of your build.gradle file. Be sure to use only the code that matches the SDK version you want to use.

For projects using Maven, add the following code to your POM file.

<dependency>
<groupId>com.nylas.sdk</groupId>
<artifactId>nylas</artifactId>
<version>X.X.X</version>
</dependency>

To start using the Kotlin/Java SDK, you must initialize the NylasClient object. The Nylas client allows you to access the Manage Grants endpoints.

To create a Nylas application client object, initialize a NylasClient object and pass in your Nylas application’s API key and API URI.

Now that you have the Kotlin/Java SDK installed and set up, you can make a simple program to test your installation. For example, the following code makes a request to return information about your Nylas application.

The Nylas APIs use OAuth 2.0 and let you choose to authenticate using either an API key or access token. For more information about authenticating with Nylas, see the Authentication guide.

In practice, Nylas’ REST API simplifies the OAuth process to two steps: redirecting the user to Nylas, and handling the auth response.

The following code samples redirect a user to Nylas for authentication.

Next, your application has to handle the authentication response from Nylas, as in the examples below.

For the latest supported version of the SDK, see the Releases page on GitHub.

The Nylas Kotlin/Java SDK includes method and model documentation, so you can easily find the implementation details you need.

The Nylas Kotlin/Java SDK repository houses the Kotlin/Java SDK and a number of useful tutorials that demonstrate how to handle things like webhooks, Bring Your Own Authentication, and Hosted OAuth. You can contribute to the SDK by creating an issue or opening a pull request.

For code samples, visit the Nylas Samples repository.