Converts Request objects to curl string
Project description
curlifier
░█████╗░██╗░░░██╗██████╗░██╗░░░░░██╗███████╗██╗███████╗██████╗░
██╔══██╗██║░░░██║██╔══██╗██║░░░░░██║██╔════╝██║██╔════╝██╔══██╗
██║░░╚═╝██║░░░██║██████╔╝██║░░░░░██║█████╗░░██║█████╗░░██████╔╝
██║░░██╗██║░░░██║██╔══██╗██║░░░░░██║██╔══╝░░██║██╔══╝░░██╔══██╗
╚█████╔╝╚██████╔╝██║░░██║███████╗██║██║░░░░░██║███████╗██║░░██║
░╚════╝░░╚═════╝░╚═╝░░╚═╝╚══════╝╚═╝╚═╝░░░░░╚═╝╚══════╝╚═╝░░╚═╝
Curlifier converts the Request and PreparedRequest objects of the Requests library into an executable curl command.
Installation
Curlifier is available on PyPI:
pip install curlifier
Dependencies
python (>=3.12, <4.0)requests (>=2.30.3, <3.0.0)
Usage
All you need is to import curlify.
For example:
>>> import requests
>>> from curlifier import curlify
>>> body = {'id': 1, 'name': 'Tima', 'age': 28}
>>> r = requests.post('https://httpbin.org/', json=body)
>>> curlify(r)
curl --request POST 'https://httpbin.org/' --header 'User-Agent: python-requests/2.32.3' --header 'Accept-Encoding: gzip, deflate' --header 'Accept: */*' --header 'Connection: keep-alive' --header 'Content-Type: application/json' --data '{"id": 1, "name": "Tima", "age": 28}'
If you use PraparedRequest, you can also specify it instead of the Response object:
>>> req = requests.Request('POST', 'https://httpbin.org/')
>>> r = req.prepare()
>>> curlify(prepared_request=r)
curl --request POST 'https://httpbin.org/'
If you want a short version of the curl command, you can specify it:
>>> body = {'id': 1, 'name': 'Tima', 'age': 28}
>>> r = requests.post('https://httpbin.org/', json=body)
>>> curlify(r, shorted=True)
curl -X POST 'https://httpbin.org/' -H 'User-Agent: python-requests/2.32.3' -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'Connection: keep-alive' -H 'Content-Type: application/json' -d '{"id": 1, "name": "Tima", "age": 28}'
You can also specify the configuration when forming the curl command:
>>> curlify(r, location=True, verbose=True, silent=True, insecure=True, include=True)
curl --request POST 'https://httpbin.org/' --header 'User-Agent: python-requests/2.32.3' --header 'Accept-Encoding: gzip, deflate' --header 'Accept: */*' --header 'Connection: keep-alive' --header 'Content-Type: application/json' --data '{"id": 1, "name": "Tima", "age": 28}' --location --verbose --silent --insecure --include
- location (bool) - Follow redirects (default: False)
- verbose (bool) - Verbose output (default: False)
- silent (bool) - Silent mode (default: False)
- insecure (bool) - Allow insecure connections (default: False)
- include (bool) - Include protocol headers (default: False)
License
Curlifier is released under the MIT License. See the bundled LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file curlifier-0.1.5.tar.gz.
File metadata
- Download URL: curlifier-0.1.5.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7eddfe8ce0149744b4ccfd7f8a45b76a70519b0c9f12d42239133853571f0500
|
|
| MD5 |
d8b26a1d1966e2a5259b431751aae673
|
|
| BLAKE2b-256 |
61ef57948c7c51dc322daf28205b851cd21552b214141f4da98f6af769ebd854
|
File details
Details for the file curlifier-0.1.5-py3-none-any.whl.
File metadata
- Download URL: curlifier-0.1.5-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4698220acd5cdc1d1874011a914ea76036e1d88d4b1c3d49d6f1602789fdfcd
|
|
| MD5 |
397a9c5f1e17498710c6c51b728e56c0
|
|
| BLAKE2b-256 |
744fdb8b9017f5e0f273d7217f256247ce6941f4e7019089fefc77d98909caa8
|