Skip to main content

Converts Request objects to curl string

Project description

curlifier

codecov tests pypi package version status pypi downloads supported python versions wemake-python-styleguide mypy ruff license

Curlifier logo

Converts the Request and PreparedRequest objects of the Requests library into an executable curl command.

Installation

pip install curlifier

⚠️ Security Warning ⚠️

The resulting curl command will include all authentication credentials, API keys, passwords, and other sensitive information that were part of the original request. Be careful when sharing or logging these commands, as they may expose sensitive data.

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 'Content-Type: application/json' --data '{"id": 1, "name": "Tima", "age": 28}'

If you use PreparedRequest, 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 '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, insecure=True)
curl --request POST 'https://httpbin.org/' <...> --header 'Content-Type: application/json' --data '{"id": 1, "name": "Tima", "age": 28}' --location --insecure
  • 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.

The logo was created using Font Meme.

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

curlifier-1.0.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

curlifier-1.0.1-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file curlifier-1.0.1.tar.gz.

File metadata

  • Download URL: curlifier-1.0.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/23.6.0

File hashes

Hashes for curlifier-1.0.1.tar.gz
Algorithm Hash digest
SHA256 df3b43223757ce24c00d473d34bdb4249635eb2ae7f7a24dd78454969487094a
MD5 0c003499e5d2ff5b9e0d98a2bf24bda3
BLAKE2b-256 eff585b9b690dd5e1501722802d1fe877f5b227047f5dbe7900929e888956218

See more details on using hashes here.

File details

Details for the file curlifier-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: curlifier-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/23.6.0

File hashes

Hashes for curlifier-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5185a2f80f13bc1a1915754f3399c709d1cc5e728a6c5aa89c4873a17cdf434
MD5 2783a6229f039700beea3bd23e79aca2
BLAKE2b-256 cd907827301de818f7c1924de1c906eeaf6babe091ef9babc87dc52c07aefd6b

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