Automatically create a simple API wrapper from request data generated by your browser.
Project description
AutoRequests
AutoRequests provides an easy way to create a simple API wrapper from request data generated by your browser.
📺 Demo
** the website shown in this example is imperialb.in
💼 Example Use Cases
- Creating a foundation for an API wrapper
- Recreating a request outside the browser
- Testing what cookies or headers are required for a server to understand your request
✂️ How to Copy
- Inspect Element
- Go to
Network
tab - Find web request
- Right-Click
- Copy
- Choose one of the following:
- Powershell
- Node.JS fetch
📦 Installation
install the package with pip
$ pip install autorequests
or download the latest development build from GitHub
$ pip install -U git+https://github.com/Hexiro/autorequests
🖥️ Command Line
$ autorequests --help
directory options
-i, --input Input Directory
-o, --output Output Directory
generation options
--return-text Makes the generated method's responses return .text instead of .json()
--no-headers Removes all headers from the operation
--no-cookies Removes all cookies from the operation
--parameters Replaces hardcoded params, json, data, etc with parameters that have default values
🚩 Known Issues
- Method names are parsed from the url, but if the URL doesn't have any paths with a valid method name, an invalid method name will be used.
- Sometimes when copying from the browser, important headers aren't included which causes the resulting API wrapper to fail requests.
- Parsing multipart/form-data when copying with the powershell mode isn't supported
🐞 Contributing
see CONTRIBUTING.md
📅 # TODO
- unit tests w/ pytest
- clean up cli
- replace --compare with --diff which shows diffs in console
- better output w/ rich
- possibly decouple method & class ?
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
autorequests-1.1.0.tar.gz
(14.5 kB
view hashes)
Built Distribution
Close
Hashes for autorequests-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 334772f6cdf6678c9a5c780f05762dce154864ed68e7ce466fe6989aaf4e735a |
|
MD5 | 959fa490a96c9d85471187c3cea0c641 |
|
BLAKE2b-256 | facd5069f4c03a6b60e52aafe857a20d5a2932634378f78a69a974f6ce8b8b89 |