{"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":"python","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,"search_vec":"'0.10.2':56 'activ':58 'api':88 'back':28 'client':29,45 'code':34 'concept':52 'current':54 'data':38 'debug':46,87 'due':80 'dynam':37 'echo':27 'endpoint':25 'flask':21,90 'fork':75 'foundat':64 'header':35 'http':1,12,44,50,83 'httpbin':6 'implement':17 'inact':82 'includ':72 'invalu':41 'maintain':59,79 'major':74 'make':39 'open':10 'open-sourc':9 'origin':78 'protocol':51 'provid':23 'psf':65 'python':19,62 'recent':70 'releas':71 'request':2,13,30 'respons':4,15 'return':31 'seen':68 'server':86 'servic':5,16,85 'sever':69 'softwar':63 'sourc':11 'specif':32 'status':33 'test':43,84 'understand':49 'use':20 'various':24 'version':55 'webhook':47 'wsgi':89","created_at":"2026-04-15T05:34:34.013263+00:00","updated_at":"2026-04-16T15:37:17.384476+00:00","problems":[{"fix":"To make HTTP requests to the `httpbin` service, use an HTTP client library like `requests` and direct your requests to `httpbin.org` or your own deployed `httpbin` instance. If you intend to run the `httpbin` *service* locally, you should typically use Docker or install it and run it with a WSGI server like Gunicorn, not `import httpbin` in your client code. \n```python\nimport requests\nresponse = requests.get('https://httpbin.org/get')\nprint(response.json())\n```","cause":"Developers often mistake `httpbin` for a client-side Python library to be imported directly to make HTTP requests, rather than understanding it primarily as a web service (httpbin.org) or a Flask application to be run locally.","error":"ModuleNotFoundError: No module named 'httpbin'"},{"fix":"Ensure you are using the correct and up-to-date Docker image for `httpbin` (e.g., `ghcr.io/psf/httpbin` or `kennethreitz/httpbin`). If building your own image, verify that `gunicorn` is installed and accessible within the container's environment. For instance, pull the latest official image: \n```bash\ndocker pull ghcr.io/psf/httpbin\ndocker run -p 80:8080 ghcr.io/psf/httpbin\n```","cause":"This error commonly occurs when running `httpbin` via Docker or a similar containerization technology, indicating that the `gunicorn` web server, which `httpbin` uses, is not found in the container's executable path, often due to an outdated or corrupted image, or incorrect Dockerfile/compose configuration.","error":"exec: \"gunicorn\": executable file not found in $PATH: unknown"},{"fix":"Increase the timeout value in your request or handle the `ReadTimeout` exception gracefully. If using a `/delay` endpoint, adjust the delay or your client's timeout accordingly. Ensure stable network connectivity and consider using a local `httpbin` instance for critical testing. \n```python\nimport requests\n\ntry:\n    response = requests.get('https://httpbin.org/delay/5', timeout=10) # Increased timeout\n    print(response.json())\nexcept requests.exceptions.ReadTimeout:\n    print(\"Request timed out after 10 seconds.\")\n```","cause":"This exception arises when an HTTP client, such as Python's `requests` library, attempts to communicate with `httpbin.org` (or a local instance) but the server does not send any data back within the specified timeout period, often due to network issues, high server load, or intentionally delayed responses from `httpbin` endpoints like `/delay`.","error":"requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='httpbin.org', port=443): Read timed out."},{"fix":"Verify the URL path you are requesting against the available `httpbin` endpoints. Double-check for any typos. If you are running a custom Flask application based on `httpbin`, ensure all routes are correctly defined and accessible. For instance, to access the `/get` endpoint: \n```python\nimport requests\n# Assuming httpbin is running locally on default port 8080\nresponse = requests.get('http://localhost:8080/get')\nprint(response.json())\n```","cause":"When running a local `httpbin` instance (which is built on Flask/Werkzeug), this error indicates that the client requested an endpoint or URL path that does not exist or is not recognized by the `httpbin` application. This can happen due to typos in the URL or trying to access an endpoint that isn't part of the standard `httpbin` API.","error":"werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.10.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/psf/httpbin","docs":null,"changelog":null,"pypi":"https://pypi.org/project/httpbin/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","testing","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}