Skip to content

Latest commit

 

History

History
101 lines (79 loc) · 2.23 KB

httpie.md

File metadata and controls

101 lines (79 loc) · 2.23 KB
title category layout weight updated description
httpie
CLI
2017/sheet
-3
2020-07-05
$ http POST http://example.com name="John" Host:example.com — JSON, cookies, files, auth, and other httpie examples.

Introduction

{: .-intro}

HTTPie is a command-line HTTP client.

Parameters

$ http POST http://example.com/posts/3 \
    Origin:example.com \  # :   HTTP headers
    name="John Doe" \     # =   string
    q=="search" \         # ==  URL parameters (?q=search)
    age:=29 \             # :=  for non-strings
    list:='[1,3,4]' \     # :=  json
    [email protected] \       # @   attach file
    [email protected] \    # =@  read from file (text)
    user:[email protected]      # :=@ read from file (json)

Forms

$ http --form POST example.com \
    name="John Smith" \
    [email protected]

Raw JSON

$ echo '{"hello": "world"}' | http POST example.com/post

Options

Printing options

-v, --verbose            # same as --print=HhBb --all
-h, --headers            # same as --print=h
-b, --body               # same as --print=b
    --all                # print intermediate requests
    --print=HhBb         # H: request headers
                         # B: request body
                         # h: response headers
                         # b: response body
    --pretty=none        # all | colors | format
    --json | -j          # Response is serialized as a JSON object.

Authentication

    --session NAME
-a, --auth USER:PASS
    --auth-type basic
    --auth-type digest

Session

    --session NAME       # store auth and cookies
    --session-read-only NAME

Downloading

-d, --download           # like wget
-c, --continue
-o, --output FILE

Others

-F, --follow             # follow redirects
    --max-redirects N    # maximum for --follow
    --timeout SECONDS
    --verify no          # skip SSL verification
    --proxy http:http://foo.bar:3128

References