ktorfit

star 1

Work with Ktorfit API clients - create endpoints, handle responses, debug network issues.

eygraber By eygraber schedule Updated 2/5/2026

name: ktorfit description: Work with Ktorfit API clients - create endpoints, handle responses, debug network issues. argument-hint: "[task] - e.g., 'create user endpoint', 'debug auth issue', 'explain response handling'" context: fork allowed-tools: Read, Edit, Write, Bash(./format, ./gradlew *, grep, cat, mkdir), Glob, Grep

Ktorfit Skill

Work with Ktorfit API clients - create endpoints, handle responses, debug network issues.

Common Tasks

/ktorfit create user endpoint          # Create new API endpoint
/ktorfit debug auth issue              # Debug authentication problems
/ktorfit explain response handling     # Understand response patterns
/ktorfit add retry logic               # Add retry to endpoint

API Interface Pattern

internal interface UserApi {
  @GET("users/{id}")
  suspend fun getUser(
    @Path("id") userId: String,
  ): JellyfinResponse<JsonObject>

  @POST("users")
  suspend fun createUser(
    @Body request: CreateUserRequest,
  ): JellyfinResponse<JsonObject>

  @GET("users")
  suspend fun getUsers(
    @Query("page") page: Int,
    @Query("limit") limit: Int = 20,
  ): JellyfinResponse<JsonArray>
}

Response Handling

// Convert to result
val result = api.getUser(userId).toResult()

// Map success
result.mapSuccessTo { json ->
  User(
    id = json["id"]!!.jsonPrimitive.content,
    name = json["name"]!!.jsonPrimitive.content,
  )
}

// Handle in repository
override suspend fun fetchUser(id: String): JellyfinResult<User> {
  return api.getUser(id)
    .toResult()
    .mapSuccessTo { json -> json.toUser() }
    .andThen { user ->
      localDataSource.saveUser(user)
    }
}

Key Patterns

Request Body (kotlinx.serialization)

@Serializable
data class CreateUserRequest(
  val name: String,
  val email: String,
)

Headers

@GET("users")
suspend fun getUsers(
  @Header("Authorization") token: String,
): JellyfinResponse<JsonArray>

Retry Logic

retryJellyfinResult(RetryPolicy.Default) {
  api.getUsers().toResult()
}

Module Location

API interfaces are in data/{feature}/impl/ and are internal.

Documentation

Install via CLI
npx skills add https://github.com/eygraber/jellyfin-kmp --skill ktorfit
Repository Details
star Stars 1
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator