A golang port of the venerable httpbin.org HTTP request & response testing service.
Note: All endpoints accept an optional ?response_delay=<duration> query parameter to add an initial delay before responding (e.g. ?response_delay=2s or ?response_delay=1-5 for a random delay).
/ This page./absolute-redirect/:n 302 Absolute redirects n times./anything/:anything Returns anything that is passed to request./base64/:value?content-type=ct Decodes a Base64-encoded string, with optional Content-Type./base64/decode/:value?content-type=ct Explicit URL for decoding a Base64 encoded string./base64/encode/:value Encodes a string into URL-safe Base64./basic-auth/:user/:password Challenges HTTPBasic Auth./bearer Checks Bearer token header - returns 401 if not set./brotli Returns brotli-encoded data. Not implemented!/bytes/:n Generates n random bytes of binary data, accepts optional seed integer parameter./cache Returns 200 unless an If-Modified-Since or If-None-Match header is provided, when it returns a 304./cache/:n Sets a Cache-Control header for n seconds./close?mode=clean|reset&after=headers|partial Closes the connection abruptly, optionally after sending headers or partial data./cookies Returns cookie data./cookies/delete?name Deletes one or more simple cookies./cookies/set?name=value Sets one or more simple cookies./deflate Returns deflate-encoded data./delay/:n Delays responding for min(n, 10) seconds. Supports range syntax like 2-8 for random delays./delete Returns request data. Allows only DELETE requests./deny Denied by robots.txt file./digest-auth/:qop/:user/:password Challenges HTTP Digest Auth using default MD5 algorithm/digest-auth/:qop/:user/:password/:algorithm Challenges HTTP Digest Auth using specified algorithm (MD5 or SHA-256)/drip?numbytes=n&duration=s&delay=s&code=code Drips data over the given duration after an optional initial delay, simulating a slow HTTP server./dump/request Returns the given request in its HTTP/1.x wire approximate representation./echo Echoes the request body back with the same Content-Type. Allows POST, PUT, PATCH./encoding/utf8 Returns page containing UTF-8 data./env Returns all environment variables named with HTTPBIN_ENV_ prefix./etag/:etag Assumes the resource has the given etag and responds to If-None-Match header with a 200 or 304 and If-Match with a 200 or 412 as appropriate./forms/post HTML form that submits to /post/get Returns GET data./gzip Returns gzip-encoded data./head Returns response headers. Allows only HEAD requests./headers Returns request header dict./hidden-basic-auth/:user/:password 404'd BasicAuth./html Renders an HTML Page./hostname Returns the name of the host serving the request./image Returns page containing an image based on sent Accept header. Accepts ?size=small|medium|large, ?gradient=preset, ?color1=hex&color2=hex, ?noise=0-255, ?nocache=1./image/avif Returns an AVIF image./image/jpeg Returns a JPEG image. Accepts ?size=small|medium|large./image/png Returns a PNG image. Accepts ?size=small|medium|large./image/svg Returns a SVG image./image/webp Returns a WEBP image./image/photo.{ext} Returns an image based on file extension (.png, .jpeg, .jpg, .svg, .webp, .avif)./image/size/{small|medium|large}/filename.{ext} Returns a generated image of the given size./image/gradient/{preset}/size/{size}/filename.{ext} Returns a generated image with a gradient preset (warm, cool, sunset, forest, ocean, grayscale, neon)./image/no-cache/.../filename.{ext} Returns a unique (uncached) generated image./ip Returns Origin IP./json Returns JSON./links/:n Returns page containing n HTML links./mix/s=:code/h=:header:value/d=:delay/b64=:body Composable endpoint that combines status code, headers, delays, and body in a single URL./negotiate Performs content negotiation based on the Accept header./patch Returns request data. Allows only PATCH requests./pdf?pages=n&size=small|medium|large&seed=int&nocache=1 Returns a dynamically generated PDF document. pages (1-100, default 1), size (content density), seed (deterministic, default 42), nocache or no-cache (unique each time)./post Returns request data. Allows only POST requests./put Returns request data. Allows only PUT requests./problem?status=:code&title=:title&detail=:detail Returns a Problem Details (RFC 9457) JSON response. Pipeline-compatible: /status/422/problem?title=Test sets both HTTP and JSON status./range/1024?duration=s&chunk_size=code Streams n bytes, and allows specifying a Range header to select a subset of the data. Accepts a chunk_size and request duration parameter./redirect-to?url=foo&status_code=307 307 Redirects to the foo URL./redirect-to?url=foo 302 Redirects to the foo URL./redirect/:n 302 Redirects n times./relative-redirect/:n 302 Relative redirects n times./response-headers?key=val Returns given response headers./robots.txt Returns some robots.txt rules./sse?delay=1s&duration=5s&count=10&event=name&retry=ms&fail_after=n a stream of server-sent events./status/:code Returns given HTTP Status code./stream-bytes/:n Streams n random bytes of binary data, accepts optional seed and chunk_size integer parameters./stream/:n Streams min(n, 100) lines./trailers?key=val Returns JSON response with query params added as HTTP Trailers./unstable Fails half the time, accepts optional failure_rate float and seed integer parameters./upload Discards the body of POST/PUT/PATCH requests, for testing upload performance./user-agent Returns user-agent./uuid Generates a UUIDv4 value./version Returns the version of the go-httpbin instance. Pipeline-compatible (e.g. /delay/1/version)./websocket/echo?max_fragment_size=2048&max_message_size=10240 A WebSocket echo service./xml Returns some XMLTesting an HTTP Library can become difficult sometimes. RequestBin is fantastic for testing POST requests, but doesn't let you control the response. This exists to cover all kinds of HTTP scenarios. Additional endpoints are being considered.
All endpoint responses are JSON-encoded.
{"origin":"73.238.9.52, 77.83.142.42"}
{"user-agent":"curl/7.64.1"}
{
"args": {
"foo": [
"bar"
]
},
"headers": {
"Accept": [
"*/*"
],
"Host": [
"localhost:8080"
],
"User-Agent": [
"curl/7.64.1"
]
},
"origin": "73.238.9.52, 77.83.142.42",
"url": "http://localhost:8080/get?foo=bar"
}
GET /dump/request?foo=bar HTTP/1.1
Host: localhost:8080
Accept: */*
User-Agent: curl/7.64.1
HTTP/1.1 418 I'm a teapot
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
X-More-Info: http://tools.ietf.org/html/rfc2324
Date: Tue, 13 Jul 2021 13:12:37 GMT
Content-Length: 0
{"version":"abc1234","go_version":"go1.26"}
# Downloads a 3-page large PDF document
{"type":"about:blank","title":"Validation Failed","status":422,"detail":""}
hello
Chain operations directly in the URL path. Prefix any endpoint with one or more modifiers to compose behavior, then specify a terminal endpoint.
delay/:duration — Add a delay (e.g. delay/1, delay/500ms, delay/2-4 for random range)response_delay/:duration — Same as delay (alternative name)status/:code — Override the response status codeheader/:name:value — Set a custom response header (X-* headers or allowlisted names)no-cache — Disable caching (equivalent to ?nocache=1)All single endpoints work as terminals. Grouped by category:
400 — Invalid modifier value, unknown segment, missing terminal405 — Wrong HTTP method for a method-restricted terminal (e.g. GET on /echo)501 — AVIF/WebP generation without conversion tools/delay/1/status/418 — Wait 1s, then return 418 I'm a Teapot/delay/500ms/get — Wait 500ms, then return request data/status/422/body/SGVsbG8= — Return "Hello" with status 422/header/X-Custom:test/status/201/get — Custom header + status override + GET data/delay/1/version — Wait 1s, then return version info/status/422/problem?title=Validation+Failed — HTTP 422 + coherent Problem Details JSON/delay/0/response-headers?X-Debug=true — Custom response headers via pipeline/status/201/pdf?pages=3 — 3-page PDF with status 201/header/X-Request-Id:abc/status/200/json — JSON with custom header and status/image/gradient/warm/size/small/photo.png — Warm gradient PNG image/image/no-cache/gradient/cool/size/small/photo.jpeg — Unique cool gradient JPEG/redirect/3/status/200 — Redirect 3 times, ending with status 200/delay/1/redirect/3/image/photo.png — Wait 1s, redirect 3 times, serve PNG image/delay/2-4/bytes/1024 — Random 2-4s delay, then 1024 random bytes/status/201/json — JSON with status 201/delay/500ms/status/503 — Wait 500ms + server error/header/X-Debug:true/uuid — UUID with custom header/delay/0/hostname — Hostname via pipeline/delay/0/negotiate — Content negotiation via pipeline/status/422/problem?title=Validation+Failed — Coherent Problem Details/no-cache/pdf?pages=3 — Unique PDF each time via pipeline modifier/pdf?pages=5&size=large&no-cache=1 — PDF with no-cache query param/delay/abc/get — 400 error: invalid delay value/delay/999/get — 400 error: delay exceeds maximumcurl to verify the response. This is a browser limitation, not a server bug.Ported to Go by Will McCutchen.
From the original Kenneth Reitz project.
httpbin.org — the original httpbin