Metadata-Version: 2.1
Name: httpxfetch
Version: 0.0.2
Summary: httpxfetch is a Python wrapper for the JavaScript fetch function, designed to streamline the process of reverse engineering APIs.
Author-email: Adaías Magdiel <eu@adaiasmagdiel.com>
Project-URL: Homepage, https://github.com/AdaiasMagdiel/httpxfetch
Project-URL: Issues, https://github.com/AdaiasMagdiel/httpxfetch/issues
Keywords: fetch,httpx,reverse engineering,JavaScript
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Utilities
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx==0.26.0

# httpxfetch

![GitHub](https://img.shields.io/github/license/AdaiasMagdiel/httpxfetch)
![PyPI](https://img.shields.io/pypi/v/httpxfetch)

`httpxfetch` is a Python wrapper for the JavaScript `fetch` function, designed to streamline the process of reverse engineering APIs. The primary goal of this project is to simplify testing and data inspection by allowing users to copy the `fetch` requests generated by browser developer tools, paste them into their Python code, and execute them seamlessly.

## Installation

You can install `httpxfetch` using pip:

```bash
pip install httpxfetch
```

## Quick Start

```python
from httpxfetch import fetch

# Example: Making a GET request
response = fetch('https://api.example.com/data')
print(response.status_code)
print(response.json())
```

## Features

- **Simplified Testing:** Copy and paste `fetch` requests from browser developer tools into your Python code for easy testing and data exploration.

- **Wrapper for HTTPX:** Utilizes the powerful `httpx` library to perform HTTP requests in Python.

- **JSON Handling:** Automatically converts the request body to a JSON string using the `JSON.stringify` equivalent function.

## Usage

```python
from fetch_to_httpx import fetch, JSON

# Example: Making a POST request with JSON payload
url = 'https://api.example.com/data'
options = {
    'method': 'post',
    'headers': {'Content-Type': 'application/json'},
    'body': JSON.stringify({'key': 'value'}),
}

response = fetch(url, options)
print(response.status_code)
print(response.json())
```

## Return Type

The `fetch` function returns an instance of the `httpx.Response` class. All methods available in the `httpx.Response` class can be applied to the result of the `fetch` function.

## Disclaimer

The project intentionally includes some redundant steps, such as converting the `fetch` body to a string before loading it as a dictionary. This is done to minimize the effort required, providing a convenient function to simulate `JSON.stringify` for ease of use.

## Contributing

Contributions are welcome! Feel free to open issues, submit pull requests, or provide suggestions to improve the project.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
