Mastering Networking with Ktor in Kotlin Multiplatform (KMP) and Compose Multiplatform Apps

Dive into the foundations of networking with Ktor in a Kotlin Multiplatform environment. Learn how to make HTTP requests, download and upload the data, and intercept the communication between a client and a server. We will build a simple application for both iOS and Android that will use a third-party API, Unsplash, to fetch the data and display it to our users. First, you’ll explore what is Kotlin Multiplatform (KMP) and how sharing code actually works between multiple platforms. Next, we’ll explore different features of the Ktor networking library, default headers, plugins, query parameters, response wrappers, authentication tokens, HTTP interception, file uploading, parsing JSON data, and more. Finally, in the end, we will build a simple app for both iOS and Android, that will display the data from a third-party API called Unsplash. The UI of both apps will be shared using Compose Multiplatform technology. Knowledge about Swift is not required! 

Course Objectives

In this master codelab, you’ll explore:

  • Emphasizes the benefits of sharing business logic and UI between Android and iOS in KMP 
  • Understanding Ktor Networking Framework 
  • Create your first Kotlin Multiplatform (KMP) and Compose Multiplatform projects  
  • Working with HTTP Requests and Query Parameters 
  • Adding headers, interceptors, and logging for requests 
  • Working with Authentication tokens 
  • The advantages of using a Resource plugin 
  • Advanced Request Handling: file uploads, parallel requests, and cancellation of requests 
  • Customizing HTTP responses: success and failure 
  • Testing API Endpoints using Mocks and Postman 
  • Building an image app using the Unsplash API for both iOS and Android

Meet the instructor

Stefan Jovanović

Content Author & Course Instructor

More courses by the instructor