360 Secure SkillHub
360 安全技能中心

Api Tester

基于 Node.js 内置 http/https 模块实现的轻量 HTTP 客户端,可发送带自定义请求头与 JSON 请求体的 GET、POST、PUT、DELETE 请求,自动序列化请求体并解析响应,默认 10 秒超时,返回含 status、headers、data、raw、error 的结构化结果,用于 API 测试、健康检查或程序化访问 REST 服务。

wanng-ide
wanng-ide
热度 98.99
最近更新 2026-05-11 17:25:45
分类:开发依赖:代码执行 / 第三方 API应用场景:API 集成

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add api-tester
Metadata
name
api-tester
description
Perform structured HTTP/HTTPS requests (GET, POST, PUT, DELETE) with custom headers and JSON body support. Use for API testing, health checks, or interacting with REST services programmatically without relying on curl.

API Tester

A lightweight, dependency-free HTTP client for OpenClaw.

Usage

Basic GET Request

const api = require('skills/api-tester');
const result = await api.request('GET', 'https://api.example.com/data');
console.log(result.status, result.data);

POST Request with JSON Body

const api = require('skills/api-tester');
const payload = { key: 'value' };
const headers = { 'Authorization': 'Bearer <token>' };
const result = await api.request('POST', 'https://api.example.com/submit', headers, payload);

Return Format

The request function returns a Promise resolving to:

{
  status: 200,          // HTTP status code
  headers: { ... },     // Response headers
  data: { ... },        // Parsed JSON body (if applicable) or raw string
  raw: "...",           // Raw response body string
  error: "..."          // Error message if request failed (network error, timeout)
}

Features

  • Zero dependencies: Uses Node.js built-in http and https modules.
  • Auto-JSON: Automatically stringifies request body and parses response body if Content-Type matches.
  • Timeout support: Default 10s timeout, configurable.
  • Error handling: Returns structured error object instead of throwing, ensuring safe execution.