EXTERNAL_HTTP()

All functions > SOURCE > EXTERNAL_HTTP()

Returns the JSON response from a HTTP call

Signatures

Returns: Parsed JSON response from HTTP API in [value], plus source_status on serving

EXTERNAL_HTTP(
  FROM source
  [ WITH ( property = value, ... ) ]
) → ROW(value JSON)
ParameterTypeRequiredDescription
sourceHTTPSOURCEYesConnection feature defined with SOURCE_HTTP()
methodVARCHARNoWITH property: HTTP method override
pathVARCHARNoWITH property: path override or extension
headersROWNoWITH property: headers override or extension
query_paramsROWNoWITH property: query parameters override or extension
bodyROWNoWITH property: request body override
timeoutDECIMALNoWITH property: timeout override

Notes

  • Makes HTTP API call and returns JSON response
  • WITH properties override the SOURCE_HTTP() defaults
  • Supports dynamic request parameters per query
  • Returns ROW(value JSON): read the response with [value]
  • The row also has source_status (OK, MISS, TIMEOUT, UNAVAILABLE, ERROR) on serving: reading it guards the call (on a failed request the value is NULL, the status says why, the call succeeds); unguarded, a failed request fails the call
  • Common use cases: fraud detection APIs, ML model APIs, enrichment services
  • Handles request retries and error responses
  • Online-only restriction (for real-time serving)

See also

Examples

Call an API per key and parse the JSON response

FeatureQL
DEFINE
    firstname := INPUT(VARCHAR)
RETURN
    firstname,
    http_response := EXTERNAL_HTTP(
        FROM fm.tutorials.external_http.http_source
        WITH (
            QUERY_PARAMS = ROW(firstname AS name)
        )
    )[value]
FOR
    firstname := BIND_VALUES(ARRAY('Alice', 'Bob', 'Charlie'))
;
Result
FIRSTNAME VARCHARHTTP_RESPONSE VARCHAR
AliceHello Alice!
BobHello Bob!
CharlieHello Charlie!