cURL チートシート
検索・印刷できる curl リファレンス——HTTP メソッド、ヘッダー、データとフォーム、認証、ダウンロード、cookie、TLS、プロキシ、デバッグ。無料。
基本
12curl https://api.example.com
GETリクエストを送りボディを表示
curl -o page.html https://example.com
レスポンスを指定ファイルに保存
curl -O https://example.com/file.zip
リモートのファイル名で保存
curl -i https://example.com
レスポンスヘッダーとボディを表示
curl -I https://example.com
レスポンスヘッダーのみ取得 (HEAD)
curl -v https://example.com
リクエスト/レスポンスの詳細出力
curl -s https://example.com
サイレントモード、進捗とエラーを非表示
curl -sS https://example.com
サイレントだがエラーは表示
curl -L https://example.com
HTTPリダイレクトを追跡 (3xx)
curl https://a.com https://b.com
1回の呼び出しで複数URLをリクエスト
curl 'https://x.com/p?[1-5]'
数値範囲でURLをループ
curl --version
curlのバージョンと機能を表示
HTTPメソッド
9curl -X GET https://api.example.com
明示的にGETリクエストを送信
curl -X POST https://api.example.com
POSTリクエストを送信
curl -X PUT https://api.example.com/1
リソース置換のPUTリクエストを送信
curl -X PATCH https://api.example.com/1
フィールド更新のPATCHリクエストを送信
curl -X DELETE https://api.example.com/1
DELETEリクエストを送信
curl -I https://api.example.com
ヘッダーのみのHEADリクエストを送信
curl -X OPTIONS https://api.example.com
OPTIONSプリフライトリクエストを送信
curl --head https://api.example.com
HEADリクエスト用 -I の長い形式
curl --request POST https://x.com
メソッド指定 -X の長い形式
ヘッダー
10curl -H 'Accept: application/json' https://x.com
単一のリクエストヘッダーを追加
curl -H 'X-Token: abc' -H 'X-Env: dev' https://x.com
複数のヘッダーを追加
curl -H 'Content-Type: application/json' https://x.com
リクエストボディのContent-Typeを宣言
curl -H 'Authorization: Bearer TOKEN' https://x.com
Bearer認可ヘッダーを送信
curl -H 'Host: example.com' https://1.2.3.4
Hostヘッダーを上書き
curl -H 'Accept-Encoding: gzip' https://x.com
gzip圧縮レスポンスをリクエスト
curl -A 'MyAgent/1.0' https://x.com
User-Agent文字列を設定
curl -e 'https://ref.com' https://x.com
Refererヘッダーを設定
curl -H 'X-Debug:' https://x.com
空にしてデフォルトヘッダーを削除
curl --compressed https://x.com
圧縮要求しレスポンスを自動展開
データの送信
11curl -d 'name=Jane&age=30' https://x.com
URLエンコードフォームデータをPOST
curl -d '@payload.json' https://x.com
ファイルから読んだデータをPOST
curl --data-urlencode 'q=hello world' https://x.com
単一のURLエンコードフィールドをPOST
curl --data-binary '@file.bin' https://x.com
加工せず生のバイトをPOST
curl -G --data-urlencode 'q=cats' https://x.com
データをGETクエリ文字列として付加
curl -X POST -H 'Content-Type: application/json' -d '{"name":"Jane"}' https://x.com
JSONボディをPOST
curl --json '{"name":"Jane"}' https://x.com
JSONをPOSTしJSONヘッダーを自動設定
curl -F 'name=Jane' https://x.com
マルチパートフォームフィールドを送信
curl -F 'file=@photo.png' https://x.com
ファイルをマルチパートform-dataでアップロード
curl -F 'file=@a.pdf;type=application/pdf' https://x.com
MIMEタイプ明示でファイルをアップロード
curl -d '' https://x.com
空のボディでPOST
認証
9curl -u user:pass https://x.com
HTTPベーシック認証
curl -u user https://x.com
ベーシック認証、パスワードを入力要求
curl -H 'Authorization: Bearer TOKEN' https://x.com
Bearerトークンヘッダーを送信
curl --oauth2-bearer TOKEN https://x.com
OAuth 2.0 Bearerトークンを送信
curl --digest -u user:pass https://x.com
HTTPダイジェスト認証を使用
curl --ntlm -u user:pass https://x.com
NTLM認証を使用
curl --netrc https://x.com
~/.netrcから認証情報を読み込み
curl --netrc-file creds https://x.com
カスタムnetrcファイルから認証情報を読み込み
curl -H 'X-Api-Key: KEY' https://x.com
APIキーヘッダーを送信
ダウンロードとアップロード
11curl -O https://x.com/file.zip
リモートのファイル名でダウンロード
curl -o out.zip https://x.com/file.zip
指定ファイル名でダウンロード
curl -OL https://x.com/file.zip
ダウンロードしリダイレクトを追跡
curl -C - -O https://x.com/file.zip
途中のダウンロードを再開
curl --limit-rate 200k -O https://x.com/f
転送速度に上限を設定
curl -r 0-1023 -o part https://x.com/f
指定バイト範囲のみダウンロード
curl --retry 3 -O https://x.com/f
失敗時にダウンロードを再試行
curl -T file.txt ftp://x.com/
PUT/FTPでファイルをアップロード
curl -T file.txt https://x.com/up
HTTP PUTでファイルをアップロード
curl --create-dirs -o a/b/f.txt https://x.com
出力用に不足ディレクトリを作成
curl -# -O https://x.com/file.zip
シンプルな進捗バーを表示
Cookie
8curl -b 'session=abc123' https://x.com
Cookieをインラインで送信
curl -b cookies.txt https://x.com
ファイルからCookieを送信
curl -c cookies.txt https://x.com
受信したCookieをjarに書き込み
curl -b jar.txt -c jar.txt https://x.com
同じCookie jarを読み書き更新
curl -b 'a=1; b=2' https://x.com
複数Cookieを一度に送信
curl -c - https://x.com
受信Cookieを標準出力に表示
curl --junk-session-cookies -b jar.txt https://x.com
jar内のセッションCookieを無視
curl -L -c jar.txt -b jar.txt https://x.com/login
リダイレクト間でセッションを維持
TLS / SSL
10curl -k https://x.com
非セキュアを許可(証明書検証をスキップ)
curl --cacert ca.pem https://x.com
カスタムCAバンドルで検証
curl --capath /etc/ssl/certs https://x.com
CA証明書のディレクトリを使用
curl --cert client.pem https://x.com
クライアント証明書を送信
curl --cert client.pem --key client.key https://x.com
クライアント証明書と秘密鍵を使用
curl --tlsv1.2 https://x.com
最低でもTLS 1.2を要求
curl --tlsv1.3 https://x.com
最低でもTLS 1.3を要求
curl --tls-max 1.2 https://x.com
TLSの最大バージョンを制限
curl --ciphers ECDHE-RSA-AES128-GCM-SHA256 https://x.com
許可するTLS暗号スイートを制限
curl -vI https://x.com
TLSハンドシェイクの詳細を確認
プロキシ
9curl -x http://proxy:8080 https://x.com
HTTPプロキシ経由でリクエスト
curl --proxy http://proxy:8080 https://x.com
プロキシ指定 -x の長い形式
curl -x proxy:8080 -U user:pass https://x.com
プロキシに認証
curl --proxy-user user:pass -x proxy:8080 https://x.com
プロキシ認証情報の長い形式
curl --socks5 127.0.0.1:1080 https://x.com
SOCKS5プロキシを使用
curl --socks5-hostname 127.0.0.1:1080 https://x.com
リモートDNS解決付きSOCKS5プロキシ
curl --socks4 127.0.0.1:1080 https://x.com
SOCKS4プロキシを使用
curl --noproxy example.com https://x.com
指定ホストはプロキシをバイパス
curl -x '' https://x.com
設定済みプロキシを無効化
デバッグと出力
11curl -w '%{http_code}\n' -o /dev/null -s https://x.com
HTTPステータスコードのみ表示
curl -w '%{time_total}\n' -o /dev/null -s https://x.com
合計転送時間を表示
curl -w '@format.txt' https://x.com
write-out形式をファイルから読み込み
curl -D headers.txt https://x.com
レスポンスヘッダーをファイルに出力
curl -D - -o body.txt https://x.com
ヘッダーを標準出力、ボディをファイルへ
curl --trace trace.txt https://x.com
転送の完全な16進トレース
curl --trace-ascii - https://x.com
ASCIIトレースを標準出力へ
curl --trace-time -v https://x.com
詳細出力にタイムスタンプを追加
curl -v https://x.com 2>&1 | less
詳細ログをページャで表示
curl -sS -o /dev/null -w '%{size_download}\n' https://x.com
ダウンロードバイト数を表示
curl --libcurl out.c https://x.com
同等のlibcurl Cソースを出力
タイムアウトと再試行
10curl --connect-timeout 5 https://x.com
接続フェーズを秒単位で制限
curl --max-time 30 https://x.com
全体の操作時間に上限を設定
curl --retry 3 https://x.com
一時的エラー時に再試行
curl --retry 3 --retry-delay 2 https://x.com
再試行の間に待機
curl --retry 5 --retry-max-time 60 https://x.com
再試行に費やす合計時間を制限
curl --retry-connrefused https://x.com
接続拒否時にも再試行
curl --retry-all-errors https://x.com
一時的でなく任意のエラーで再試行
curl --speed-limit 100 --speed-time 10 https://x.com
一定時間遅すぎる場合に中止
curl --keepalive-time 60 https://x.com
TCPキープアライブ間隔を設定
curl --expect100-timeout 1 https://x.com
100-continueの待機を制限
「:q」に一致する項目はありません。
お困りですか?
このツールで問題が見つかりましたか?チームにお知らせください。