AgentPM™

@zack/http-fetch

Make HTTP requests (GET/POST/etc.) and return normalized response metadata and content.

Install
agentpm install @zack/http-fetch@0.1.0
Load
Weekly downloads
1
0%
Last publish
1d ago
v0.1.0
agent.json
{
  "name": "http-fetch",
  "version": "0.1.0",
  "description": "Make HTTP requests (GET/POST/etc.) and return normalized response metadata and content.",
  "files": [
    "dist/"
  ],
  "entrypoint": {
    "args": [
      "dist/index.js"
    ],
    "command": "node",
    "timeout_ms": 60000
  },
  "environment": {
    "vars": {
      "HTTP_FETCH_PROXY_URL": {
        "required": false,
        "description": "Optional HTTP(S) proxy URL to route requests through."
      },
      "HTTP_FETCH_DEFAULT_USER_AGENT": {
        "required": false,
        "description": "Optional default User-Agent header to send when none is provided in inputs."
      }
    }
  },
  "inputs": {
    "type": "object",
    "required": [
      "url"
    ],
    "properties": {
      "url": {
        "type": "string",
        "format": "uri",
        "description": "The URL to request."
      },
      "body": {
        "type": "string",
        "description": "Optional request body (for POST/PUT/PATCH, etc.). Sent as-is. For JSON, send a JSON-stringified payload and set Content-Type accordingly."
      },
      "method": {
        "enum": [
          "GET",
          "POST",
          "PUT",
          "DELETE",
          "PATCH",
          "HEAD",
          "OPTIONS"
        ],
        "type": "string",
        "default": "GET",
        "description": "HTTP method to use."
      },
      "headers": {
        "type": "object",
        "description": "Optional request headers as a simple key/value map.",
        "additionalProperties": {
          "type": "string"
        }
      },
      "max_bytes": {
        "type": "integer",
        "default": 1048576,
        "maximum": 5242880,
        "minimum": 1,
        "description": "Maximum number of bytes to read from the response body. Responses larger than this should be truncated."
      },
      "timeout_ms": {
        "type": "integer",
        "default": 30000,
        "maximum": 120000,
        "minimum": 1,
        "description": "Request timeout in milliseconds."
      },
      "response_type": {
        "enum": [
          "auto",
          "text",
          "json",
          "bytes"
        ],
        "type": "string",
        "default": "auto",
        "description": "Hint for how the response body should be returned."
      },
      "follow_redirects": {
        "type": "boolean",
        "default": true,
        "description": "Whether to follow HTTP redirects."
      }
    },
    "additionalProperties": false
  },
  "outputs": {
    "oneOf": [
      {
        "type": "object",
        "required": [
          "ok",
          "status",
          "headers"
        ],
        "properties": {
          "ok": {
            "const": true
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code returned by the server."
          },
          "headers": {
            "type": "object",
            "description": "Normalized response headers as a key/value map.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "body_json": {
            "type": "object",
            "description": "Parsed JSON response body when response_type=json (or auto detects JSON)."
          },
          "body_text": {
            "type": "string",
            "description": "UTF-8 text response body when treatable as text (response_type=text or auto-detected)."
          },
          "truncated": {
            "type": "boolean",
            "description": "True if the response body was truncated due to max_bytes."
          },
          "url_final": {
            "type": "string",
            "description": "Final URL after redirects (if follow_redirects is true)."
          },
          "body_base64": {
            "type": "string",
            "description": "Base64-encoded response body for binary responses (response_type=bytes or auto detects binary)."
          },
          "status_text": {
            "type": "string",
            "description": "HTTP status text, if available."
          },
          "content_type": {
            "type": "string",
            "description": "Content-Type header value, if present."
          }
        },
        "additionalProperties": false
      },
      {
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "const": false
          },
          "error": {
            "type": "object",
            "required": [
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine-readable error code (e.g. INPUT_INVALID, REQUEST_FAILED, TIMEOUT, RESPONSE_TOO_LARGE)."
              },
              "details": {
                "type": "object",
                "description": "Optional structured context about the error (e.g. status code, URL).",
                "additionalProperties": true
              },
              "message": {
                "type": "string",
                "description": "Human-readable error message."
              }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": false
      }
    ]
  },
  "license": {
    "file": "LICENSE",
    "spdx": "MIT"
  },
  "runtime": {
    "type": "node",
    "version": "20"
  }
}
Environment variables
Optional
HTTP_FETCH_PROXY_URL
Optional HTTP(S) proxy URL to route requests through.
HTTP_FETCH_DEFAULT_USER_AGENT
Optional default User-Agent header to send when none is provided in inputs.
Compatibility
NodePython