Learn cURL by Examples
LatestcURL is a powerful command-line tool and versatile library used for transferring data across networks using URLs. It supports an extensive range of protocols—including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, SMB, SMTP, and many others—making it a flexible solution for developers, system administrators, and API testers alike. Whether you're fetching a webpage, interacting with a REST API, uploading files, or debugging network requests, cURL provides a consistent and script-friendly interface.
These examples cover common cURL usage scenarios, from simple GET requests to complex interactions involving authentication, file uploads, and debugging.
Basic Request
Perform a simple GET request. This sample shows the default behavior.
Query Parameters
Send data in the URL. This example shows GET with params.
Request Headers
Custom headers. This sample shows sending User-Agent and Accept headers.
JSON Payload
Send JSON data. This example demonstrates how to properly format and send a JSON object in a POST request, ensuring the server interprets it correctly.
Form Data
Submit HTML forms. This sample demonstrates how to send data using the `application/x-www-form-urlencoded` content type, which is the standard method for submitting simple web forms.
File Upload
Upload files to a server. This example shows `-F` with file paths.
Authentication Token
Authenticate requests. This sample shows Basic Auth and Bearer Tokens.
Cookie Storage
Manage sessions and persistent state. This example covers the "cookie engine", the Netscape cookie file format, and session handling.
Redirect Handling
Control redirect behavior. This sample shows `-L` and `--max-redirs`.
Response Timing
Measure performance. This example shows custom output formatting.
HEAD Request
Fetch headers only. This is useful for checking if a resource exists or inspecting metadata without downloading the body.
HTTPS/TLS Options
Force specific TLS versions. Useful for testing server compatibility or security configurations.
Proxy Request
Route requests through a proxy server. Supports HTTP, HTTPS, and SOCKS proxies.
Timeout Settings
Set connection and operation timeouts. Prevents cURL from hanging indefinitely.
Max Time Limit
Hard limit on operation duration. Synonymous with `--max-time` but focused on use cases.
Limit Upload Speed
Throttle upload bandwidth. Useful for testing low-bandwidth conditions or being a good network citizen.
Limit Download Speed
Throttle download bandwidth. Simulate slow connections.
IPv4 Only
Force cURL to use IPv4. Resolves DNS to IPv4 addresses only.
IPv6 Only
Force cURL to use IPv6. Resolves DNS to IPv6 addresses only.
Upload File via PUT
Upload a file using the PUT method. Common in WebDAV and RESTful storage APIs.
Upload Raw Data
Send raw binary data from a file. Useful for APIs expecting binary bodies (e.g., images, protobufs).
Send Binary Data
Send binary data directly from the command line (if possible) or via pipe.
GraphQL Request
Execute a GraphQL query. GraphQL requests are typically POST requests with a JSON body containing the query.
XML/SOAP Request
Send an XML payload, common in legacy SOAP APIs.
HTTP/2 Request
Force the use of HTTP/2. Modern cURL versions try to negotiate this automatically.
HTTP/3 Request
Force the use of HTTP/3 (QUIC). Requires a cURL build with HTTP/3 support.

