REST Client

One input per line. Output is numbered to match the input order.
Pinned tools are listed in your favourites on the home page.Copies a link to this tool that carries your current input, so it opens ready to run.Gives you an iframe snippet for putting this tool on your own site.
Note: CORS applies — only CORS-enabled or same-origin APIs will work in the browser.

Collections are stored in this browser only and exported as files you download. Nothing you save here — URLs, headers, tokens or bodies — is ever sent to a server.

Any HTTP method, your own headers and body. Use this for ordinary JSON APIs.

Ctrl+Enter Run  · Ctrl+Shift+C Copy  · Esc Clear

Understand REST Client

从你的浏览器标签页发出真实的 HTTP 请求,并显示状态码、耗时、响应头和响应体。

How it works

请求通过浏览器自带的 fetch() API 发出,这意味着它继承了浏览器施加于页面发起请求的每一条规则。响应时间用调用前后的 performance.now() 测量,因此它包含连接建立和浏览器开销,而不是纯粹的服务端数字。当 Content-Type 表明是 JSON 时,响应体会被解析并美化输出,否则保留为原始文本。GET 和 HEAD 不带请求体,因为 fetch 规范禁止在这两者上携带请求体。

When to use it

  • 在开发过程中试探自己的 API,而不必安装桌面客户端
  • 在动手写代码对接之前,先看清某个公共端点究竟返回什么——状态、头和结构
  • 确认 bearer 令牌或 API 密钥是否被接受,并在不被接受时看到错误响应体
  • 并排比较预发布环境和生产环境同一端点的响应

Watch out for

  • CORS 会生效。除非服务器发送 Access-Control-Allow-Origin,否则浏览器不会让页面读取跨源响应,因此不少工作正常的 API 在这里会失败并报网络错误,而这并非服务器的问题——那类情况请改用 curl 或桌面客户端。
  • 你看不到全部响应头。除非服务器在 Access-Control-Expose-Headers 中列出更多,否则跨源时只有 CORS 安全清单中的那些(Content-Type、Cache-Control、Content-Length、Expires、Last-Modified、Pragma、Content-Language)可读。
  • 有些头根本无法从页面设置。Host、Origin、Referer、Connection 和 Cookie 属于被禁止的头名称——浏览器会自行设置它们,并悄悄丢弃你给的值。
  • 跳转会被透明地跟随,因此 301 会表现为最终的 200,中间那一跳是不可见的。当跳转本身正是你要排查的对象时,请使用不带 `-L` 的 `curl -i`。

Not the right tool for: 必须向另一个源携带 cookie 的请求,以及文件上传。这里默认不会跨源发送 cookie,而 multipart 请求体需要 curl 的 `-F` 或带文件选择器的桌面客户端。

Frequently Asked Questions

我的 API 请求为什么报 CORS 错误?

除非 API 返回 Access-Control-Allow-Origin 头,否则浏览器会阻止网页应用发起的跨源请求。如果这个 API 由你掌控,请加上 CORS 头。否则请改用 curl、Postman 或 CORS 代理测试。CORS 是浏览器的安全策略,不是服务器错误。

可以发送 multipart 表单数据吗?

目前 REST 客户端支持 JSON、文本和表单编码的请求体。对于 multipart(文件上传),请使用带 -F 参数的 curl,或使用原生支持文件选择器的 Postman。

如何在这个客户端中进行认证?

添加 Authorization 头:JWT/OAuth 用 "Bearer YOUR_TOKEN",HTTP Basic 认证用 "Basic BASE64(user:pass)",或使用 API 专有的头,例如 "X-Api-Key: YOUR_KEY"。该客户端不会在你的浏览器之外存储或传输凭据。

How to Use REST Client

  1. Paste or type your input in the input area above.
  2. The tool processes your input automatically or click Run.
  3. Copy or download the result using the action buttons.
  4. Use Ctrl+Enter to run quickly from the keyboard.