ktor-expert

Design and implement multiplatform HTTP clients using Ktor.

Updated Jan 11, 2025
One-click install
npx skills add https://github.com/shaharKeisarApps/MoviesAndBeyond --skill ktor-expert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ktor-expert
Source: https://github.com/shaharKeisarApps/MoviesAndBeyond/tree/main/.claude/skills/ktor-expert
Command: npx skills add https://github.com/shaharKeisarApps/MoviesAndBeyond --skill ktor-expert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides expert guidance to architect and implement multiplatform HTTP clients using Ktor, simplifying setup, authentication, serialization, and error handling across common targets.

Core Features & Use Cases

  • Unified Client Setup: Create a reusable HttpClient with shared configuration across platforms (commonMain, androidMain, iosMain, jvmMain).
  • Authentication & Security: Implement bearer tokens, token refresh, and secure storage integration for API access.
  • Serialization & Interceptors: Configure content negotiation, logging, timeouts, and retry policies; customize via plugins.
  • WebSocket & File Transfers: Support WebSocket communication and multipart file upload/download patterns.
  • Testing & Mocking: Provide mock testing patterns for API services using MockEngine in tests.

Quick Start

Start by adding Ktor dependencies to your multiplatform module, create a shared HttpClient with content negotiation and timeouts, then wire up authentication and a basic API service. Extend with WebSocket, file upload/download, and testing blocks as needed.

Frequently Asked Questions about ktor-expert

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up a Ktor HTTP client for Kotlin Multiplatform?

To set up a Ktor HTTP client for Kotlin Multiplatform, add the Ktor dependencies to your module and create a shared HttpClient with common configuration like content negotiation and timeouts across commonMain, androidMain, iosMain, and jvmMain.

How do I implement bearer token authentication and refresh in Ktor?

Implement bearer token authentication in Ktor by configuring the authentication plugin, managing token storage securely, and wiring up token refresh logic to maintain API access across your multiplatform application.

What's the best way to handle network retries and error handling in Ktor?

The best way to handle network retries and errors in Ktor is by configuring interceptors with retry policies and robust error handling directly within the shared HttpClient setup.

Can I use Ktor for WebSocket communication and file transfers?

Yes, you can use Ktor for WebSocket communication and file transfers by implementing specific patterns for WebSocket support and multipart file upload/download within your multiplatform network layer.

How do I test API services with Ktor MockEngine?

Test API services with Ktor MockEngine by providing mock testing patterns that simulate network responses, allowing you to validate client behavior and interceptors without real network requests.

Does Ktor support shared serialization configuration across multiple platforms?

Ktor supports shared serialization configuration across multiple platforms by using content negotiation plugins to unify JSON or data parsing logic within the commonMain source set.