/trakt-api

Modern powerful Trakt API to track your movies and TV shows.

Primary LanguageKotlinApache License 2.0Apache-2.0

Website | Support | Documentation

Trakt

Track and discover your TV shows and movies with Trakt.

Maven Central Github Actions Issues Kotlin Gradle GitHub License GitHub Account


Trakt Kotlin

Trakt Kotlin is a Kotlin Multiplatform library for tracking your series and movies.

  • Written in Kotlin native with ktor from the ground up.
  • Support for Android, iOS, desktop, and web applications.
  • High customizable HttpClient configuration

Sample projects:

Setup

The library is available on Maven Central.

Gradle

Add the Maven Central repository if it is not already there.

repositories {
    mavenCentral()
}

To use the library in a single-platform project, add a dependency.

dependencies {
    implementation("app.moviebase:trakt-api:0.6.0")
}

In Kotlin Multiplatform projects, add the dependency to your commonMain source-set dependencies.

commonMain {
    dependencies {
        implementation("app.moviebase:trakt-api:0.6.0")
    }
}

Usage

Most of the library follows the possibilities and naming at the official Trakt documentation.

Configuration

Build up your Trakt instance to access the APIs. You can configure the entire HttpClient of ktor.

val trakt = Trakt {
    traktApiKey = "clientId"

    expectSuccess = false // if you want to disable exceptions
    useCache = true
    useTimeout = true
    maxRetriesOnException = 3 // retries when network calls throw an exception

    // add your own client
    httpClient(OkHttp) {
        engine {

        }
    }

    httpClient {
        // for custom HttpClient configuration
    }
}

Get information

For getting basic information about a shows or other media content.

val trakt = Trakt("clientId")
val traktShow = trakt.shows.getSummary(traktSlug = "vikings")

Search

Search for TV shows by a query.

val trakt = Trakt("clientId")
val showPageResult = trakt.search.search(
    searchType = TraktSearchType.TMDB,
    id = "63639",
    mediaType = TraktMediaType.SHOW
)

Contributing 🤝

Please feel free to open an issue if you have any questions or suggestions. Or participate in the discussion. If you want to contribute, please read the contribution guidelines for more information.



This library uses the Trakt but is not endorsed or certified by Trakt.