DocsHTTP Clienthttp_request

http_request

Http Request

Make an HTTP/HTTPS request with full control over method, headers, body, authentication, proxy, and TLS settings. Supports GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS methods. Includes proxy support (HTTP, HTTPS, SOCKS4, SOCKS5, SOCKS5H) and built-in Tor integration for anonymous requests. Returns status code, response headers, body, timing information, and redirect details. Use 'output' parameter to control body format: 'text' for UTF-8, 'base64' for binary content, 'json' for parsed JSON.

Usage Example

1234567891011
import asyncio
from owl_browser import OwlBrowser, RemoteConfig
# Async usage
async with OwlBrowser(config) as browser:
context = await browser.create_context()
context_id = context["context_id"]
await browser.http_request(
url="https://example.com"
)

Parameters

Required

urlstringrequired

The full URL to request, including protocol (e.g., 'https://api.example.com/data'). Supports http:// and https:// protocols.

Optional

methodenum
GETPOSTPUTDELETE+3 more

HTTP method to use. Options: 'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'. Default: 'GET'

headersstring

HTTP headers as a JSON object (e.g., {"Content-Type": "application/json", "X-Custom": "value"}) or as a string with one header per line. Each key-value pair becomes a request header.

bodystring

Request body content. For JSON APIs, pass a JSON string and set Content-Type header to 'application/json'. For form data, use URL-encoded format with Content-Type 'application/x-www-form-urlencoded'.

cookiesstring

Cookies to send with the request. Accepts either a string in 'name=value; name2=value2' format, or a JSON array of cookie objects from browser_get_cookies (e.g., [{"name": "session", "value": "abc"}, ...]). When using the array format, only 'name' and 'value' fields are used.

auth_typeenum
nonebasicbearerdigest

Authentication type. Options: 'none', 'basic', 'bearer', 'digest'. Default: 'none'

auth_usernamestring

Username for basic or digest authentication.

auth_passwordstring

Password for basic or digest authentication.

auth_tokenstring

Bearer token for bearer authentication (without 'Bearer ' prefix).

proxy_typeenum
httphttpssocks4socks5+1 more

Type of proxy server. Options: 'http', 'https', 'socks4', 'socks5', 'socks5h'. Use 'socks5h' for remote DNS resolution (recommended for privacy).

proxy_hoststring

Proxy server hostname or IP address.

proxy_portstring

Proxy server port number.

proxy_usernamestring

Username for proxy authentication.

proxy_passwordstring

Password for proxy authentication.

use_torboolean

Use built-in Tor proxy (SOCKS5H at 127.0.0.1:9050) for anonymous requests. Overrides any proxy settings. Default: false

follow_redirectsboolean

Follow HTTP redirects automatically. Default: true

max_redirectsstring

Maximum number of redirects to follow. Default: 10

timeoutstring

Total request timeout in milliseconds. Default: 30000 (30 seconds)

connect_timeoutstring

Connection timeout in milliseconds. Default: 10000 (10 seconds)

ssl_verifyboolean

Verify SSL/TLS certificates. Set to false for self-signed certificates. Default: true

ca_cert_pathstring

Path to custom CA certificate bundle file (.pem) for SSL verification.

user_agentstring

Custom User-Agent header string. Overrides default.

outputenum
textbase64json

Response body output format. 'text' for UTF-8 text, 'base64' for binary content encoded as base64, 'json' to attempt JSON parsing. Default: 'text'

Response

Returns a JSON object with the operation result.

{
  "success": true,
  "result": <value>
}