# Ky

> Tiny & elegant JavaScript HTTP client based on the Fetch API

Source: https://talira.ai/catalog/ky-7jhb33p5
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [libraries / http clients](https://talira.ai/categories/libraries/http-clients), [languages / javascript](https://talira.ai/categories/languages/javascript)
- Licence: MIT[^2]
- Pricing: Free and open source[^2]
- Free tier: yes[^2]
- Self-hostable: yes[^1]
- API: yes[^1]
- Creator: Sindre Sorhus

Ky is a small HTTP client for JavaScript and [TypeScript](https://talira.ai/catalog/typescript-w0asrgz8.md) that wraps the standard Fetch API, so the same code runs in browsers, Node.js, [Bun](https://talira.ai/catalog/bun-z64kv5wg.md) and Deno, with no dependencies. On top of `fetch` it adds method shortcuts, errors for non-2xx responses, retries with backoff, per-attempt and total timeouts, upload and download progress, a base URL, instances with shared defaults, and hooks before and after each request. Responses can be validated against a Standard Schema validator such as [Zod](https://talira.ai/catalog/zod-ptz19tg1.md), and `.json()` is typed `unknown` by default rather than `any`. Sindre Sorhus, Seth Holladay and Szymon Marczak maintain it, and the README of [Got](https://talira.ai/catalog/got-0csab4w7.md), their Node.js-only client, recommends Ky instead. Its FAQ contrasts it with [axios](https://talira.ai/catalog/axios-0sg488rd.md), which predates `fetch`.

## Links

- GitHub: https://github.com/sindresorhus/ky

## Problems it solves

- plain fetch doesn't throw on 404 or 500 responses and I keep forgetting to check response.ok
- retry failed API calls automatically with backoff from browser and Node.js code
- put a timeout on fetch calls without wiring up AbortController by hand every time
- I want a tiny HTTP client with zero dependencies that works in the browser, Node.js, Bun and Deno
- create a preconfigured API client with a base URL, default headers and an auth token on every request
- refresh an expired access token and replay the request when the API answers 401
- validate the JSON an API returns against a Zod schema and get a typed result
- show a progress bar while uploading or downloading a file with fetch
- stop a huge or malicious response body from being read into memory: set a maximum response size
- give a whole request, retries included, one overall deadline

## Features

- built on the Fetch API, no dependencies
- method shortcuts (ky.get, ky.post, ky.put, ky.patch, ky.delete, ky.head, ky.query)
- HTTPError for non-2xx responses, configurable per status
- retries with backoff, Retry-After support and custom retry rules
- per-attempt timeout and an overall totalTimeout
- maximum response size
- upload and download progress callbacks
- baseUrl and prefix options, searchParams
- instances with shared defaults (ky.create, ky.extend)
- hooks: init, beforeRequest, beforeRetry, beforeError, afterResponse
- response validation with Standard Schema (Zod, Valibot)
- TypeScript types, .json() typed unknown by default
- undici dispatcher pass-through for proxies and HTTP/2 in Node.js

## Limitations

- Doesn't run on Node.js versions before 22: it needs Node.js 22 or later and the latest Chrome, Firefox or Safari[^1]

## Capabilities

- Has an API: plan not known

## Trust

Overall: 0.28 out of 1.
Signals: backing 0.20, extensibility 0.20.

- created by Sindre Sorhus

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [Got](https://talira.ai/catalog/got-0csab4w7.md): Human-friendly and powerful HTTP request library for Node.js
- [undici](https://talira.ai/catalog/undici-kmdjat1w.md): An HTTP/1.1 client, written from scratch for Node.js
- [ofetch](https://talira.ai/catalog/ofetch-brxwg7d2.md): A better fetch API. Works on node, browser, and workers.
- [axios](https://talira.ai/catalog/axios-0sg488rd.md): Promise based HTTP client for the browser and node.js
- [SuperAgent](https://talira.ai/catalog/superagent-b9qa7pyb.md): Ajax for Node.js and browsers (JS HTTP client)
- [node-fetch](https://talira.ai/catalog/node-fetch-f6wxdep8.md): A light-weight module that brings the Fetch API to Node.js

## Sources

[^1]: https://github.com/sindresorhus/ky (checked 20 Nov 2026)
[^2]: https://github.com/sindresorhus/ky/blob/main/license (checked 20 Nov 2026)
