# CuttlePy
A fully typed Python HTTP client built on top of [primp](https://github.com/deedy5/primp) - the fastest Python HTTP
client with browser impersonation capabilities.
## Acknowledgements
This project is powered by the excellent [primp](https://github.com/deedy5/primp) library. CuttlePy provides type hints
and a more structured interface while utilizing primp's powerful features under the hood.
## Features
- Full type hints support for better IDE integration
- All the power of primp with a typed interface
- Browser impersonation capabilities
- Support for all HTTP methods
- Comprehensive response object with typed properties
## Installation
```bash
pip install cuttlepy
```
## Usage
### Making Requests
```python
from cuttlepy import get, CuttleClient
# Using convenience functions
response = get("https://api.example.com/data")
print(response.json())
# Using the client
client = CuttleClient(
impersonate="chrome_131",
timeout=30
)
response = client.get("https://api.example.com/data")
```
### Response Object
The `CuttleResponse` object provides typed access to response data:
```python
response = get("https://api.example.com/data")
# Access response properties with proper typing
content: bytes = response.content
status_code: int = response.status_code
headers: Dict[str, str] = response.headers
cookies: CookieJar = response.cookies
text: str = response.text
# Parse JSON with proper typing
data: Any = response.json()
```
### HTTP Methods
All standard HTTP methods are supported with full type hints:
```python
from cuttlepy import CuttleClient
client = CuttleClient()
# GET request
response = client.get(
url="https://api.example.com/data",
params={"key": "value"},
headers={"Authorization": "Bearer token"}
)
# POST request with JSON
response = client.post(
url="https://api.example.com/data",
json={"key": "value"}
)
# POST with form data
response = client.post(
url="https://api.example.com/data",
data={"key": "value"}
)
# POST with files
response = client.post(
url="https://api.example.com/data",
files={"file": open("document.pdf", "rb").read()}
)
```
### Authentication
```python
# Basic auth
client = CuttleClient(auth=("username", "password"))
# Bearer token
client = CuttleClient(auth_bearer="your-token")
```
### Browser Impersonation
```python
client = CuttleClient(impersonate="chrome_131")
```
## 📖 API Reference
### CuttleClient
```python
class CuttleClient:
def __init__(
self,
*,
auth: Optional[Tuple[str, str]] = None,
auth_bearer: Optional[str] = None,
params: Optional[Dict[str, str]] = None,
headers: Optional[Dict[str, str]] = None,
cookies: Optional[Dict[str, str]] = None,
timeout: float = 30,
cookie_store: bool = True,
referer: bool = True,
proxy: Optional[str] = None,
impersonate: Optional[str] = None,
follow_redirects: bool = True,
max_redirects: int = 20,
verify: bool = True,
ca_cert_file: Optional[str] = None,
http1: Optional[bool] = None,
http2: Optional[bool] = None
): ...
```
### CuttleResponse
```python
class CuttleResponse:
@property
def content(self) -> bytes: ...
@property
def cookies(self) -> CookieJar: ...
@property
def encoding(self) -> Optional[str]: ...
@property
def headers(self) -> Dict[str, str]: ...
@property
def status_code(self) -> int: ...
@property
def text(self) -> str: ...
def json(self) -> Any: ...
@property
def url(self) -> str: ...
def raise_for_status(self) -> None: ...
```
## License
MIT License
## Links
- [primp Documentation](https://github.com/deedy5/primp) - The underlying HTTP client used by CuttlePy
Raw data
{
"_id": null,
"home_page": null,
"name": "cuttlepy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "aiohttp, client, http, httpx, primp, requests, wrapper",
"author": null,
"author_email": "Chanpreet Singh <chanpreet3000@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/60/28/fe61018a69e2f2e1c471732c498bf67cd1a1c1a8b2d99f0e55c50127a0ad/cuttlepy-0.2.2.tar.gz",
"platform": null,
"description": "# CuttlePy\n\nA fully typed Python HTTP client built on top of [primp](https://github.com/deedy5/primp) - the fastest Python HTTP\nclient with browser impersonation capabilities.\n\n## Acknowledgements\n\nThis project is powered by the excellent [primp](https://github.com/deedy5/primp) library. CuttlePy provides type hints\nand a more structured interface while utilizing primp's powerful features under the hood.\n\n## Features\n\n- Full type hints support for better IDE integration\n- All the power of primp with a typed interface\n- Browser impersonation capabilities\n- Support for all HTTP methods\n- Comprehensive response object with typed properties\n\n## Installation\n\n```bash\npip install cuttlepy\n```\n\n## Usage\n\n### Making Requests\n\n```python\nfrom cuttlepy import get, CuttleClient\n\n# Using convenience functions\nresponse = get(\"https://api.example.com/data\")\nprint(response.json())\n\n# Using the client\nclient = CuttleClient(\n impersonate=\"chrome_131\",\n timeout=30\n)\nresponse = client.get(\"https://api.example.com/data\")\n```\n\n### Response Object\n\nThe `CuttleResponse` object provides typed access to response data:\n\n```python\nresponse = get(\"https://api.example.com/data\")\n\n# Access response properties with proper typing\ncontent: bytes = response.content\nstatus_code: int = response.status_code\nheaders: Dict[str, str] = response.headers\ncookies: CookieJar = response.cookies\ntext: str = response.text\n\n# Parse JSON with proper typing\ndata: Any = response.json()\n```\n\n### HTTP Methods\n\nAll standard HTTP methods are supported with full type hints:\n\n```python\nfrom cuttlepy import CuttleClient\n\nclient = CuttleClient()\n\n# GET request\nresponse = client.get(\n url=\"https://api.example.com/data\",\n params={\"key\": \"value\"},\n headers={\"Authorization\": \"Bearer token\"}\n)\n\n# POST request with JSON\nresponse = client.post(\n url=\"https://api.example.com/data\",\n json={\"key\": \"value\"}\n)\n\n# POST with form data\nresponse = client.post(\n url=\"https://api.example.com/data\",\n data={\"key\": \"value\"}\n)\n\n# POST with files\nresponse = client.post(\n url=\"https://api.example.com/data\",\n files={\"file\": open(\"document.pdf\", \"rb\").read()}\n)\n```\n\n### Authentication\n\n```python\n# Basic auth\nclient = CuttleClient(auth=(\"username\", \"password\"))\n\n# Bearer token\nclient = CuttleClient(auth_bearer=\"your-token\")\n```\n\n### Browser Impersonation\n\n```python\nclient = CuttleClient(impersonate=\"chrome_131\")\n```\n\n## \ud83d\udcd6 API Reference\n\n### CuttleClient\n\n```python\nclass CuttleClient:\n def __init__(\n self,\n *,\n auth: Optional[Tuple[str, str]] = None,\n auth_bearer: Optional[str] = None,\n params: Optional[Dict[str, str]] = None,\n headers: Optional[Dict[str, str]] = None,\n cookies: Optional[Dict[str, str]] = None,\n timeout: float = 30,\n cookie_store: bool = True,\n referer: bool = True,\n proxy: Optional[str] = None,\n impersonate: Optional[str] = None,\n follow_redirects: bool = True,\n max_redirects: int = 20,\n verify: bool = True,\n ca_cert_file: Optional[str] = None,\n http1: Optional[bool] = None,\n http2: Optional[bool] = None\n ): ...\n```\n\n### CuttleResponse\n\n```python\nclass CuttleResponse:\n @property\n def content(self) -> bytes: ...\n\n @property\n def cookies(self) -> CookieJar: ...\n\n @property\n def encoding(self) -> Optional[str]: ...\n\n @property\n def headers(self) -> Dict[str, str]: ...\n\n @property\n def status_code(self) -> int: ...\n\n @property\n def text(self) -> str: ...\n\n def json(self) -> Any: ...\n\n @property\n def url(self) -> str: ...\n\n def raise_for_status(self) -> None: ...\n```\n\n## License\n\nMIT License\n\n## Links\n\n- [primp Documentation](https://github.com/deedy5/primp) - The underlying HTTP client used by CuttlePy\n",
"bugtrack_url": null,
"license": null,
"summary": "Typed python HTTP client wrapper for PRIMP",
"version": "0.2.2",
"project_urls": {
"Bug Tracker": "https://github.com/chanpreet3000/cuttlepy/issues",
"Homepage": "https://github.com/chanpreet3000/cuttlepy",
"Source Code": "https://github.com/chanpreet3000/cuttlepy"
},
"split_keywords": [
"aiohttp",
" client",
" http",
" httpx",
" primp",
" requests",
" wrapper"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "47a93d6ae01f861f7166579dd1ef2baea86ec80ba8795564be65069c998c8b60",
"md5": "a6b295becd3fbc5e0e283b5b851b6add",
"sha256": "1e50d9a2533daec738c9d9dd19a2561339e5b8a5b22ee3a89191b8990bceb6ae"
},
"downloads": -1,
"filename": "cuttlepy-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a6b295becd3fbc5e0e283b5b851b6add",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7258,
"upload_time": "2024-12-22T17:13:05",
"upload_time_iso_8601": "2024-12-22T17:13:05.627346Z",
"url": "https://files.pythonhosted.org/packages/47/a9/3d6ae01f861f7166579dd1ef2baea86ec80ba8795564be65069c998c8b60/cuttlepy-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6028fe61018a69e2f2e1c471732c498bf67cd1a1c1a8b2d99f0e55c50127a0ad",
"md5": "658cde49079d376ab5e1075665b4e8d9",
"sha256": "aedeb14fe77e4964117a888a825b564eea497955f2fd315dd1a136e1c8e19b5c"
},
"downloads": -1,
"filename": "cuttlepy-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "658cde49079d376ab5e1075665b4e8d9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11287,
"upload_time": "2024-12-22T17:13:07",
"upload_time_iso_8601": "2024-12-22T17:13:07.355135Z",
"url": "https://files.pythonhosted.org/packages/60/28/fe61018a69e2f2e1c471732c498bf67cd1a1c1a8b2d99f0e55c50127a0ad/cuttlepy-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-22 17:13:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "chanpreet3000",
"github_project": "cuttlepy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "cuttlepy"
}