Convert Requests request objects to curl commands.
Project Links
Meta
Author: Egor Orlov
Requires Python: >=3.7
Classifiers
Environment
- Web Environment
Intended Audience
- Developers
License
- OSI Approved :: MIT License
Operating System
- OS Independent
Programming Language
- Python
- Python :: 3
- Python :: 3 :: Only
Topic
- Internet :: WWW/HTTP
- Internet :: WWW/HTTP :: Dynamic Content
Curlify - convert Python Requests request object to cURL command
Installation
pip install curlify
Changes
v3.0.0
- Remove Python 2 compatibility
- Add
prettyparameter to enable generating a multi-line command - Don't add
-Xwhen it's unnecessary - Correctly send empty headers
- Don't generate
--datathat would read a file - Don't sort headers, their order is deterministic on Python 3.7+
v2.2.0
- Fixed shell quotes. Fixed posting CSV file. Thanks to @leNEKO
v2.1.1
- Add
--insecureflag ifverifyparameter is notTrue
v2.1.0
- Fixed body rendering when using
jsonparam to request function.
v2.0.1
- Added
compressedparameter toto_curlfunction, if it is needed to add--compressedoption to generated cURL command.
v2.0
- Skip
-doption if request body is empty https://github.com/ofw/curlify/issues/6 - Minor changes to header sorting
v1.2
- Order of headers is deterministic (thanks to @tomviner)
Example
import curlify
import requests
response = requests.get("http://google.ru")
print(curlify.to_curl(response.request))
# curl -X 'GET' -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'User-Agent: python-requests/2.18.4' 'http://www.google.ru/'
print(curlify.to_curl(response.request, compressed=True))
# curl -X 'GET' -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'User-Agent: python-requests/2.18.4' --compressed 'http://www.google.ru/'
3.0.0
May 25, 2025
2.2.1
Jul 21, 2019
2.2.0
Jul 21, 2019
2.1.1
Jan 03, 2019
2.1.0
Aug 13, 2018
2.0.1
Mar 19, 2018
2.0
Mar 19, 2018
1.2.1
Sep 02, 2016
1.2
Aug 23, 2016
1.1
Aug 15, 2016
1.0
Aug 15, 2016
Wheel compatibility matrix
Files in release
Extras:
None
Dependencies:
requests