Curlify

3.0.0 · active · verified Thu Apr 09

Curlify is a Python library that converts `requests` request objects into equivalent cURL commands. This is particularly useful for debugging network requests by quickly generating a cURL command that can be executed directly in a terminal. The current version is 3.0.0, and it maintains an active release cadence, primarily focusing on Python version compatibility and minor enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a `requests.Request` object, prepare it using `.prepare()`, and then convert the resulting `PreparedRequest` object into a cURL command string using `curlify`.

import requests
from curlify import curlify

# Create a requests.Request object
r = requests.Request(
    'GET', 
    'http://httpbin.org/get',
    headers={'User-Agent': 'curlify-test-agent'},
    params={'key': 'value'},
    data={'body_key': 'body_value'}
)

# Prepare the request to get a PreparedRequest object
prepared_request = r.prepare()

# Convert the prepared request to a curl command
curl_command = curlify(prepared_request)
print(f"Generated cURL command:\n{curl_command}")

view raw JSON →