curl

Transfer data over HTTP, HTTPS, FTP and more

About

curl is the transfer tool most people script when downloading a file or calling an API. It speaks HTTP, HTTPS, FTP, SFTP and dozens of other protocols. It ships with Termux and nearly every other system.

Install it

pkg install curl

Run this inside Termux. If the package is already present, pkg will say so and do nothing.

Commands worth knowing

6 of the invocations you will actually reach for. Tap the copy button to put one on your clipboard.

curl -i https://example.com Fetch a page and show the headers alongside the body. Reveals status codes and caching directives.
curl -O https://example.com/file.zip Download a file and save it under the name the server suggests.
curl -L -o page.html https://example.com Follow redirects and write the result to a chosen filename. The usual way to grab a page for offline reading.
curl -X POST -d "a=1&b=2" https://example.com/api Send form data to an endpoint with a POST request. The quickest way to exercise an API you are testing.
curl -H "Authorization: Bearer TOKEN" https://example.com/api Add an authentication header for a protected endpoint.
curl -s -o /dev/null -w "%{http_code}" https://example.com Print only the HTTP status code. Handy for a script that watches a site.

Worked example

Run curl -i https://example.com and this is what you should see.

termux
$ curl -i https://example.com
HTTP/1.1 200 OK
content-type: text/html; charset=UTF-8
server: nginx/1.24.0

<!doctype html>
<html lang="en">

Developed by

Daniel Stenberg and the project contributors .