Skip to main content

httpxfetch is a Python wrapper for the JavaScript fetch function, designed to streamline the process of reverse engineering APIs.

Project description

httpxfetch

GitHub PyPI

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:

pip install httpxfetch

Quick Start

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

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 file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httpxfetch-0.0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httpxfetch-0.0.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file httpxfetch-0.0.2.tar.gz.

File metadata

  • Download URL: httpxfetch-0.0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for httpxfetch-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b5521651974d027bd7e70f363332fcd00a72aa822d7b83a877f8b94ca12601d1
MD5 7b03460e46efc294b84a78b45df153d3
BLAKE2b-256 eb6a406a559dce7d666d4608a4a2dfbb1fbe9f47d2f23c95cd709098aa4fc811

See more details on using hashes here.

File details

Details for the file httpxfetch-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: httpxfetch-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for httpxfetch-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 83ee6ede1a201c7ab8039a1b0f051fbebcd80072e5230b58778c4cd587969c60
MD5 a82307c08324b2fc66374188f7fc792f
BLAKE2b-256 0589975b75ae4fbd5102ab6b8ead202ac9450c79164fb85b3151f28827b75da2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page