Ktor 2.0.3 Help

Adding client dependencies

To use the Ktor HTTP client in your project, you need to configure repositories and add the following dependencies:

Configure the repositories

Before adding Ktor dependencies, you need to configure the repositories for this project:

  • Production

    Production releases of Ktor are available in the Maven central repository. You can declare this repository in your build script as follows:

    repositories { mavenCentral() }
    repositories { mavenCentral() }
  • Early Access Program (EAP)

    To get access to the EAP versions of Ktor, you need to reference the Space repository:

    repositories { maven { url = uri("https://maven.pkg.jetbrains.space/public/p/ktor/eap") } }
    repositories { maven { url "https://maven.pkg.jetbrains.space/public/p/ktor/eap" } }
    <repositories> <repository> <id>ktor-eap</id> <url>https://maven.pkg.jetbrains.space/public/p/ktor/eap</url> </repository> </repositories>

    Note that Ktor EAPs might require the Kotlin dev repository:

    repositories { maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") } }
    repositories { maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" } }
    <repositories> <repository> <id>ktor-eap</id> <url>https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev</url> </repository> </repositories>

Add dependencies

Client dependency

The main client functionality is available in the ktor-client-core artifact. Depending on your build system, you can add it in the following way:

implementation "io.ktor:ktor-client-core:$ktor_version"
<dependency> <groupId>io.ktor</groupId> <artifactId>ktor-client-core-jvm</artifactId> <version>${ktor_version}</version> </dependency>

For a multiplatform project, you need to add the ktor-client-core artifact to the commonMain source set:

val commonMain by getting { dependencies { implementation("io.ktor:ktor-client-core:$ktorVersion") } }

Engine dependency

An engine is responsible for processing network requests. There are different client engines available for various platforms, such as Apache, CIO, Android, iOS, and so on. For example, you can add a CIO engine dependency as follows:

implementation "io.ktor:ktor-client-cio:$ktor_version"
<dependency> <groupId>io.ktor</groupId> <artifactId>ktor-client-cio-jvm</artifactId> <version>${ktor_version}</version> </dependency>

For a multiplatform project, you need to add a dependency for the required engine to a corresponding source set. For example, the code snippet below shows how to add the ktor-client-okhttp dependency to the androidMain source set:

val androidMain by getting { dependencies { implementation("io.ktor:ktor-client-okhttp:$ktorVersion") } }

For a full list of dependencies required for a specific engine, see Add an engine dependency.

Plugin dependency

Ktor lets you use additional client functionality (plugins) that is not available by default, for example, logging, authorization, or serialization. Some of them are provided in separate artifacts. You can learn which dependencies you need from a topic for a required plugin.

Supported platforms

The Ktor HTTP client can be used on different platforms supported by Kotlin:

You can use it in multiplatform projects, be it a multiplatform mobile or a full-stack web application. The following targets are supported for multiplatform projects:

Target platform

Target preset


  • jvm


  • js


  • android


  • iosArm32

  • iosArm64

  • iosX64

  • iosSimulatorArm64


  • watchosArm32

  • watchosArm64

  • watchosX86

  • watchosX64

  • watchosSimulatorArm64


  • tvosArm64

  • tvosX64

  • tvosSimulatorArm64


  • macosX64

  • macosArm64


  • linuxX64


  • mingwX64

Last modified: 28 June 2022