Ky HTTP Client

2.0.1 · active · verified Sat Apr 18

Ky is a tiny and elegant HTTP client based on the Fetch API, providing a simpler API with features like method shortcuts, automatic retries, JSON option, timeout support, upload/download progress, and instances with custom defaults. It treats non-2xx status codes as errors by default, unlike plain Fetch. The current stable version is 2.0.1, and the library is actively developed with regular updates.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates making a POST request with JSON payload to an example URL and logging the parsed JSON response.

import ky from 'ky';

const exampleJson = await ky.post('https://example.com', {
  json: { foo: true },
}).json();

console.log(exampleJson);
// => {data: '🦄'}

view raw JSON →