Skip to main content

httpstat

screenshot

httpstat visualizes curl(1) statistics in a way of beauty and clarity.

It is a single file🌟 Python script that has no dependency👏 and is compatible with Python 3🍻.

Features

  • Beautiful terminal output — timing breakdown of DNS, TCP, TLS, server processing, and content transfer
  • Structured JSON output--format json / jsonl for machine consumption with a stable v1 schema
  • SLO threshold checking--slo total=500,connect=100 exits with code 4 on violation
  • Save results to file--save path.json for multi-step workflows
  • NO_COLOR support — respects the NO_COLOR convention

Installation

There are three ways to get httpstat:

  • Download the script directly: wget https://raw.githubusercontent.com/reorx/httpstat/master/httpstat.py

  • Through pip: pip install httpstat

  • Through homebrew (macOS only): brew install httpstat

For Windows users, @davecheney's Go version is suggested. → download link

Usage

Simply:

python httpstat.py httpbin.org/get

If installed through pip or brew, you can use httpstat as a command:

httpstat httpbin.org/get

cURL Options

Because httpstat is a wrapper of cURL, you can pass any cURL supported option after the url (except for -w, -D, -o, -s, -S which are already used by httpstat):

httpstat httpbin.org/post -X POST --data-urlencode "a=b" -v

Structured Output

Use --format (-f) to get machine-readable output:

httpstat httpbin.org/get --format json
{
  "schema_version": 1,
  "url": "httpbin.org/get",
  "ok": true,
  "exit_code": 0,
  "response": {
    "status_line": "HTTP/2 200",
    "status_code": 200,
    "remote_ip": "...",
    "remote_port": "443",
    "headers": {"Content-Type": "application/json", "Server": "nginx", "...": "..."}
  },
  "timings_ms": {
    "dns": 5, "connect": 10, "tls": 15,
    "server": 50, "transfer": 20, "total": 100,
    "namelookup": 5, "initial_connect": 15,
    "pretransfer": 30, "starttransfer": 80
  },
  "speed": { "download_kbs": 1234.5, "upload_kbs": 0.0 },
  "slo": null
}

Use --format jsonl for compact single-line JSON (useful for log pipelines).

SLO Thresholds

Check response times against thresholds. Exits with code 4 on violation:

httpstat httpbin.org/get --slo total=500,connect=100,ttfb=200

Supported keys: total, connect, ttfb (time to first byte), dns, tls.

In pretty mode, violations are printed in red at the end of the output. In JSON mode, violations appear in the slo field:

{
  "slo": {
    "pass": false,
    "violations": [
      { "key": "total", "threshold_ms": 500, "actual_ms": 823 }
    ]
  }
}

Save Results

Write structured JSON output to a file (works with any --format):

httpstat httpbin.org/get --save result.json
httpstat httpbin.org/get --format json --save result.json

Environment Variables

httpstat has a bunch of environment variables to control its behavior. Here are some usage demos, you can also run httpstat --help to see full explanation.

  • HTTPSTAT_SHOW_BODY

    Set to true to show response body in the output, note that body length is limited to 1023 bytes, will be truncated if exceeds. Default is false.

  • HTTPSTAT_SHOW_IP

    By default httpstat shows remote and local IP/port address. Set to false to disable this feature. Default is true.

  • HTTPSTAT_SHOW_SPEED

    Set to true to show download and upload speed. Default is false.

    HTTPSTAT_SHOW_SPEED=true httpstat http://cachefly.cachefly.net/10mb.test
    
    ...
    speed_download: 3193.3 KiB/s, speed_upload: 0.0 KiB/s
    
  • HTTPSTAT_SAVE_BODY

    By default httpstat stores body in a tmp file, set to false to disable this feature. Default is true

  • HTTPSTAT_CURL_BIN

    Indicate the cURL bin path to use. Default is curl from current shell $PATH.

    This exampe uses brew installed cURL to make HTTP2 request:

    HTTPSTAT_CURL_BIN=/usr/local/Cellar/curl/7.50.3/bin/curl httpstat https://http2.akamai.com/ --http2
    
    HTTP/2 200
    ...
    

    cURL must be compiled with nghttp2 to enable http2 feature (#12).

  • HTTPSTAT_METRICS_ONLY

    If set to true, httpstat will only output metrics in json format, this is useful if you want to parse the data instead of reading it.

    Note: This is kept for backward compatibility. Prefer --format json instead.

  • HTTPSTAT_DEBUG

    Set to true to see debugging logs. Default is false

  • NO_COLOR

    When set (to any value), disables all colored output. See no-color.org for the convention.

    NO_COLOR=1 httpstat httpbin.org/get
    

For convenience, you can export these environments in your .zshrc or .bashrc, example:

export HTTPSTAT_SHOW_IP=false
export HTTPSTAT_SHOW_SPEED=true
export HTTPSTAT_SAVE_BODY=false

Related Projects

Here are some implementations in various languages:

  • Go: davecheney/httpstat

    This is the Go alternative of httpstat, it's written in pure Go and relies no external programs. Choose it if you like solid binary executions (actually I do).

  • Go (library): tcnksm/go-httpstat

    Other than being a cli tool, this project is used as library to help debugging latency of HTTP requests in Go code, very thoughtful and useful, see more in this article

  • Bash: b4b4r07/httpstat

    This is what exactly I want to do at the very beginning, but gave up due to not confident in my bash skill, good job!

  • Node: yosuke-furukawa/httpstat

    b4b4r07 mentioned this in his article, could be used as a HTTP client also.

  • PHP: talhasch/php-httpstat

    The PHP implementation by @talhasch

Some code blocks in httpstat are copied from other projects of mine, have a look:

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httpstat-2.0.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httpstat-2.0.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file httpstat-2.0.0.tar.gz.

File metadata

  • Download URL: httpstat-2.0.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for httpstat-2.0.0.tar.gz
Algorithm Hash digest
SHA256 9fa2930aebadefabb301daff56962003f26a973dc3f114743fd509909c77a638
MD5 01cf22db729d6520aee5aa9ada7beac2
BLAKE2b-256 7d7d436692f99eb01c0af46aa6019a9d3f0977894e373334abb044f9a8721991

See more details on using hashes here.

File details

Details for the file httpstat-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: httpstat-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for httpstat-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37fcac6888dde9d34e99d5d486cb50225c8359daad931c36f1eb92838893f89c
MD5 a8fb1997bcf2d80826a472dbf2729874
BLAKE2b-256 7a02d51394d55e438da535743ed0650fa81dc23d2c8b86cc18a5ecb3199d4c32

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

1.3.2

2 files

1.3.1

1 file

1.2.1

2 files

1.2.0

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page