HTTP & APIs in Compose Desktop: Ktor Client & JSON Serialization | Kotlin Desktop #8
20views
2likes
012:57
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Build a Weather App with Compose Desktop! Learn Ktor Client with CIO engine, kotlinx.serialization for JSON parsing, suspend functions, loading
states, and error handling — all in about 140 lines of Kotlin using the free Open-Meteo API (no API key needed).
What You'll Learn:
- Ktor Client with CIO engine for HTTP requests
- ContentNegotiation plugin with JSON serialization
- @Serializable data classes for API response mapping
- @SerialName for mapping JSON field names to Kotlin properties
- Suspend functions for asynchronous network calls
- rememberCoroutineScope and scope.launch for UI coroutines
- LaunchedEffect for initial data fetch on composition
- Loading states with CircularProgressIndicator
- Error handling with try-catch and user-friendly messages
- when block for conditional UI rendering
Timestamps:
0:00 - Introduction
0:15 - Preview: What We're Building
0:45 - Project Setup (Gradle, Ktor Dependencies)
2:36 - Weather Models (@Serializable Data Classes)
3:31 - Weather API (HttpClient, Fetch Function)
4:58 - App Content (State, Coroutines, UI)
8:14 - Main & Compile
9:56 - App Demo (Live Weather Data)
10:56 - Recap & Key Takeaways
11:56 - Thanks for Watching
Key Takeaways:
1. HttpClient — Configure Ktor with CIO engine and JSON content negotiation
2. Suspend Functions — Network calls are suspend funs called from coroutine scopes
3. Data Classes — @Serializable and @SerialName for automatic JSON parsing
4. Loading States — when block handles loading, error, and success
5. Error Handling — try-catch with user-friendly error messages
Previous Lesson:
Lesson 07: Dialogs & Menus
https://youtube.com/...
Next Lesson:
Lesson 09: Database & Storage (coming soon)
Tech Stack:
Kotlin 2.1, Compose Multiplatform 1.7.3, Material3
Ktor Client 3.0.3, kotlinx-serialization 1.7.3
Gradle 8.10, JVM 17+
API: Open-Meteo (free, no API key required)
https://open-meteo.com
Source Code: https://github.com/GoCelesteAI/kotlin_desktop_http_apis
Taught by CelesteAI
If you found this helpful, please like and subscribe for more Kotlin Desktop tutorials!
#kotlin #compose #desktop #material3 #ktor #http #api #json #serialization #weather #tutorial #programming
Back to tutorialsOpen in YouTube
Duration
12:57
Published
February 20, 2026
Added to Codegiz
March 15, 2026