[{"data":1,"prerenderedAt":61},["Reactive",2],{"/samples/curl/":3},[4],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"language":11,"library":11,"link":12,"body":13,"_type":56,"_id":57,"_source":58,"_file":59,"_extension":60},"/samples/curl/curl","curl",false,"","Curl","cUrl is a command-line tool and library for transferring data with URLs. It supports numerous protocols including HTTP, HTTPS, FTP, and many others. cUrl is widely used for testing APIs, downloading files, and making HTTP requests from the command line.","cUrl","https://curl.se/docs/",{"type":14,"children":15,"toc":53},"root",[16,31,44],{"type":17,"tag":18,"props":19,"children":20},"element","p",{},[21,29],{"type":17,"tag":22,"props":23,"children":26},"a",{"href":12,"rel":24},[25],"nofollow",[27],{"type":28,"value":11},"text",{"type":28,"value":30}," is a command-line tool and library for transferring data with URLs. It supports numerous protocols including HTTP, HTTPS, FTP, and many others. cUrl is widely used for testing APIs, downloading files, and making HTTP requests from the command line.",{"type":17,"tag":32,"props":33,"children":38},"pre",{"className":34,"code":36,"language":37,"meta":8},[35],"language-bash","#!/bin/bash\n\n# Simple function to convert HTML to PDF using cUrl\nconvert() {\n    local api_key=\"$1\"\n    local endpoint=\"$2\"\n    local params=\"$3\"\n    \n    # Validate endpoint\n    if [[ ! \"$endpoint\" =~ ^(pdf|png|jpg|webp)$ ]]; then\n        echo \"Error: Invalid endpoint\"\n        return 1\n    fi\n    \n    # Make the API request\n    curl -X POST \"https://api.pdfshift.io/v3/convert/$endpoint\" \\\n        -H \"Content-Type: application/json\" \\\n        -H \"X-API-Key: $api_key\" \\\n        -d \"$params\" \\\n        -o \"result.$endpoint\"\n}\n\n# Example usage\nconvert \"sk_XXXXXXXXXXXXXX\" \"pdf\" '{\"source\": \"https://en.wikipedia.org/wiki/REST\"}'\n","bash",[39],{"type":17,"tag":40,"props":41,"children":42},"code",{"__ignoreMap":8},[43],{"type":28,"value":36},{"type":17,"tag":32,"props":45,"children":48},{"className":46,"code":47,"language":37,"meta":8},[35],"# Example usage with error handling\nAPI_KEY=\"sk_xxxxxxxxxxxx\"\n\n# Convert HTML from URL to PDF with error handling\nresponse=$(curl -s -w \"%{http_code}\" -X POST \"https://api.pdfshift.io/v3/convert/pdf\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"X-API-Key: ${API_KEY}\" \\\n  -d '{\"source\": \"https://www.example.com\"}')\n\n# Extract HTTP status code\nhttp_status=\"${response: -3}\"\n# Extract response body\nresponse_body=\"${response%???}\"\n\nif [ \"$http_status\" -eq 200 ]; then\n    echo \"Conversion successful\"\n    echo \"$response_body\" > \"result.pdf\"\nelse\n    echo \"Error: HTTP $http_status\"\n    echo \"$response_body\"\nfi\n",[49],{"type":17,"tag":40,"props":50,"children":51},{"__ignoreMap":8},[52],{"type":28,"value":47},{"title":8,"searchDepth":54,"depth":54,"links":55},2,[],"markdown","content:samples:curl:curl.md","content","samples/curl/curl.md","md",1792765618728]