httpbin.org

0.9.2

[ Base URL: httpbin.org/ ]

A simple HTTP Request & Response Service.

$ docker run -p 80:80 kennethreitz/httpbin
Developer: Kenneth Reitz Contact: me@kennethreitz.org [Powered by Flasgger]

API Endpoints

Browse every endpoint group below. Open Try it out to see a sample request and response.

HTTP Methods

Testing different HTTP verbs

5 endpoints
get /get

Returns GET data.

200
Try it out

Request

curl https://httpbin.org/get

Response

HTTP/1.1 200 OK{
  "args": {},
  "headers": { "Host": "httpbin.org" },
  "origin": "203.0.113.1",
  "url": "https://httpbin.org/get"
}
post /post

Returns POST data.

200
Try it out

Request

curl -X POST https://httpbin.org/post -d "hello=world"

Response

HTTP/1.1 200 OK{
  "form": { "hello": "world" },
  "url": "https://httpbin.org/post"
}
put /put

Returns PUT data.

200
Try it out

Request

curl -X PUT https://httpbin.org/put -d "hello=world"

Response

HTTP/1.1 200 OK{
  "form": { "hello": "world" },
  "url": "https://httpbin.org/put"
}
patch /patch

Returns PATCH data.

200
Try it out

Request

curl -X PATCH https://httpbin.org/patch -d "hello=world"

Response

HTTP/1.1 200 OK{
  "form": { "hello": "world" },
  "url": "https://httpbin.org/patch"
}
delete /delete

Returns DELETE data.

200
Try it out

Request

curl -X DELETE https://httpbin.org/delete

Response

HTTP/1.1 200 OK{
  "args": {},
  "url": "https://httpbin.org/delete"
}

Auth

Auth methods

4 endpoints
get /basic-auth/{user}/{passwd}

Challenges HTTPBasic Auth.

Try it out

Request

curl -u user:passwd https://httpbin.org/basic-auth/user/passwd

Response

HTTP/1.1 200 OK{
  "authenticated": true,
  "user": "user"
}
get /bearer

Checks Bearer token header.

Try it out

Request

curl -H "Authorization: Bearer demo" https://httpbin.org/bearer

Response

HTTP/1.1 200 OK{
  "authenticated": true,
  "token": "demo"
}
get /digest-auth/{qop}/{user}/{passwd}

Challenges HTTP Digest Auth.

Try it out

Request

curl --digest -u user:passwd https://httpbin.org/digest-auth/auth/user/passwd

Response

HTTP/1.1 200 OK{
  "authenticated": true,
  "user": "user"
}
get /hidden-basic-auth/{user}/{passwd}

404 on success, 200 otherwise.

Try it out

Request

curl -u user:passwd https://httpbin.org/hidden-basic-auth/user/passwd

Response

HTTP/1.1 404 NOT FOUND{
  "authenticated": true,
  "user": "user"
}

Status codes

Codes for testing different statuses

1 endpoint
get /status/{codes}

Return status code or a random one.

Try it out

Request

curl -i https://httpbin.org/status/418

Response

HTTP/1.1 418 I'M A TEAPOT-

Request inspection

Inspect the client's request

3 endpoints
get /headers

Return header dict.

Try it out

Request

curl https://httpbin.org/headers

Response

HTTP/1.1 200 OK{
  "headers": {
    "Host": "httpbin.org",
    "User-Agent": "curl/8.0"
  }
}
get /ip

Returns origin IP.

Try it out

Request

curl https://httpbin.org/ip

Response

HTTP/1.1 200 OK{
  "origin": "203.0.113.1"
}
get /user-agent

Returns user-agent.

Try it out

Request

curl https://httpbin.org/user-agent

Response

HTTP/1.1 200 OK{
  "user-agent": "curl/8.0"
}

Response inspection

Inspect the response

4 endpoints
get /cache

304 if If-Modified-Since was sent.

Try it out

Request

curl -H "If-Modified-Since: Mon, 01 Jan 2024 00:00:00 GMT" https://httpbin.org/cache

Response

HTTP/1.1 304 NOT MODIFIED-
get /cache/{value}

Sets Cache-Control to value seconds.

Try it out

Request

curl -i https://httpbin.org/cache/60

Response

HTTP/1.1 200 OKCache-Control: max-age=60
get /etag/{etag}

Assumes etag and checks request headers.

Try it out

Request

curl -i -H 'If-None-Match: "abc"' https://httpbin.org/etag/abc

Response

HTTP/1.1 304 NOT MODIFIED-
get /response-headers

Returns response headers from query params.

Try it out

Request

curl "https://httpbin.org/response-headers?X-Demo=yes"

Response

HTTP/1.1 200 OK{
  "X-Demo": "yes"
}

Response formats

Different response formats

5 endpoints
get /html

Returns a simple HTML page.

Try it out

Request

curl https://httpbin.org/html

Response

HTTP/1.1 200 OK<!DOCTYPE html>
<html><head></head>
<body><h1>Herman Melville - Moby-Dick</h1></body></html>
get /json

Returns sample JSON data.

Try it out

Request

curl https://httpbin.org/json

Response

HTTP/1.1 200 OK{
  "slideshow": { "title": "Sample Slide Show" }
}
get /robots.txt

Returns some robots.txt rules.

Try it out

Request

curl https://httpbin.org/robots.txt

Response

HTTP/1.1 200 OKUser-agent: *
Disallow: /deny
get /xml

Returns a simple XML document.

Try it out

Request

curl https://httpbin.org/xml

Response

HTTP/1.1 200 OK<?xml version="1.0" encoding="UTF-8"?>
<slideshow title="Sample Slide Show"></slideshow>
get /deny

A denied message from robots.txt.

Try it out

Request

curl https://httpbin.org/deny

Response

HTTP/1.1 200 OKUser-agent: *
Disallow: /deny

Dynamic data

Generates random data

8 endpoints
get /base64/{value}

Decodes a Base64 encoded string.

Try it out

Request

curl https://httpbin.org/base64/SFRUUEJJTiBpcyBhd2Vzb21l

Response

HTTP/1.1 200 OKHTTPBIN is awesome
get /bytes/{n}

Returns n random bytes.

Try it out

Request

curl https://httpbin.org/bytes/16

Response

HTTP/1.1 200 OKContent-Type: application/octet-stream
(16 random bytes)
get /delay/{n}

Returns response after n seconds.

Try it out

Request

curl https://httpbin.org/delay/2

Response

HTTP/1.1 200 OK{
  "args": {},
  "url": "https://httpbin.org/delay/2"
}
get /drip

Streams data over a duration.

Try it out

Request

curl "https://httpbin.org/drip?duration=2&numbytes=4"

Response

HTTP/1.1 200 OK(4 bytes streamed over 2 seconds)
get /links/{n}/{offset}

Returns a page containing n links.

Try it out

Request

curl https://httpbin.org/links/10/0

Response

HTTP/1.1 200 OK<html><body>... 10 links ...</body></html>
get /range/{n}

Streams n bytes honoring Range headers.

Try it out

Request

curl -H "Range: bytes=0-15" https://httpbin.org/range/256

Response

HTTP/1.1 206 PARTIAL CONTENT(16 bytes of 256)
get /stream-bytes/{n}

Streams n random bytes.

Try it out

Request

curl https://httpbin.org/stream-bytes/32

Response

HTTP/1.1 200 OKContent-Type: application/octet-stream
(32 streamed random bytes)
get /uuid

Returns a UUID4.

Try it out

Request

curl https://httpbin.org/uuid

Response

HTTP/1.1 200 OK{
  "uuid": "e1f0a2c4-1b3d-4e5f-8a9b-0c1d2e3f4a5b"
}

Cookies

Set and inspect cookies

3 endpoints
get /cookies

Returns cookie data.

Try it out

Request

curl -b "session=demo" https://httpbin.org/cookies

Response

HTTP/1.1 200 OK{
  "cookies": { "session": "demo" }
}
get /cookies/set

Sets cookies and redirects to /cookies.

Try it out

Request

curl -i "https://httpbin.org/cookies/set?session=demo"

Response

HTTP/1.1 302 FOUNDSet-Cookie: session=demo; Path=/
get /cookies/delete

Deletes cookies and redirects to /cookies.

Try it out

Request

curl -i "https://httpbin.org/cookies/delete?session"

Response

HTTP/1.1 302 FOUNDSet-Cookie: session=; Expires=Thu, 01 Jan 1970 00:00:00 GMT

Images

Images in different formats

5 endpoints
get /image

Returns a page containing an image.

Try it out

Request

curl -o page.html https://httpbin.org/image

Response

HTTP/1.1 200 OK<html><body>
<img src="https://httpbin.org/image/png"></body></html>
get /image/png

Returns a PNG image.

Try it out

Request

curl -o image.png https://httpbin.org/image/png

Response

HTTP/1.1 200 OKContent-Type: image/png
get /image/jpeg

Returns a JPEG image.

Try it out

Request

curl -o image.jpg https://httpbin.org/image/jpeg

Response

HTTP/1.1 200 OKContent-Type: image/jpeg
get /image/webp

Returns a WEBP image.

Try it out

Request

curl -o image.webp https://httpbin.org/image/webp

Response

HTTP/1.1 200 OKContent-Type: image/webp
get /image/svg

Returns an SVG image.

Try it out

Request

curl -o image.svg https://httpbin.org/image/svg

Response

HTTP/1.1 200 OKContent-Type: image/svg+xml

Redirects

Returns different redirect codes

4 endpoints
get /absolute-redirect/{n}

30x redirects to absolute URLs n times.

Try it out

Request

curl -i https://httpbin.org/absolute-redirect/2

Response

HTTP/1.1 302 FOUNDLocation: https://httpbin.org/absolute-redirect/1
get /redirect-to

Redirects to any URL from the url param.

Try it out

Request

curl -i "https://httpbin.org/redirect-to?url=https://httpbin.org/get"

Response

HTTP/1.1 302 FOUNDLocation: https://httpbin.org/get
get /redirect/{n}

30x redirects n times.

Try it out

Request

curl -L https://httpbin.org/redirect/3

Response

HTTP/1.1 302 FOUNDLocation: /relative-redirect/2
get /relative-redirect/{n}

30x relative redirects n times.

Try it out

Request

curl -L https://httpbin.org/relative-redirect/2

Response

HTTP/1.1 302 FOUNDLocation: /relative-redirect/1

Anything

Generates anything

2 endpoints
any /anything

Returns anything passed in the request.

Try it out

Request

curl -X POST https://httpbin.org/anything -d "hello=world"

Response

HTTP/1.1 200 OK{
  "method": "POST",
  "form": { "hello": "world" },
  "url": "https://httpbin.org/anything"
}
any /anything/{anything}

Returns anything passed in the request path.

Try it out

Request

curl https://httpbin.org/anything/demo

Response

HTTP/1.1 200 OK{
  "method": "GET",
  "url": "https://httpbin.org/anything/demo"
}

Other Utilities

A sample HTML form mirroring the /forms/post utility. Submitting posts the fields to /post.

Posted as form-encoded data.