Primp: HTTP Client with Browser Impersonation
Primp is a Python library that provides a fast HTTP client capable of impersonating various web browsers by replicating their headers and TLS/JA3/JA4/HTTP2 fingerprints. It is implemented as a Python binding to the high-performance Rust `rquest` library. The current version is 1.2.2, and the project maintains an active release cadence with frequent updates.
Warnings
- breaking As a relatively new library that wraps a Rust core, Primp's API can evolve. Significant updates have been noted in releases (e.g., v1.2.0 introduced new impersonation profiles and HTTP/2 fingerprinting). Always review release notes for potential API changes when upgrading, especially across minor versions.
- gotcha For effective browser impersonation, always specify an `impersonate` profile (e.g., `impersonate='chrome_146'`) and optionally `impersonate_os` when initializing a `Client` or `AsyncClient`. Without these, Primp may behave as a generic HTTP client and might not bypass advanced bot detection mechanisms.
- gotcha Primp requires Python 3.10 or newer. Attempting to install or run Primp with older Python versions will result in installation failures or runtime errors due to syntax or dependency incompatibilities.
- gotcha Being a Python binding to a Rust library, debugging low-level network issues (e.g., TLS handshakes, specific HTTP/2 frame errors) might occasionally require familiarity with Rust concepts or consulting the documentation of the underlying `rquest` library.
Install
-
pip install primp
Imports
- Client
from primp import Client
- AsyncClient
from primp import AsyncClient
- Impersonate
from primp import Impersonate
Quickstart
import primp
# Initialize a client with a specific browser impersonation profile
# Available profiles: chrome_146, safari_26, edge_146, firefox_148, opera_129, etc.
# You can also specify an OS: impersonate_os="linux"
client = primp.Client(impersonate="chrome_146")
# Make a GET request to a TLS fingerprint testing service
resp = client.get("https://tls.peet.ws/api/all")
# Print the response body (usually JSON content showing TLS/browser details)
print(resp.text)
# For asynchronous usage:
# import asyncio
# async def main():
# async with primp.AsyncClient(impersonate="chrome_146") as client:
# resp = await client.get("https://tls.peet.ws/api/all")
# print(resp.text)
# asyncio.run(main())