Skip to main content

Converts Request objects to curl string

Project description

curlifier

coverage tests pypi package version pypi downloads supported python versions wemake-python-styleguide license

Curlifier logo

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

Installation

pip install curlifier

Dependencies

  • python (>=3.10, <4.0)
  • requests (>=2.0, <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 '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 '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-0.2.12.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

curlifier-0.2.12-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: curlifier-0.2.12.tar.gz
  • Upload date:
  • Size: 8.7 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-0.2.12.tar.gz
Algorithm Hash digest
SHA256 480a691cb5a3f3b7327522afb3bf646e53957eab1280548cae4a44f71661ab37
MD5 a857caf8dde258856b37b34cb2e91623
BLAKE2b-256 f0e3d90f6b55ba6af370a1ee844619f562da045608e3769759d1032e9d2556d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: curlifier-0.2.12-py3-none-any.whl
  • Upload date:
  • Size: 11.7 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-0.2.12-py3-none-any.whl
Algorithm Hash digest
SHA256 70ffe8a79ee024cfaecf27e10bcc49f916e1c52e20d467899d865e6e0d2c0093
MD5 3ac3b2a1aa21ab607c2afd53f9dfc04d
BLAKE2b-256 e5d9e6e6874c1f3acab06ea0047583c15763fa31c56ce4cd26dd669ff8fb76f5

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