curl transfer data from URLs

curl sends requests to URLs and prints the response. It supports every HTTP method, custom headers, authentication, file uploads and many other protocols, which makes it the standard tool for testing and scripting web APIs.

Availability Preinstalled on macOS, Windows 10+ and most Linux distributions

Syntax

curl [options] url

Common options

OptionWhat it does
-LFollow redirects
-sSilent: hide the progress bar
-fFail with an error on HTTP 4xx and 5xx responses
-o fileSave the response to a file (-O uses the remote name)
-IFetch only the response headers
-H 'Name: value'Add a request header
-X METHOD -d dataChoose the method and send a request body

Examples

Download a file

curl -L -o data.csv https://example.com/data.csv

Show only the headers

curl -sI https://example.com

Call a JSON API

curl -s -H 'Accept: application/json' https://api.github.com/repos/golang/go

POST JSON

curl -s -X POST -H 'Content-Type: application/json' -d '{"name":"sqx"}' https://httpbin.org/post

Use curl with sqx

Query an API response

A JSON array of objects becomes a table with one row per object.

curl -s https://api.github.com/repos/golang/go/releases | sqx "SELECT tag_name, published_at FROM stdin LIMIT 5"

Or let sqx fetch and cache it

-f accepts a URL directly. The response is cached, so re-running the query doesn't hit the API again. Use curl when you need auth headers or POST.

sqx -f releases=https://api.github.com/repos/golang/go/releases "SELECT tag_name, published_at FROM releases LIMIT 5"

Full documentation

This page covers the essentials. For every option, see the official documentation:

Or read the manual in your terminal: man curl