HTTP & Network
OcaltQL provides full network access — HTTP requests via FETCH and CURL, IP aliasing and proxy routing, user agent control, real-time communication via WebSocket, and low-level TCP and UDP connections.
FETCH
See Fetch & Curl for the full FETCH reference. The essentials are covered here alongside the extended network capabilities.
FETCH 'https://api.example.com/data' SET ?response
AFTER FETCH 'https://api.example.com/data' METHOD 'post' BODY 'name=Alice&age=30' SET ?response
AFTER FETCH 'https://api.example.com/data' METHOD 'post' BODY '{"name":"Alice"}' HEADER 'Content-Type: application/json' SET ?response
AFTER FETCH 'https://api.example.com/data' HEADER 'Auth: token' HEADER 'X-Custom: value' SET ?response
AFTER FETCH 'https://api.example.com/data' TIMEOUT 10 SECONDS SET ?response
AFTER FETCH 'https://example.com/image.jpg' INTO '/root/image.jpg'
AFTER FETCH 'https://api.example.com/data' SET ?code WITH STATUS AND SET ?body WITH DATA
AFTER EMIT ?code
AFTER EMIT ?body
IP Aliasing & Proxy
IP routes the request from a specific source IP. IP ALIAS hides the real IP behind an alias. PROXY routes through an HTTP or SOCKS5 proxy. All are modifiers on FETCH and can be combined with any other modifier.
FETCH 'https://api.example.com/data' IP '192.168.1.100' SET ?response
AFTER FETCH 'https://api.example.com/data' IP ALIAS '10.0.0.5' SET ?response
FETCH 'https://api.example.com/data' PROXY 'http://proxy.example.com:8080' SET ?response
AFTER FETCH 'https://api.example.com/data' PROXY 'socks5://127.0.0.1:1080' SET ?response
User Agent Control
USER AGENT sets the user agent string sent with the request. Any string is valid. Pass an empty string to send no user agent.
FETCH 'https://api.example.com/data' USER AGENT 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)' SET ?response
AFTER FETCH 'https://api.example.com/data' USER AGENT 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X)' SET ?response
AFTER FETCH 'https://api.example.com/data' USER AGENT 'OcaltQL-Bot/1.0' SET ?response
AFTER FETCH 'https://api.example.com/data' USER AGENT '' SET ?response
Combined Modifiers
All modifiers — IP, proxy, user agent, headers, method, body, timeout — can be combined in any order on a single FETCH.
FETCH 'https://api.example.com/data' IP '203.0.113.1' USER AGENT 'CustomBot/1.0' HEADER 'X-Real-IP: 203.0.113.1' HEADER 'Referer: https://example.com' SET ?response
CURL
CURL is a direct alias for FETCH. Every modifier available on FETCH works identically on CURL.
CURL 'https://api.example.com/data' SET ?response
STATUS
STATUS sets the HTTP response status code for the current script execution. It has no effect on execution flow — the script continues normally after it runs.
STATUS 404
AFTER EMIT "Not found"
IF ?user IS NULL
OPEN
STATUS 401
AFTER EMIT "Unauthorized"
CLOSE
OR
OPEN
STATUS 200
AFTER EMIT "Welcome, " & ?user("email")
CLOSE
WebSocket
WEBSOCKET opens a WebSocket connection. SEND transmits a message. RECEIVE blocks until a message arrives and captures it. CLOSE terminates the connection.
(* Open connection *)
WEBSOCKET 'wss://socket.example.com' SET ?ws
(* Send message *)
AFTER SEND ?ws 'hello'
(* Receive message *)
AFTER RECEIVE ?ws SET ?msg
AFTER EMIT ?msg
(* Close connection *)
AFTER CLOSE ?ws
TCP
TCP opens a raw TCP connection to a host and port. SEND transmits data. RECEIVE reads incoming data.
(* Connect *)
TCP '192.168.1.1' PORT 8080 SET ?tcp
(* Send *)
AFTER SEND ?tcp 'hello'
(* Receive *)
AFTER RECEIVE ?tcp SET ?data
AFTER EMIT ?data
UDP
UDP sends a datagram to a host and port. UDP is connectionless — there is no persistent connection object and no RECEIVE on the same call.
UDP '192.168.1.1' PORT 53 SEND 'query'
?ws, ?tcp) determines the protocol. CLOSE terminates any open connection by its variable.