Skip to main content
The Ky client wraps the popular Ky library, providing a lightweight alternative to Axios with automatic retry, timeout, and hooks built on the native Fetch API.

Installation

Ky is a peer dependency and must be installed separately.

Basic Usage

1

Create a client instance

2

Make API calls

Configuration

The Ky client extends Ky configuration with OpenAPI TypeScript features:

Client Options

Custom Ky Instance

Use an existing Ky instance:

HTTP Methods

Retry Configuration

Ky has built-in retry support:

Default Retry

Custom Retry Logic

Per-Request Retry

Timeout Configuration

Global Timeout

Per-Request Timeout

Disable Timeout

Response Styles

Fields Style (Default)

Data Style

Authentication

Bearer Token

API Key

Interceptors

Add request, response, and error interceptors:

Request Interceptor

Response Interceptor

Error Interceptor

Server-Sent Events

Stream real-time data:

Request Cancellation

Response Parsing

Auto (Default)

Specific Format

Advanced Features

Preflight Requests

Response Hooks

Error Hooks

TypeScript Types

Comparison with Fetch Client

Next Steps

Fetch Client

Zero-dependency alternative

ofetch Client

Universal fetch wrapper

Retry Configuration

Configure automatic retries

Authentication

Set up API authentication