Skip to content

Commit e24581f

Browse files
committed
Added Readme
1 parent e58c907 commit e24581f

File tree

2 files changed

+178
-1
lines changed

2 files changed

+178
-1
lines changed

readme.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# CuttlePy
2+
3+
A fully typed Python HTTP client built on top of [primp](https://github.com/deedy5/primp) - the fastest Python HTTP
4+
client with browser impersonation capabilities.
5+
6+
## Acknowledgements
7+
8+
This project is powered by the excellent [primp](https://github.com/deedy5/primp) library. CuttlePy provides type hints
9+
and a more structured interface while utilizing primp's powerful features under the hood.
10+
11+
## Features
12+
13+
- Full type hints support for better IDE integration
14+
- All the power of primp with a typed interface
15+
- Browser impersonation capabilities
16+
- Support for all HTTP methods
17+
- Comprehensive response object with typed properties
18+
19+
## Installation
20+
21+
```bash
22+
pip install cuttlepy
23+
```
24+
25+
## Usage
26+
27+
### Making Requests
28+
29+
```python
30+
from cuttlepy import get, CuttleClient
31+
32+
# Using convenience functions
33+
response = get("https://api.example.com/data")
34+
print(response.json())
35+
36+
# Using the client
37+
client = CuttleClient(
38+
impersonate="chrome_131",
39+
timeout=30
40+
)
41+
response = client.get("https://api.example.com/data")
42+
```
43+
44+
### Response Object
45+
46+
The `CuttleResponse` object provides typed access to response data:
47+
48+
```python
49+
response = get("https://api.example.com/data")
50+
51+
# Access response properties with proper typing
52+
content: bytes = response.content
53+
status_code: int = response.status_code
54+
headers: Dict[str, str] = response.headers
55+
cookies: CookieJar = response.cookies
56+
text: str = response.text
57+
58+
# Parse JSON with proper typing
59+
data: Any = response.json()
60+
```
61+
62+
### HTTP Methods
63+
64+
All standard HTTP methods are supported with full type hints:
65+
66+
```python
67+
from cuttlepy import CuttleClient
68+
69+
client = CuttleClient()
70+
71+
# GET request
72+
response = client.get(
73+
url="https://api.example.com/data",
74+
params={"key": "value"},
75+
headers={"Authorization": "Bearer token"}
76+
)
77+
78+
# POST request with JSON
79+
response = client.post(
80+
url="https://api.example.com/data",
81+
json={"key": "value"}
82+
)
83+
84+
# POST with form data
85+
response = client.post(
86+
url="https://api.example.com/data",
87+
data={"key": "value"}
88+
)
89+
90+
# POST with files
91+
response = client.post(
92+
url="https://api.example.com/data",
93+
files={"file": open("document.pdf", "rb").read()}
94+
)
95+
```
96+
97+
### Authentication
98+
99+
```python
100+
# Basic auth
101+
client = CuttleClient(auth=("username", "password"))
102+
103+
# Bearer token
104+
client = CuttleClient(auth_bearer="your-token")
105+
```
106+
107+
### Browser Impersonation
108+
109+
```python
110+
client = CuttleClient(impersonate="chrome_131")
111+
```
112+
113+
## 📖 API Reference
114+
115+
### CuttleClient
116+
117+
```python
118+
class CuttleClient:
119+
def __init__(
120+
self,
121+
*,
122+
auth: Optional[Tuple[str, str]] = None,
123+
auth_bearer: Optional[str] = None,
124+
params: Optional[Dict[str, str]] = None,
125+
headers: Optional[Dict[str, str]] = None,
126+
cookies: Optional[Dict[str, str]] = None,
127+
timeout: float = 30,
128+
cookie_store: bool = True,
129+
referer: bool = True,
130+
proxy: Optional[str] = None,
131+
impersonate: Optional[str] = None,
132+
follow_redirects: bool = True,
133+
max_redirects: int = 20,
134+
verify: bool = True,
135+
ca_cert_file: Optional[str] = None,
136+
http1: Optional[bool] = None,
137+
http2: Optional[bool] = None
138+
): ...
139+
```
140+
141+
### CuttleResponse
142+
143+
```python
144+
class CuttleResponse:
145+
@property
146+
def content(self) -> bytes: ...
147+
148+
@property
149+
def cookies(self) -> CookieJar: ...
150+
151+
@property
152+
def encoding(self) -> Optional[str]: ...
153+
154+
@property
155+
def headers(self) -> Dict[str, str]: ...
156+
157+
@property
158+
def status_code(self) -> int: ...
159+
160+
@property
161+
def text(self) -> str: ...
162+
163+
def json(self) -> Any: ...
164+
165+
@property
166+
def url(self) -> str: ...
167+
168+
def raise_for_status(self) -> None: ...
169+
```
170+
171+
## License
172+
173+
MIT License
174+
175+
## Links
176+
177+
- [primp Documentation](https://github.com/deedy5/primp) - The underlying HTTP client used by CuttlePy

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="cuttlepy",
8-
version="0.1.1",
8+
version="0.1.2",
99
author="Chanpreet Singh",
1010
author_email="[email protected]",
1111
description="Typed python HTTP client wrapper for PRIMP",

0 commit comments

Comments
 (0)