Fetch External Data
POST /api/agents/integrate/fetch
Fetch data from external API endpoints.
Integrates with third-party APIs to retrieve data for enrichment, validation, or supplementary information using Lagan’s API integrator. Supports GET/POST/PUT/PATCH/DELETE with authentication, custom headers, query parameters, and request bodies (POST/PUT/PATCH only; serialized as JSON).
Process:
- Validate URL against SSRF policy (private IPs, loopback, cloud metadata)
- Configure authentication from headers (Bearer / X-API-Key / custom)
- Execute HTTP request via aiohttp inside the API integrator
- Parse JSON response (or return raw content for non-JSON bodies)
- Return structured data with status + timing
Args: request: FetchExternalDataRequest with API endpoint and parameters.
Returns: FetchExternalDataResponse with fetched data and status.
Raises: HTTPException 400: API endpoint URL rejected by SSRF validator. HTTPException 503: Lagan API integrator not initialized.
Example:
POST /api/agents/discovery/integrate/fetch
{
"api_endpoint": "https://api.example.com/data",
"method": "GET",
"headers": {"Authorization": "Bearer token"},
"params": {"query": "search_term"},
"timeout_seconds": 30
}
Response:
{
"success": true,
"status_code": 200,
"data": {"results": [...], "total": 10},
"error": null,
"response_time_ms": 234
}Request Body required
Section titled “Request Body required ”Request to fetch data from external API.
Fetches data from an external API endpoint with configurable HTTP method, headers, parameters, and timeout.
Fields:
api_endpoint: External API endpoint URL (required, must be valid HTTP/HTTPS)method: HTTP method (GET or POST)headers: Custom request headersparams: Query parameters for GET requestsbody: Request body for POST requeststimeout_seconds: Request timeout (1-120 seconds, default 30)
Security Notes:
- External API calls are logged for auditing
- Sensitive headers should be handled securely
- Timeout prevents hanging requests
Usage: Used to fetch data from external APIs for enrichment.
Integration:
- IntegrationRoutes: Request validation for /integration/fetch endpoint
- LaganAgent: External data fetching tool
object
External API endpoint URL
HTTP method
Request headers
object
Query parameters for GET requests
object
Request body for POST requests
object
Request timeout in seconds
Responses
Section titled “ Responses ”Successful Response
Response from external API fetch operation.
Returns fetched data from external API with status code and timing information.
Fields:
success: Whether fetch was successfulstatus_code: HTTP status code from APIdata: Fetched data from API (if successful)error: Error message if fetch failedresponse_time_ms: API response time in milliseconds
Usage: Returned by external API fetch endpoints.
Integration:
- IntegrationRoutes: Response model for /integration/fetch endpoint
- Frontend: External data display
object
Whether fetch was successful
HTTP status code from API
API response time in milliseconds
Validation Error