Skip to main content

API Request

api_request is the HTTP tool for interface calls. Unlike web_fetch, it doesn't emphasize text extraction but rather "API-style requests with structured results".

Required fields

ParameterDescription
base_urlAPI root URL, e.g. http://api.internal:8080
methodGET, POST, PUT, PATCH, DELETE
pathrelative API path, e.g. /v1/users

Optional fields

  • query
  • headers
  • body
  • timeout

When body is an object or array, the implementation automatically converts to JSON and adds Content-Type: application/json.

Return shape

Results are unified into:

{
"ok": true,
"status": 200,
"result": {},
"error": null
}

When failed, ok=false with HTTP status or exception info.

Config

tools:
api_request:
enabled: true
timeout: 20
max_bytes: 200000
follow_redirects: true
user_agent: "MushroomAgent api_request/1.0"

Use it for

  • internal services
  • structured REST APIs
  • interfaces requiring custom headers, body, or query params
  • business API calls more structured than web_fetch

Example

{
"tool": "api_request",
"base_url": "http://api.internal:8080",
"method": "POST",
"path": "/v1/jobs",
"body": { "name": "sync" }
}