ky

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
该 skill 基于 Ky v1.14.3,生成于 2026-02-04。
Ky is a tiny and elegant HTTP client based on the Fetch API. It provides a simpler and more powerful API than plain fetch with no dependencies, targeting modern browsers, Node.js 18+, Bun, and Deno.
该 skill 基于 Ky v1.14.3,生成于 2026-02-04。
Ky是一款基于Fetch API的轻量优雅HTTP客户端。它无需依赖,提供了比原生fetch更简洁且功能更强大的API,适用于现代浏览器、Node.js 18+、Bun和Deno。

Core References

核心参考

TopicDescriptionReference
Basic UsageHTTP method shortcuts, response body methods, TypeScript supportcore-usage
Core Optionsjson, searchParams, prefixUrl, timeout, methodcore-options
主题描述参考
基础用法HTTP方法快捷方式、响应体处理方法、TypeScript支持core-usage
核心选项json、searchParams、prefixUrl、timeout、methodcore-options

Features

功能特性

Retry Mechanism

重试机制

TopicDescriptionReference
Automatic RetryConfigurable retry strategies, delays, jitter, custom logicfeature-retry
主题描述参考
自动重试可配置的重试策略、延迟、抖动、自定义逻辑feature-retry

Hooks System

钩子系统

TopicDescriptionReference
Lifecycle HooksbeforeRequest, beforeRetry, afterResponse, beforeError hooksfeature-hooks
主题描述参考
生命周期钩子beforeRequest、beforeRetry、afterResponse、beforeError钩子feature-hooks

Instance Management

实例管理

TopicDescriptionReference
Custom Instancesky.create(), ky.extend(), context for hooksfeature-instances
主题描述参考
自定义实例ky.create()、ky.extend()、钩子上下文feature-instances

Error Handling

错误处理

TopicDescriptionReference
Error TypesHTTPError, TimeoutError, ForceRetryError, type guardsfeature-errors
主题描述参考
错误类型HTTPError、TimeoutError、ForceRetryError、类型守卫feature-errors

Advanced

进阶功能

TopicDescriptionReference
Progress TrackingUpload and download progress callbacksadvanced-progress
CustomizationCustom JSON parsing/stringifying, custom fetchadvanced-customization
主题描述参考
进度追踪上传和下载进度回调advanced-progress
自定义配置自定义JSON解析/序列化、自定义fetchadvanced-customization

Best Practices

最佳实践

TopicDescriptionReference
Form Datamultipart/form-data, URL-encoded forms, file uploadbest-practices-form-data
CancellationAbortController for request cancellationbest-practices-cancellation
Node.js FeaturesProxy support, HTTP/2, environment configurationbest-practices-nodejs
主题描述参考
表单数据multipart/form-data、URL编码表单、文件上传best-practices-form-data
请求取消使用AbortController取消请求best-practices-cancellation
Node.js特性代理支持、HTTP/2、环境配置best-practices-nodejs