Skip to content

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:

  1. Validate URL against SSRF policy (private IPs, loopback, cloud metadata)
  2. Configure authentication from headers (Bearer / X-API-Key / custom)
  3. Execute HTTP request via aiohttp inside the API integrator
  4. Parse JSON response (or return raw content for non-JSON bodies)
  5. 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
}
FetchExternalDataRequest

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 headers
  • params: Query parameters for GET requests
  • body: Request body for POST requests
  • timeout_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
apiEndpoint
required
Apiendpoint

External API endpoint URL

string format: uri
>= 1 characters <= 2083 characters
method
Method

HTTP method

string
default: GET
Allowed values: GET POST
headers
Headers

Request headers

object
key
additional properties
string
params
Params

Query parameters for GET requests

object
key
additional properties
string
body
Body

Request body for POST requests

object
key
additional properties
any
timeoutSeconds
Timeoutseconds

Request timeout in seconds

integer
default: 30 >= 1 <= 120

Successful Response

FetchExternalDataResponse

Response from external API fetch operation.

Returns fetched data from external API with status code and timing information.

Fields:

  • success: Whether fetch was successful
  • status_code: HTTP status code from API
  • data: Fetched data from API (if successful)
  • error: Error message if fetch failed
  • response_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
success
required
Success

Whether fetch was successful

boolean
statusCode
required
Statuscode

HTTP status code from API

integer
>= 100 <= 599
data
Any of:
object
key
additional properties
any
error
Any of:
string
responseTimeMs
required
Responsetimems

API response time in milliseconds

integer

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object