jpskill.com
🛠️ 開発・MCP コミュニティ

curl-http

APIテストやHTTPリクエストの送信など、コマンドラインからHTTP通信を行う際に、curlやhttpieを活用して効率的に処理するSkill。

📜 元の英語説明(参考)

API testing with curl and httpie for HTTP requests. Use when user asks to "test API", "make HTTP request", "curl POST", "send request", "test endpoint", "debug API", or make any HTTP calls from command line.

🇯🇵 日本人クリエイター向け解説

一言でいうと

APIテストやHTTPリクエストの送信など、コマンドラインからHTTP通信を行う際に、curlやhttpieを活用して効率的に処理するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

curl & HTTPie

APIテスト用のコマンドラインHTTPクライアントです。

curlの基本

GETリクエスト

curl https://api.example.com/users
curl -s https://api.example.com/users  # サイレントモード
curl -i https://api.example.com/users  # ヘッダーを含める

POSTリクエスト

# JSONボディ
curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"John","email":"john@example.com"}'

# ファイルから
curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d @data.json

ヘッダーと認証

# カスタムヘッダー
curl -H "Authorization: Bearer token123" https://api.example.com

# Basic認証
curl -u username:password https://api.example.com

# 複数のヘッダー
curl -H "Content-Type: application/json" \
     -H "X-API-Key: key123" \
     https://api.example.com

その他のメソッド

# PUT
curl -X PUT https://api.example.com/users/1 \
  -H "Content-Type: application/json" \
  -d '{"name":"Updated"}'

# PATCH
curl -X PATCH https://api.example.com/users/1 \
  -d '{"status":"active"}'

# DELETE
curl -X DELETE https://api.example.com/users/1

ファイルアップロード

# フォームアップロード
curl -X POST https://api.example.com/upload \
  -F "file=@photo.jpg" \
  -F "description=My photo"

# バイナリ
curl -X POST https://api.example.com/upload \
  --data-binary @file.bin \
  -H "Content-Type: application/octet-stream"

便利なオプション

-v          # 詳細表示 (デバッグ)
-s          # サイレントモード
-o file     # ファイルに出力
-O          # リモートファイル名で保存
-L          # リダイレクトを追跡
-k          # SSLエラーを無視
-w '\n'     # 出力の後に改行を追加
--max-time 10  # タイムアウト (秒)

HTTPie (より使いやすい代替手段)

GETリクエスト

http https://api.example.com/users
http GET api.example.com/users  # 明示的なGET

POSTリクエスト

# JSON (デフォルト)
http POST api.example.com/users name=John email=john@example.com

# 文字列とその他の型
http POST api.example.com/users name=John age:=30 active:=true

ヘッダーと認証

# ヘッダー
http api.example.com Authorization:"Bearer token"

# Basic認証
http -a user:pass api.example.com

# Bearer認証
http api.example.com "Authorization: Bearer token"

出力制御

http -h api.example.com   # ヘッダーのみ
http -b api.example.com   # ボディのみ
http -p Hh api.example.com  # リクエストヘッダー

一般的なパターン

レスポンスコードのテスト

# curl
status=$(curl -s -o /dev/null -w "%{http_code}" https://api.example.com)
echo "Status: $status"

# 成功したか確認
if curl -s -f https://api.example.com > /dev/null; then
  echo "Success"
fi

JSONの整形表示

curl -s https://api.example.com | jq .
curl -s https://api.example.com | python -m json.tool

レスポンスとヘッダーの保存

curl -D headers.txt -o response.json https://api.example.com

失敗時のリトライ

curl --retry 3 --retry-delay 2 https://api.example.com

実行時間の情報

curl -w "Time: %{time_total}s\n" -o /dev/null -s https://api.example.com

GraphQL

curl -X POST https://api.example.com/graphql \
  -H "Content-Type: application/json" \
  -d '{"query": "{ users { id name } }"}'

デバッグ

# 詳細出力
curl -v https://api.example.com

# トレース (非常に詳細)
curl --trace - https://api.example.com

# レスポンスヘッダーのみ表示
curl -I https://api.example.com
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

curl & HTTPie

Command-line HTTP clients for API testing.

curl Basics

GET Request

curl https://api.example.com/users
curl -s https://api.example.com/users  # Silent
curl -i https://api.example.com/users  # Include headers

POST Request

# JSON body
curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"John","email":"john@example.com"}'

# From file
curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d @data.json

Headers & Auth

# Custom header
curl -H "Authorization: Bearer token123" https://api.example.com

# Basic auth
curl -u username:password https://api.example.com

# Multiple headers
curl -H "Content-Type: application/json" \
     -H "X-API-Key: key123" \
     https://api.example.com

Other Methods

# PUT
curl -X PUT https://api.example.com/users/1 \
  -H "Content-Type: application/json" \
  -d '{"name":"Updated"}'

# PATCH
curl -X PATCH https://api.example.com/users/1 \
  -d '{"status":"active"}'

# DELETE
curl -X DELETE https://api.example.com/users/1

File Upload

# Form upload
curl -X POST https://api.example.com/upload \
  -F "file=@photo.jpg" \
  -F "description=My photo"

# Binary
curl -X POST https://api.example.com/upload \
  --data-binary @file.bin \
  -H "Content-Type: application/octet-stream"

Useful Options

-v          # Verbose (debug)
-s          # Silent
-o file     # Output to file
-O          # Save with remote filename
-L          # Follow redirects
-k          # Ignore SSL errors
-w '\n'     # Add newline after output
--max-time 10  # Timeout in seconds

HTTPie (Friendlier Alternative)

GET Request

http https://api.example.com/users
http GET api.example.com/users  # Explicit GET

POST Request

# JSON (default)
http POST api.example.com/users name=John email=john@example.com

# String vs other types
http POST api.example.com/users name=John age:=30 active:=true

Headers & Auth

# Header
http api.example.com Authorization:"Bearer token"

# Basic auth
http -a user:pass api.example.com

# Bearer auth
http api.example.com "Authorization: Bearer token"

Output Control

http -h api.example.com   # Headers only
http -b api.example.com   # Body only
http -p Hh api.example.com  # Request headers

Common Patterns

Test Response Code

# curl
status=$(curl -s -o /dev/null -w "%{http_code}" https://api.example.com)
echo "Status: $status"

# Check if successful
if curl -s -f https://api.example.com > /dev/null; then
  echo "Success"
fi

Pretty Print JSON

curl -s https://api.example.com | jq .
curl -s https://api.example.com | python -m json.tool

Save Response & Headers

curl -D headers.txt -o response.json https://api.example.com

Retry on Failure

curl --retry 3 --retry-delay 2 https://api.example.com

Timing Info

curl -w "Time: %{time_total}s\n" -o /dev/null -s https://api.example.com

GraphQL

curl -X POST https://api.example.com/graphql \
  -H "Content-Type: application/json" \
  -d '{"query": "{ users { id name } }"}'

Debug

# Verbose output
curl -v https://api.example.com

# Trace (very detailed)
curl --trace - https://api.example.com

# Show only response headers
curl -I https://api.example.com