返回博客
Tutorial 2026-04-05

用 cURL 测试 API:从基础到高级技巧

通过认证、文件上传、调试的实际示例掌握 cURL。

cURL 是 API 测试的瑞士军刀。

基本命令

curl -s https://api.example.com/users | jq '.'

curl -X POST https://api.example.com/users \

-H "Content-Type: application/json" \

-d '{"name": "Alice"}'

高级技巧

curl -w "Total: %{time_total}s\n" -o /dev/null -s https://api.example.com/users

将在线工具与 cURL 结合使用。