The impit Python module provides high-level clients and standalone functions for browser impersonation. You can use the Client or AsyncClient classes for managed sessions, or use standalone HTTP method functions for one-off requests.
Core Classes
Client: Synchronous client for managing requests.AsyncClient: Asynchronous client for managing requests.ImpitPyResponse: The response object returned by requests.
Standalone HTTP Methods
You can perform requests without manually instantiating a client using the following functions:
get(url, ...)post(url, ...)put(url, ...)head(url, ...)patch(url, ...)delete(url, ...)options(url, ...)trace(url, ...)stream(method, url, ...): For streaming response content.
Common Request Parameters
All request functions and methods accept the following optional arguments:
content: bytes (raw content)data: Request body dataheaders: dict[str, str]timeout: float or str (e.g., '10s'). Defaults to USE_CLIENT_DEFAULT.force_http3: boolcookie_jar: A Python object representing a cookie jar.cookies: dict of cookies.follow_redirects: boolmax_redirects: intproxy: str (proxy URL)
To use the default timeout settings, use the USE_CLIENT_DEFAULT constant.
import impit
# Using a standalone GET request
response = impit.get("https://example.com", timeout=5.0)
print(response.status_code)
# Using the Client class
client = impit.Client(proxy="http://myproxy:8080")
response = client.get("https://example.com")
# Streaming a request
stream = impit.stream("GET", "https://example.com/large-file")
for chunk in stream:
print(chunk)