cuttlepy


Namecuttlepy JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/chanpreet3000/cuttlepy
SummaryTyped python HTTP client wrapper for PRIMP
upload_time2024-12-14 19:14:41
maintainerNone
docs_urlNone
authorChanpreet Singh
requires_python>=3.8
licenseNone
keywords http client wrapper primp requests httpx aiohhtp
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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": "https://github.com/chanpreet3000/cuttlepy",
    "name": "cuttlepy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "http, client, wrapper, primp, requests, httpx, aiohhtp",
    "author": "Chanpreet Singh",
    "author_email": "chanpreet3000@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/09/11/00a18dfaf2abb3d4daf4979c204ac673078345e5d43c76dfdaab0d355a2d/cuttlepy-0.1.4.tar.gz",
    "platform": null,
    "description": "# CuttlePy\r\n\r\nA fully typed Python HTTP client built on top of [primp](https://github.com/deedy5/primp) - the fastest Python HTTP\r\nclient with browser impersonation capabilities.\r\n\r\n## Acknowledgements\r\n\r\nThis project is powered by the excellent [primp](https://github.com/deedy5/primp) library. CuttlePy provides type hints\r\nand a more structured interface while utilizing primp's powerful features under the hood.\r\n\r\n## Features\r\n\r\n- Full type hints support for better IDE integration\r\n- All the power of primp with a typed interface\r\n- Browser impersonation capabilities\r\n- Support for all HTTP methods\r\n- Comprehensive response object with typed properties\r\n\r\n## Installation\r\n\r\n```bash\r\npip install cuttlepy\r\n```\r\n\r\n## Usage\r\n\r\n### Making Requests\r\n\r\n```python\r\nfrom cuttlepy import get, CuttleClient\r\n\r\n# Using convenience functions\r\nresponse = get(\"https://api.example.com/data\")\r\nprint(response.json())\r\n\r\n# Using the client\r\nclient = CuttleClient(\r\n    impersonate=\"chrome_131\",\r\n    timeout=30\r\n)\r\nresponse = client.get(\"https://api.example.com/data\")\r\n```\r\n\r\n### Response Object\r\n\r\nThe `CuttleResponse` object provides typed access to response data:\r\n\r\n```python\r\nresponse = get(\"https://api.example.com/data\")\r\n\r\n# Access response properties with proper typing\r\ncontent: bytes = response.content\r\nstatus_code: int = response.status_code\r\nheaders: Dict[str, str] = response.headers\r\ncookies: CookieJar = response.cookies\r\ntext: str = response.text\r\n\r\n# Parse JSON with proper typing\r\ndata: Any = response.json()\r\n```\r\n\r\n### HTTP Methods\r\n\r\nAll standard HTTP methods are supported with full type hints:\r\n\r\n```python\r\nfrom cuttlepy import CuttleClient\r\n\r\nclient = CuttleClient()\r\n\r\n# GET request\r\nresponse = client.get(\r\n    url=\"https://api.example.com/data\",\r\n    params={\"key\": \"value\"},\r\n    headers={\"Authorization\": \"Bearer token\"}\r\n)\r\n\r\n# POST request with JSON\r\nresponse = client.post(\r\n    url=\"https://api.example.com/data\",\r\n    json={\"key\": \"value\"}\r\n)\r\n\r\n# POST with form data\r\nresponse = client.post(\r\n    url=\"https://api.example.com/data\",\r\n    data={\"key\": \"value\"}\r\n)\r\n\r\n# POST with files\r\nresponse = client.post(\r\n    url=\"https://api.example.com/data\",\r\n    files={\"file\": open(\"document.pdf\", \"rb\").read()}\r\n)\r\n```\r\n\r\n### Authentication\r\n\r\n```python\r\n# Basic auth\r\nclient = CuttleClient(auth=(\"username\", \"password\"))\r\n\r\n# Bearer token\r\nclient = CuttleClient(auth_bearer=\"your-token\")\r\n```\r\n\r\n### Browser Impersonation\r\n\r\n```python\r\nclient = CuttleClient(impersonate=\"chrome_131\")\r\n```\r\n\r\n## \ud83d\udcd6 API Reference\r\n\r\n### CuttleClient\r\n\r\n```python\r\nclass CuttleClient:\r\n    def __init__(\r\n            self,\r\n            *,\r\n            auth: Optional[Tuple[str, str]] = None,\r\n            auth_bearer: Optional[str] = None,\r\n            params: Optional[Dict[str, str]] = None,\r\n            headers: Optional[Dict[str, str]] = None,\r\n            cookies: Optional[Dict[str, str]] = None,\r\n            timeout: float = 30,\r\n            cookie_store: bool = True,\r\n            referer: bool = True,\r\n            proxy: Optional[str] = None,\r\n            impersonate: Optional[str] = None,\r\n            follow_redirects: bool = True,\r\n            max_redirects: int = 20,\r\n            verify: bool = True,\r\n            ca_cert_file: Optional[str] = None,\r\n            http1: Optional[bool] = None,\r\n            http2: Optional[bool] = None\r\n    ): ...\r\n```\r\n\r\n### CuttleResponse\r\n\r\n```python\r\nclass CuttleResponse:\r\n    @property\r\n    def content(self) -> bytes: ...\r\n\r\n    @property\r\n    def cookies(self) -> CookieJar: ...\r\n\r\n    @property\r\n    def encoding(self) -> Optional[str]: ...\r\n\r\n    @property\r\n    def headers(self) -> Dict[str, str]: ...\r\n\r\n    @property\r\n    def status_code(self) -> int: ...\r\n\r\n    @property\r\n    def text(self) -> str: ...\r\n\r\n    def json(self) -> Any: ...\r\n\r\n    @property\r\n    def url(self) -> str: ...\r\n\r\n    def raise_for_status(self) -> None: ...\r\n```\r\n\r\n## License\r\n\r\nMIT License\r\n\r\n## Links\r\n\r\n- [primp Documentation](https://github.com/deedy5/primp) - The underlying HTTP client used by CuttlePy\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Typed python HTTP client wrapper for PRIMP",
    "version": "0.1.4",
    "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": [
        "http",
        " client",
        " wrapper",
        " primp",
        " requests",
        " httpx",
        " aiohhtp"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a662ba51bd5a2ec2f7b992f478b28d7360ccdb0dcfd4037bf6d14421455f1f6",
                "md5": "422b0648f95f6a20ab26c7f60904365b",
                "sha256": "a2ffc66eac70ff74b30cdff41141d539b87cbcee063a57e8322da8eddb678b55"
            },
            "downloads": -1,
            "filename": "cuttlepy-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "422b0648f95f6a20ab26c7f60904365b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7533,
            "upload_time": "2024-12-14T19:14:38",
            "upload_time_iso_8601": "2024-12-14T19:14:38.592299Z",
            "url": "https://files.pythonhosted.org/packages/9a/66/2ba51bd5a2ec2f7b992f478b28d7360ccdb0dcfd4037bf6d14421455f1f6/cuttlepy-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "091100a18dfaf2abb3d4daf4979c204ac673078345e5d43c76dfdaab0d355a2d",
                "md5": "c75186fdd4cc0681b7c025005d53e75a",
                "sha256": "efa3ffa3c4885477618e1e1deccdc33aff8e1e6219aad19562299c2a39a9d222"
            },
            "downloads": -1,
            "filename": "cuttlepy-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "c75186fdd4cc0681b7c025005d53e75a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7726,
            "upload_time": "2024-12-14T19:14:41",
            "upload_time_iso_8601": "2024-12-14T19:14:41.845100Z",
            "url": "https://files.pythonhosted.org/packages/09/11/00a18dfaf2abb3d4daf4979c204ac673078345e5d43c76dfdaab0d355a2d/cuttlepy-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-14 19:14:41",
    "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"
}
        
Elapsed time: 9.26386s