Built-in functions: Network

@fetch_url <url>

Fetches the content of a URL. Returns an object with keys like response , code.

$response:@fetch_url “http://loclhost”

@print $response

> arr:

> [

>      response => <!DOCTYPE html ><html></html>

>      code => 200

> ]

@call_restapi <url>, <method>, <body>, {array of headers}, <valid_ssl = true>

Send an HTTP request to the specified REST API endpoint.

– url: The API endpoint URL (string).

– method>: HTTP method (e.g., “GET”, “POST”, “PUT”, “DELETE”).

– body: Request body content as a string (for methods like POST or PUT). Use empty string “” if no body.

– array of headers: An array of strings for HTTP headers, e.g. [“Content-Type: application/json”, “Authorization: Bearer …”].

– valid_ssl (optional, default true): If true, validate SSL certificates; if false, allow insecure SSL connections.

Returns the response body string and response code.

@call_restapi “https://api.example.com/data”, “POST”, “{\”key\”:\”value\”}”, [“Content-Type: application/json”], true

@print $?

> array:

> [

>      response => success

>      code => 200

> ]