SKILL.md--- name: curl-http description: Essential curl commands for HTTP requests, API testing, and file transfers. homepage: https://curl.se/ metadata: {"clawdbot":{"emoji":"🌐","requires":{"bins":["curl"]}}} --- # curl - HTTP Client Command-line tool for making HTTP requests and transferring data. ## Basic Requests ### GET requests ```bash # Simple GET request curl https://api.example.com # Save output to file curl https://example.com -o output.html curl https://example.com/file.zip -O # Use remote filename # Follow redirects curl -L https://example.com # Show response headers curl -i https://example.com # Show only headers curl -I https://example.com # Verbose output (debugging) curl -v https://example.com ``` ### POST requests ```bash # POST with data curl -X POST https://api.example.com/users \ -d "name=John&email=john@example.com" # POST JSON data curl -X POST https://api.example.com/users \ -H "Content-Type: application/json" \ -d '{"name":"John","email":"john@example.com"}' # POST from file curl -X POST https://api.example.com/users \ -H "Content-Type: application/json" \ -d @data.json # Form upload curl -X POST https://api.example.com/upload \ -F "file=@document.pdf" \ -F "description=My document" ``` ### Other HTTP methods ```bash # PUT request curl -X PUT https://api.example.com/users/1 \ -H "Content-Type: application/json" \ -d '{"name":"Jane"}' # DELETE request curl -X DELETE https://api.example.com/users/1 # PATCH request curl -X PATCH https://api.example.com/users/1 \ -H "Content-Type: application/json" \ -d '{"email":"newemail@example.com"}' ``` ## Headers & Authentication ### Custom headers ```bash # Add custom header curl -H "User-Agent: MyApp/1.0" https://example.com # Multiple headers curl -H "Accept: application/json" \ -H "Authorization: Bearer token123" \ https://api.example.com ``` ### Authentication ```bash # Basic auth curl -u username:password https://api.example.com # Bearer token curl -H "Authorization: Bearer YOUR_TOKEN" \ https://api.example.com # API key in header curl -H "X-API-Key: your_api_key" \ https://api.example.com # API key in URL curl "https://api.example.com?api_key=your_key" ``` ## Advanced Features ### Timeouts & retries ```bash # Connection timeout (seconds) curl --connect-timeout 10 https://example.com # Max time for entire operation curl --max-time 30 https://example.com # Retry on failure curl --retry 3 https://example.com # Retry delay curl --retry 3 --retry-delay 5 https://example.com ``` ### Cookies ```bash # Send cookies curl -b "session=abc123" https://example.com # Save cookies to file curl -c cookies.txt https://example.com # Load cookies from file curl -b cookies.txt https://example.com # Both save and load curl -b cookies.txt -c cookies.txt https://example.com ``` ### Proxy ```bash # Use HTTP proxy curl -x http://proxy.example.com:8080 https://api.example.com # With proxy authentication curl -x htt