Install & Compatibility
Where this runs
tested against v3.2.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 36.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.2s · import 0.000s · 37MB
38MB installed
● package 38MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
main
✓ from httpie import main
✗ from httpie import call_main
This quickstart demonstrates both the recommended way of using HTTPie programmatically (as a subprocess) and the experimental direct `call_main` API. The subprocess method provides stability and mimics standard CLI usage. Remember to set `HTTP_AUTH_TOKEN` in your environment for the auth example.
import subprocess
from httpie.core import call_main
# Recommended: Run HTTPie as a subprocess
print("--- Using subprocess (recommended) ---")
try:
result = subprocess.run(['http', 'https://httpbin.org/get', 'X-Auth-Token: ' + os.environ.get('HTTP_AUTH_TOKEN', 'none')], capture_output=True, text=True, check=True)
print(result.stdout)
except subprocess.CalledProcessError as e:
print(f"Subprocess failed: {e}\n{e.stderr}")
# Alternative: Use the internal call_main (API not guaranteed stable)
print("\n--- Using httpie.core.call_main (experimental) ---")
# Redirect stdout/stderr to capture output, as call_main prints directly
import io
import sys
old_stdout = sys.stdout
redirected_output = io.StringIO()
sys.stdout = redirected_output
try:
# call_main expects a list of CLI arguments
args = ['https://httpbin.org/post', 'hello=world', 'Content-Type: application/json']
status_code = call_main(args)
print(f"Call main exited with status: {status_code}")
print(redirected_output.getvalue())
finally:
sys.stdout = old_stdout # Restore stdout
# Example of setting an environment variable for a subprocess call
import os
os.environ['HTTP_TEST_VAR'] = 'test_value'
print("\n--- Subprocess with environment variable ---")
try:
result_env = subprocess.run(['http', 'https://httpbin.org/get', 'HTTP_TEST_VAR'], capture_output=True, text=True, check=True)
print(result_env.stdout)
except subprocess.CalledProcessError as e:
print(f"Subprocess failed: {e}\n{e.stderr}")
del os.environ['HTTP_TEST_VAR'] # Clean up
http --version
Debug
Known issues
breakingHTTPie v3.0.0 and later dropped support for Python 3.6. Users on older Python versions must upgrade Python or stick to HTTPie versions < 3.0.0.fixUpgrade Python to 3.7 or newer, or pin `httpie<3.0.0`.
affects: >=3.0.0
gotchaThe `httpie.core` programmatic API (e.g., `call_main`) is not officially stable and is subject to change between versions without a dedicated deprecation cycle. Direct programmatic interaction should be used with caution.fixFor stable programmatic integration, it is generally recommended to run HTTPie as a subprocess, parsing its standard output and error streams. This mirrors how the CLI is intended to be used.
affects: All
gotchaHTTPie has experienced issues with SSL connections and compatibility with underlying `requests` and `urllib3` versions in the past (e.g., 3.2.2, 3.2.3, 3.2.4 patches). While often resolved quickly, this indicates sensitivity to its core dependencies.fixEnsure you are running the latest patch release of HTTPie to benefit from the most recent dependency compatibility fixes. If encountering SSL issues, check the HTTPie GitHub releases for recent fixes.
affects: 3.2.2, 3.2.3, 3.2.4 (fixed in these respective versions)
deprecatedHTTPie v3.1.0 fixed a critical security vulnerability related to cookie exposure on redirects to third-party hosts. While fixed, relying on older versions could expose users to this vulnerability.fixUpgrade to HTTPie v3.1.0 or newer immediately to mitigate the cookie exposure vulnerability. Regularly update HTTPie to receive security patches.
affects: <3.1.0
Upgrade
Version history
3.2.4latest on PyPI · released Nov 1, 2024
Audit
Dependencies
requestsrequiredCore HTTP client functionality, subject to version-specific fixes in HTTPie releases.
urllib3requiredUnderlying HTTP connection pool management, also subject to compatibility fixes.