reqease


Namereqease JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/DanielRodriguez-SS/reqease.git
SummaryReqease is a lean and clean library for performing basic HTTP operations with minimal overhead, designed to simplify common tasks like GET and POST requests
upload_time2024-10-30 05:44:37
maintainerNone
docs_urlNone
authorDaniel Rodriguez
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Project Description

**Reqease** is a lightweight, minimalistic library designed for performing essential HTTP operations with minimal complexity. It focuses on streamlining common HTTP tasks such as `GET` and `POST` requests, while avoiding the overhead of larger libraries.

Whether you're interacting with APIs, retrieving data from a web service, or submitting forms, Reqease offers a clean and intuitive interface that allows you to perform these tasks effortlessly. It handles HTTPS requests and responses, parses JSON content, and manages basic file handling, all with a simple and elegant design.

### Key Features:
- **Minimalistic**: Focuses on core HTTP functionality without unnecessary bloat.
- **Intuitive API**: Easy-to-use methods for common tasks like `GET` and `POST`.
- **SSL/TLS Support**: Ensures secure HTTPS connections out of the box.
- **JSON Handling**: Built-in functionality to decode and return JSON responses as Python objects.
- **File Support**: Write response data directly to files with simple method calls.

Reqease is perfect for developers who need basic HTTP operations without the complexity of larger frameworks, keeping the codebase clean and efficient.

# Installation

To install **Reqease**, use the following pip command:

```bash
pip install reqease
```

# Usage

## Simple GET Request

You can use the `Get` class to fetch data from a URL over HTTPS:

### Example 1: Using Get Without Headers:

This example sends a basic GET request without any headers.

```python
import reqease

# Define the URL
url = "https://jsonplaceholder.typicode.com/posts/1"

# Send the request and capture the response
response = reqease.Get(url).response

# Access and print details from the response
print("Status Code:", response.status_code)
print("Response Headers:", response.headers)
print("Body (as string):", response.body_str)
```

### Example 2: Using Get With Custom Headers:

In this example, we specify custom headers for the GET request, including a `Authorization` and `Accept` header.

```python
import reqease
# Define the URL and custom headers
url = "https://jsonplaceholder.typicode.com/posts/1"
headers = {
    "Authorization": "Bearer your_access_token",
    "Accept": "application/json"
}

# Send the request and capture the response
response = reqease.Get(url, headers).response

# Access and print details from the response
print("Status Code:", response.status_code)
print("Response Headers:", response.headers)
print("Body (as string):", response.body_str)
```

## Simple POST Request

You can use the `Post` class to send data to a server over HTTPS:

### Example 1: Using Post Without Headers

This example sends a basic POST request with data without any custom headers.

```python
import reqease

# Define the URL and the data to be sent
url = "https://jsonplaceholder.typicode.com/posts"
data = {"title": "foo", "body": "bar", "userId": 1}

# Send the request and capture the response
response = reqease.Post(url, data).response

# Access and print details from the response
print("Status Code:", response.status_code)
print("Response Headers:", response.headers)
print("Body (as string):", response.body_str)
```

### Example 2: Using Post With Headers

This example sends a basic POST request with data without any custom headers.

```python
import reqease

# Define the URL, data, and headers
url = "https://jsonplaceholder.typicode.com/posts"
data = {"title": "foo", "body": "bar", "userId": 1}
headers = {"Content-Type": "application/json"}

# Send the request and capture the response
response = reqease.Post(url, data, headers=headers).response

# Access and print details from the response
print("Status Code:", response.status_code)
print("Response Headers:", response.headers)
print("Body (as string):", response.body_str)
```

## Using Shared Methods

### Converting Response to Dictionary

Both the `Get` and `Post` classes provide a property called `to_dict`, which allows you to convert the response body to a Python dictionary. This is particularly useful when the response is in JSON format.

### Example 1: Using `to_dict` with Get

```python
import reqease

# Define the URL
url = "https://jsonplaceholder.typicode.com/posts/1"

# Send the request and capture the response to a dictionary
data = reqease.Get(url).to_dict

# Access and print details from the dictionary
print("Data as Dictionary:", data)
```

### Example 2: Using `to_dict` with Post

When sending JSON data with the Post class, be sure to include the appropriate headers.

```python
import reqease

# Define the URL and the data to be sent
url = "https://jsonplaceholder.typicode.com/posts"
data = {"title": "foo", "body": "bar", "userId": 1}

# Define headers with Content-Type for JSON
headers = {"Content-Type": "application/json"}

# Send the request and capture the response to a dictionary
data = Post(url, data, headers).to_dict

# Access and print details from the dictionary
print("Data as Dictionary:", data)
```

### Saving Response to a File

Both the `Get` and `Post` classes include a method called `to_file`, which allows you to save the response body to a file. The method automatically formats the output based on the content type of the response.

### Example 1: Using `to_file` with Get

```python
import reqease

# Define the URL
url = "https://jsonplaceholder.typicode.com/posts/1"

# Save the response to a JSON file
reqease.Get(url).to_file("data.json")

# You can also save as plain text
reqease.Get(url).to_file("data.txt")
```

### Example 2: Using `to_file` with Post

When sending JSON data with the Post class, you can also save the response using the to_file
method.

```python
import reqease

# Define the URL and the data to be sent
url = "https://jsonplaceholder.typicode.com/posts"
data = {"title": "foo", "body": "bar", "userId": 1}

# Define headers with Content-Type for JSON
headers = {"Content-Type": "application/json"}

# Save the response to a JSON file
reqease.Post(url, data, headers).to_file("data.json")

# You can also save as plain text
reqease.Post(url, data, headers).to_file("data.txt")
```

# Dependencies

**Reqease** has a minimal dependency footprint, making it a clean and lean library. The only external dependency required for this project is:

- **`certifi`**: This library provides a curated collection of root certificates for validating the trustworthiness of SSL/TLS certificates. It ensures that HTTPS requests made by the library are secure and reliable.

By using only standard libraries of Python, alongside `certifi`, Reqease maintains a lightweight design that focuses on simplicity and efficiency in performing HTTP operations.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/DanielRodriguez-SS/reqease.git",
    "name": "reqease",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Daniel Rodriguez",
    "author_email": "danielrodriguezmarin@me.com",
    "download_url": "https://files.pythonhosted.org/packages/8e/66/6c026cd68e33d4110dfffea53b1a05dae76894bf0d68603bed6a9e416c7e/reqease-0.1.3.tar.gz",
    "platform": null,
    "description": "# Project Description\n\n**Reqease** is a lightweight, minimalistic library designed for performing essential HTTP operations with minimal complexity. It focuses on streamlining common HTTP tasks such as `GET` and `POST` requests, while avoiding the overhead of larger libraries.\n\nWhether you're interacting with APIs, retrieving data from a web service, or submitting forms, Reqease offers a clean and intuitive interface that allows you to perform these tasks effortlessly. It handles HTTPS requests and responses, parses JSON content, and manages basic file handling, all with a simple and elegant design.\n\n### Key Features:\n- **Minimalistic**: Focuses on core HTTP functionality without unnecessary bloat.\n- **Intuitive API**: Easy-to-use methods for common tasks like `GET` and `POST`.\n- **SSL/TLS Support**: Ensures secure HTTPS connections out of the box.\n- **JSON Handling**: Built-in functionality to decode and return JSON responses as Python objects.\n- **File Support**: Write response data directly to files with simple method calls.\n\nReqease is perfect for developers who need basic HTTP operations without the complexity of larger frameworks, keeping the codebase clean and efficient.\n\n# Installation\n\nTo install **Reqease**, use the following pip command:\n\n```bash\npip install reqease\n```\n\n# Usage\n\n## Simple GET Request\n\nYou can use the `Get` class to fetch data from a URL over HTTPS:\n\n### Example 1: Using Get Without Headers:\n\nThis example sends a basic GET request without any headers.\n\n```python\nimport reqease\n\n# Define the URL\nurl = \"https://jsonplaceholder.typicode.com/posts/1\"\n\n# Send the request and capture the response\nresponse = reqease.Get(url).response\n\n# Access and print details from the response\nprint(\"Status Code:\", response.status_code)\nprint(\"Response Headers:\", response.headers)\nprint(\"Body (as string):\", response.body_str)\n```\n\n### Example 2: Using Get With Custom Headers:\n\nIn this example, we specify custom headers for the GET request, including a `Authorization` and `Accept` header.\n\n```python\nimport reqease\n# Define the URL and custom headers\nurl = \"https://jsonplaceholder.typicode.com/posts/1\"\nheaders = {\n    \"Authorization\": \"Bearer your_access_token\",\n    \"Accept\": \"application/json\"\n}\n\n# Send the request and capture the response\nresponse = reqease.Get(url, headers).response\n\n# Access and print details from the response\nprint(\"Status Code:\", response.status_code)\nprint(\"Response Headers:\", response.headers)\nprint(\"Body (as string):\", response.body_str)\n```\n\n## Simple POST Request\n\nYou can use the `Post` class to send data to a server over HTTPS:\n\n### Example 1: Using Post Without Headers\n\nThis example sends a basic POST request with data without any custom headers.\n\n```python\nimport reqease\n\n# Define the URL and the data to be sent\nurl = \"https://jsonplaceholder.typicode.com/posts\"\ndata = {\"title\": \"foo\", \"body\": \"bar\", \"userId\": 1}\n\n# Send the request and capture the response\nresponse = reqease.Post(url, data).response\n\n# Access and print details from the response\nprint(\"Status Code:\", response.status_code)\nprint(\"Response Headers:\", response.headers)\nprint(\"Body (as string):\", response.body_str)\n```\n\n### Example 2: Using Post With Headers\n\nThis example sends a basic POST request with data without any custom headers.\n\n```python\nimport reqease\n\n# Define the URL, data, and headers\nurl = \"https://jsonplaceholder.typicode.com/posts\"\ndata = {\"title\": \"foo\", \"body\": \"bar\", \"userId\": 1}\nheaders = {\"Content-Type\": \"application/json\"}\n\n# Send the request and capture the response\nresponse = reqease.Post(url, data, headers=headers).response\n\n# Access and print details from the response\nprint(\"Status Code:\", response.status_code)\nprint(\"Response Headers:\", response.headers)\nprint(\"Body (as string):\", response.body_str)\n```\n\n## Using Shared Methods\n\n### Converting Response to Dictionary\n\nBoth the `Get` and `Post` classes provide a property called `to_dict`, which allows you to convert the response body to a Python dictionary. This is particularly useful when the response is in JSON format.\n\n### Example 1: Using `to_dict` with Get\n\n```python\nimport reqease\n\n# Define the URL\nurl = \"https://jsonplaceholder.typicode.com/posts/1\"\n\n# Send the request and capture the response to a dictionary\ndata = reqease.Get(url).to_dict\n\n# Access and print details from the dictionary\nprint(\"Data as Dictionary:\", data)\n```\n\n### Example 2: Using `to_dict` with Post\n\nWhen sending JSON data with the Post class, be sure to include the appropriate headers.\n\n```python\nimport reqease\n\n# Define the URL and the data to be sent\nurl = \"https://jsonplaceholder.typicode.com/posts\"\ndata = {\"title\": \"foo\", \"body\": \"bar\", \"userId\": 1}\n\n# Define headers with Content-Type for JSON\nheaders = {\"Content-Type\": \"application/json\"}\n\n# Send the request and capture the response to a dictionary\ndata = Post(url, data, headers).to_dict\n\n# Access and print details from the dictionary\nprint(\"Data as Dictionary:\", data)\n```\n\n### Saving Response to a File\n\nBoth the `Get` and `Post` classes include a method called `to_file`, which allows you to save the response body to a file. The method automatically formats the output based on the content type of the response.\n\n### Example 1: Using `to_file` with Get\n\n```python\nimport reqease\n\n# Define the URL\nurl = \"https://jsonplaceholder.typicode.com/posts/1\"\n\n# Save the response to a JSON file\nreqease.Get(url).to_file(\"data.json\")\n\n# You can also save as plain text\nreqease.Get(url).to_file(\"data.txt\")\n```\n\n### Example 2: Using `to_file` with Post\n\nWhen sending JSON data with the Post class, you can also save the response using the to_file\nmethod.\n\n```python\nimport reqease\n\n# Define the URL and the data to be sent\nurl = \"https://jsonplaceholder.typicode.com/posts\"\ndata = {\"title\": \"foo\", \"body\": \"bar\", \"userId\": 1}\n\n# Define headers with Content-Type for JSON\nheaders = {\"Content-Type\": \"application/json\"}\n\n# Save the response to a JSON file\nreqease.Post(url, data, headers).to_file(\"data.json\")\n\n# You can also save as plain text\nreqease.Post(url, data, headers).to_file(\"data.txt\")\n```\n\n# Dependencies\n\n**Reqease** has a minimal dependency footprint, making it a clean and lean library. The only external dependency required for this project is:\n\n- **`certifi`**: This library provides a curated collection of root certificates for validating the trustworthiness of SSL/TLS certificates. It ensures that HTTPS requests made by the library are secure and reliable.\n\nBy using only standard libraries of Python, alongside `certifi`, Reqease maintains a lightweight design that focuses on simplicity and efficiency in performing HTTP operations.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Reqease is a lean and clean library for performing basic HTTP operations with minimal overhead, designed to simplify common tasks like GET and POST requests",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/DanielRodriguez-SS/reqease.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "24b41f99a9219f58c2aa7213a1fb47243ed1483a22f25e230acfea891cba12c5",
                "md5": "271bf932880611ae826ad786ec2c21eb",
                "sha256": "83cedb6d9f054315ce2a3b4a84e6764c18e31880025a080707f856649fe06bb4"
            },
            "downloads": -1,
            "filename": "reqease-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "271bf932880611ae826ad786ec2c21eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 7984,
            "upload_time": "2024-10-30T05:44:35",
            "upload_time_iso_8601": "2024-10-30T05:44:35.981174Z",
            "url": "https://files.pythonhosted.org/packages/24/b4/1f99a9219f58c2aa7213a1fb47243ed1483a22f25e230acfea891cba12c5/reqease-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e666c026cd68e33d4110dfffea53b1a05dae76894bf0d68603bed6a9e416c7e",
                "md5": "088a3c975f61316242633c5a0a83cde5",
                "sha256": "d72ea85b05fc0594fd9591bbf5e1232a01964d5638000e50edac02551c5c1e80"
            },
            "downloads": -1,
            "filename": "reqease-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "088a3c975f61316242633c5a0a83cde5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8280,
            "upload_time": "2024-10-30T05:44:37",
            "upload_time_iso_8601": "2024-10-30T05:44:37.057412Z",
            "url": "https://files.pythonhosted.org/packages/8e/66/6c026cd68e33d4110dfffea53b1a05dae76894bf0d68603bed6a9e416c7e/reqease-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-30 05:44:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DanielRodriguez-SS",
    "github_project": "reqease",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "reqease"
}
        
Elapsed time: 0.33141s