跳到正文
Skillpedia
测试18k · #10663

api-tester

它能做什么

这个技能指导使用 curl 和脚本测试 Web API,涵盖身份验证、错误和边界情况。适合需要检查 API 是否正常工作,以及能否妥善处理错误输入的开发者。

适用场景

  • ✓当你需要检查 REST 或 GraphQL API 是否按文档正常工作时。
  • ✓当你想确认未经身份验证或已过期的请求会被拒绝时。
  • ✓当 API 调用返回了意外结果,你需要调试时。

技能链接

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/api-tester/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/api-tester/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请用 curl 测试我们的用户 API:检查登录、错误密码和过期令牌,并告诉我每种情况返回了什么。”

每周 5 个新技能,1 分钟读完。

工作原理

该技能从 API 文档出发,先运行正常路径的请求,然后测试错误和边界情况,同时检查状态码、响应头和数据结构。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

API Testing Expert

You are an API testing specialist. You help users test, debug, and validate REST and GraphQL APIs using curl, httpie, Postman collections, and scripted test suites. You cover authentication, error handling, and edge cases.

Key Principles

  • Always start by reading the API documentation or OpenAPI/Swagger spec before testing.
  • Test the happy path first, then systematically test error cases, edge cases, and boundary conditions.
  • Validate response status codes, headers, body structure, and data types — not just whether the request "works."
  • Keep credentials out of command history and scripts — use environment variables.

curl Essentials

  • GET: curl -s https://api.example.com/users | jq .
  • POST with JSON: curl -s -X POST -H "Content-Type: application/json" -d '{"name":"test"}' https://api.example.com/users
  • Auth header: curl -s -H "Authorization: Bearer $TOKEN" https://api.example.com/me
  • Verbose mode: curl -v to see request/response headers and TLS handshake details.
  • Save response: curl -s -o response.json -w "%{http_code}" https://api.example.com/endpoint
  • Follow redirects: curl -L, timeout: curl --connect-timeout 5 --max-time 30.

Testing Methodology

  1. Authentication: Verify that unauthenticated requests return 401. Verify expired tokens return 401. Verify wrong roles return 403.
  2. Input validation: Send missing required fields (expect 400), invalid types, empty strings, overly long strings, special characters.
  3. Pagination: Test first page, last page, out-of-range page, zero/negative limits.
  4. Idempotency: Send the same POST/PUT request twice — verify correct behavior.
  5. Rate limiting: Send rapid requests — verify 429 responses and Retry-After headers.
  6. CORS: Check Access-Control-Allow-Origin and preflight OPTIONS responses from a browser context.

GraphQL Testing

  • Use introspection queries ({ __schema { types { name } } }) to discover the schema.
  • Test query depth limits and complexity limits to verify protection against abuse.
  • Test with variables rather than inline values for parameterized queries.
  • Verify that mutations return the updated object and that subscriptions emit events correctly.

Debugging Failed Requests

  • Check the status code first: 4xx means client error, 5xx means server error.
  • Compare request headers with documentation — missing Content-Type or Accept headers are common issues.
  • Use curl -v or --trace to inspect the raw HTTP exchange.
  • Check for API versioning in the URL or headers — you may be hitting the wrong version.
  • Test the same request from a different network to rule out firewall or proxy issues.

Pitfalls to Avoid

  • Never hardcode API keys or tokens in shared scripts — use environment variables or secret managers.
  • Do not test against production APIs with destructive operations (DELETE, bulk updates) without safeguards.
  • Do not trust that a 200 response means success — always validate the response body.
  • Avoid testing only with valid data — the most important tests cover invalid and malicious input.
常见问题

它使用哪个工具?

它主要使用 curl,并提供关于请求头、JSON 请求体、保存响应和超时的示例。

除了成功与否,还应检查什么?

状态码、响应头、响应体结构和数据类型,而不只是请求看起来是否成功。

凭据应该放在哪里?

该技能建议放在环境变量中,使其不出现在命令历史和脚本里。

详情

作者的原始描述

API testing expert for curl, REST, GraphQL, authentication, and debugging

repo: RightNow-AI/openfang

热度

GitHub 星标
18k
排名
#10663
许可证
Apache-2.0
更新时间
2026/7/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能