Giter Site home page Giter Site logo

adaiasmagdiel / httpxfetch Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 8 KB

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

Home Page: https://pypi.org/project/httpxfetch/

License: MIT License

Python 100.00%
fetch-api httpx python reverse-engineering wrapper

httpxfetch's Introduction

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 httpxfetch 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.

httpxfetch's People

Contributors

adaiasmagdiel avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.