kennethreitz.org / Software / Websites / Httpbin
httpbin.org
httpbin.org is a simple HTTP request and response service. It is a useful tool for testing HTTP clients and debugging webhooks. The service provides a variety of endpoints that return different types of data, such as headers, IP address, and user-agent.
Features
- HTTP Methods: httpbin.org supports various HTTP methods, including GET, POST, PUT, DELETE, and PATCH, allowing you to test different types of requests.
- Request Inspection: The service allows you to inspect the details of the incoming request, such as headers, query parameters, and body content.
- Response Formats: httpbin.org can return responses in different formats, such as JSON, HTML, and images, enabling you to test how your client handles different content types.
- Status Codes: The service can return specific HTTP status codes, such as 200 OK, 404 Not Found, and 500 Internal Server Error, allowing you to test error handling in your client.
- Authentication: httpbin.org supports basic authentication, allowing you to test how your client handles authenticated requests.
- Dynamic Data: The service can generate dynamic data, such as random JSON responses or images of a specified size, enabling you to test edge cases in your client.
Running with Docker
You can also run httpbin.org locally using Docker. First, pull the httpbin image from Docker Hub:
$ docker pull kennethreitz/httpbin
Then, run the httpbin container:
$ docker run -p 80:80 kennethreitz/httpbin
This will start the httpbin service on port 80 of your local machine, allowing you to interact with it using your HTTP client of choice.
Usage
You can interact with httpbin.org using various HTTP clients, such as cURL, Python requests, or Postman. Here are some examples of how you can use the service:
GET Request
To make a GET request to httpbin.org, you can use cURL:
$ curl https://httpbin.org/get
This will return a JSON response containing details of the request, such as headers, origin, and URL.
POST Request
To make a POST request to httpbin.org with data, you can use cURL:
$ curl -X POST https://httpbin.org/post -d "key1=value1&key2=value2"
This will return a JSON response containing the data you posted.
Authentication
To make an authenticated request to httpbin.org, you can use cURL with basic authentication:
$ curl -u username:password https://httpbin.org/basic-auth/username/password
This will return a JSON response indicating whether the authentication was successful.