{"id":6375,"library":"httpbin","title":"HTTP Request and Response Service","description":"httpbin is an open-source HTTP request and response service, implemented in Python using Flask. It provides various endpoints that echo back client requests, return specific status codes, headers, or dynamic data, making it invaluable for testing HTTP clients, debugging webhooks, and understanding HTTP protocol concepts. The current version, 0.10.2, is actively maintained by the Python Software Foundation (PSF) and has seen several recent releases, including a major fork from its original maintainer due to inactivity.","status":"active","version":"0.10.2","language":"en","source_language":"en","source_url":"https://github.com/psf/httpbin","tags":["http","testing","service","server","debug","api","wsgi","flask"],"install":[{"cmd":"pip install httpbin","lang":"bash","label":"Install base package"},{"cmd":"pip install 'httpbin[mainapp]'","lang":"bash","label":"Install with main application dependencies"}],"dependencies":[{"reason":"Core web framework for the httpbin application.","package":"Flask","optional":false},{"reason":"Commonly used WSGI HTTP server to run httpbin as a standalone service.","package":"gunicorn","optional":true}],"imports":[{"note":"Used when running httpbin as a WSGI application via a server like Gunicorn.","symbol":"app","correct":"from httpbin import app"}],"quickstart":{"code":"import os\n\n# To run httpbin as a standalone WSGI application using Gunicorn:\n# 1. Ensure you have httpbin installed with the 'mainapp' extra:\n#    pip install 'httpbin[mainapp]' gunicorn\n# 2. Run the following command in your terminal:\n#    gunicorn httpbin:app\n\n# Alternatively, for a simple direct run (for development/testing):\n# 1. Ensure httpbin is installed:\n#    pip install httpbin\n# 2. Run the following command in your terminal:\n#    python -m httpbin.core\n\n# Example of interacting with a running httpbin instance (using requests library):\n# (This code is for demonstration, it interacts with httpbin.org, not your local instance)\nimport requests\n\nbase_url = \"https://httpbin.org\"\n\n# Make a GET request and inspect the response\nresponse_get = requests.get(f\"{base_url}/get?key=value\")\nprint(f\"GET Status: {response_get.status_code}\")\nprint(f\"GET JSON: {response_get.json()['args']}\")\n\n# Make a POST request with JSON data\npost_data = {\"name\": \"test\", \"id\": 123}\nresponse_post = requests.post(f\"{base_url}/post\", json=post_data)\nprint(f\"POST Status: {response_post.status_code}\")\nprint(f\"POST JSON: {response_post.json()['json']}\")\n","lang":"python","description":"To use httpbin, you typically run it as a WSGI application. The most common way is with a WSGI server like Gunicorn, which serves the `httpbin:app` object. For development or quick testing, you can also run it directly as a module. The provided code includes instructions for both running the service and a Python example (using the 'requests' library) demonstrating how to interact with an httpbin instance, typically the public httpbin.org service."},"warnings":[{"fix":"Be aware of the distinction. For critical testing, consider running a local instance of httpbin from the PSF package instead of relying on the public httpbin.org service.","message":"The `httpbin` PyPI package (maintained by PSF) is a fork and is NOT the backend for the public service `httpbin.org` (which is run by Postman Labs). Users often confuse the two, leading to potential discrepancies between local test environments and public service behavior.","severity":"gotcha","affected_versions":"All versions since the fork (0.10.0+)"},{"fix":"For robust and reliable testing, it is highly recommended to run a local `httpbin` instance (using the PyPI package) within your testing environment, for example, using `pytest-httpbin` or by deploying it with Gunicorn.","message":"Relying on the public `httpbin.org` service for automated tests can lead to intermittent failures due to network latency, server load, or unexpected changes in `httpbin.org`'s responses (e.g., occasional HTTP vs. HTTPS inconsistencies).","severity":"gotcha","affected_versions":"N/A (applies to external usage of httpbin.org)"},{"fix":"Always install with `pip install 'httpbin[mainapp]'` if you intend to run it as a service or application. If using Gunicorn, ensure Gunicorn is also installed separately.","message":"To run `httpbin` as a standalone application, you must install it with the `mainapp` extra (e.g., `pip install 'httpbin[mainapp]'`). A basic `pip install httpbin` might not include all necessary dependencies for direct execution or WSGI deployment.","severity":"gotcha","affected_versions":"0.10.0+"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}