This is the GitHub repository for the Nylas SDK for Kotlin and Java. This repo is primarily for anyone who wants to make contributions to the SDK or install it from source. For documentation on how to use this SDK to access the Nylas Email, Calendar, or Contacts APIs, see the official Java SDK Quickstart Guide.
The Nylas Communications Platform provides REST APIs for Email, Calendar, and Contacts, and the Nylas SDK is the quickest way to build your integration using Kotlin or Java.
Here are some resources to help you get started:
- Sign up for your free Nylas account
- Nylas API v3 Quickstart Guide
- Nylas SDK Reference
- Nylas API Reference
- Nylas Samples repo for code samples and example applications
If you have a question about the Nylas Communications Platform, contact Nylas Support for help.
Note: The Nylas SDK for Kotlin & Java requires JRE 8 or later.
If you're using Gradle, add the following to the dependencies section of build.gradle
:
implementation("com.nylas.sdk:nylas:2.5.0")
To build from source, clone this repo and build the project with Gradle.
git clone https://github.com/nylas/nylas-java.git && cd nylas-java
./gradlew build uberJar
This creates a new jar file in build/libs/nylas-java-sdk-2.5.0-uber.jar
.
See the Gradle documentation on Building Libraries or the Gradle User Manual for more information.
To use this SDK, you must first get a free Nylas account.
Then, follow the Quickstart guide to set up your first app and get your API keys.
For code examples that demonstrate how to use this SDK, take a look at our Java repos in the Nylas Samples collection.
You use the NylasClient
object to make requests to the Nylas API. The SDK is organized into different resources, each of which has methods to make requests to the API. Each resource is available through the NylasClient
object configured with your API key.
For example, to get a list of calendars, you can use the following code:
NylasClient nylas = new NylasClient.Builder("API_KEY").build();
ListResponse<Calendars> calendars = nylas.calendars().list("GRANT_ID");
Nylas maintains a reference guide for the Kotlin and Java SDK to help you get familiar with the available methods and classes.
See UPGRADE.md for instructions on upgrading from 1.x to 2.x.
Note: The Kotlin/Java SDK 2.x is not compatible with the Nylas API earlier than v3-beta.
The SDK uses SLF4J for logging. If you are using the SDK you can choose what logging framework to use with it for your app.
Common choices are log4j, logback, java.util.logging. If the application doesn't specify any logging framework, SLF4J emits one single warning and is then completely silent.
By default, the HTTP client is configured with the com.nylas.HttpLoggingInterceptor
which provides three DEBUG level loggers for HTTP requests.
com.nylas.http.Summary
logs one line for each request, containing the method, URI, and content size, and one line for each response containing the status code, message, content size and duration.com.nylas.http.Headers
logs the request and response HTTP headers (except Authorization value by default).com.nylas.http.Body
logs request and response bodies (first 10kB by default).
You can enable or disable these loggers using whatever logging framework you use.
For example, if you're using log4j2 and with an xml configuration file, include this line to enable all three:
<Logger name="com.nylas" level="DEBUG"/>
You can configure how you log HTTP Authorization header values and the body size limit using a
NylasClient.Builder
with a customized HttpLoggingInterceptor
We value and appreciate contributors' time! We welcome questions, bug reports, and pull requests.
See the Contributing for information about how to make contributions to this project.
This project is licensed under the terms of the MIT license. See the LICENSE for the full terms.