Httpie

Page content

got in touch with httpie, a restapi client for the cli

install

doas pkg_add httpie

Hello World

let’s do a little test

$ https httpie.io/hello

HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: application/json; charset=utf-8
age: 0
cache-control: public, max-age=0, must-revalidate
content-length: 264
date: Wed, 10 Nov 2021 17:34:19 GMT
etag: "108-yw+Xn8xsGAsJIUMQvDLN7gAcQuc"
server: Vercel
strict-transport-security: max-age=63072000
x-matched-path: /api/hello
x-vercel-cache: MISS
x-vercel-id: fra1::iad1::4kmc7-1636565659646-cf763c94cea0

{
    "ahoy": [
        "Hello, World! 👋 Thank you for trying out HTTPie 🥳",
        "We hope this will become a friendship."
    ],
    "links": {
        "discord": "https://httpie.io/discord",
        "github": "https://github.com/httpie",
        "homepage": "https://httpie.io",
        "twitter": "https://twitter.com/httpie"
    }
}

Examples

Custom HTTP method, HTTP headers and JSON data:

$ http PUT pie.dev/put X-API-Token:123 name=John

HTTP/1.1 200 OK
CF-Cache-Status: DYNAMIC
CF-RAY: 6ac10a252a1f3759-MXP
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json
Date: Wed, 10 Nov 2021 17:35:50 GMT
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=JFP78HjVnpCxJ0aiHsO4DENHTxEZ9jQJfrK4zLVKum%2FLZyiZ2LxL4vjax7fA4sWYPYb8womDJIQ9BEfN8lRLzcAWPJaRJx1S2mMSjsALcS4%2B%2FQ98tpK4pUH0"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Transfer-Encoding: chunked
access-control-allow-credentials: true
access-control-allow-origin: *
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400

{
    "args": {},
    "data": "{\"name\": \"John\"}",
    "files": {},
    "form": {},
    "headers": {
        "Accept": "application/json, */*;q=0.5",
        "Accept-Encoding": "gzip",
        "Cdn-Loop": "cloudflare",
        "Cf-Connecting-Ip": "185.xx.xx.xx",
        "Cf-Ipcountry": "CH",
        "Cf-Ray": "6ac10a252a1f3759-FRA",
        "Cf-Visitor": "{\"scheme\":\"http\"}",
        "Connection": "Keep-Alive",
        "Content-Length": "16",
        "Content-Type": "application/json",
        "Host": "pie.dev",
        "User-Agent": "HTTPie/2.4.0",
        "X-Api-Token": "123"
    },
    "json": {
        "name": "John"
    },
    "origin": "185.xx.xx.xx",
    "url": "http://pie.dev/put"
}

Submitting forms:

$ http -f POST pie.dev/post hello=World

HTTP/1.1 200 OK
CF-Cache-Status: DYNAMIC
CF-RAY: 6ac10c5b0a486d7a-MUC
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json
Date: Wed, 10 Nov 2021 17:37:21 GMT
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=RbGs0xZw%2BIDZxbYEynmbhB%2BM%2FjyXKLs0l6yrwtyT4%2FhSg9562fIrQIBFytkjl4CR0%2Bagb6ZMvXxJtFuGsySeJl9WA%2BiZ8%2BjSYrsGrxotoceueYGcpF3TXR9b"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Transfer-Encoding: chunked
access-control-allow-credentials: true
access-control-allow-origin: *
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400

{
    "args": {},
    "data": "",
    "files": {},
    "form": {
        "hello": "World"
    },
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip",
        "Cdn-Loop": "cloudflare",
        "Cf-Connecting-Ip": "185.xx.xx.xx",
        "Cf-Ipcountry": "CH",
        "Cf-Ray": "6ac10c5b0a486d7a-FRA",
        "Cf-Visitor": "{\"scheme\":\"http\"}",
        "Connection": "Keep-Alive",
        "Content-Length": "11",
        "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
        "Host": "pie.dev",
        "User-Agent": "HTTPie/2.4.0"
    },
    "json": null,
    "origin": "185.xx.xx.xx",
    "url": "http://pie.dev/post"
}

Docs

Docs and more examples: https://httpie.io/docs


Any Comments ?

sha256: 38efa553dfa8b02e8c539e51119c762eb74fae2107b050d469152ebaa29aa9c3