ChatGPT vs DeepSeek vs Gemini: Curl
Sure! Here are some simple curl
command examples for beginners to help you get started with making HTTP requests from the command line:
- Fetch a Webpage (HTTP GET Request)
curl https://www.example.com
This command downloads and displays the HTML content of the webpage.
- Save the Output to a File
curl -o example.html https://www.example.com
The
-o
option saves the output to example.html
instead of displaying it.- Follow Redirects
curl -L http://example.com
Sometimes URLs redirect to other URLs. The
-L
flag tells curl
to follow these redirects.- Show Response Headers
curl -I https://www.example.com
The
-I
option fetches and displays only the HTTP headers (not the body).- Send a POST Request with Data
curl -X POST -d "name=John&age=30" https://httpbin.org/post
This sends form data (
name
and age
) via POST.- Send JSON Data in a POST Request
curl -X POST -H "Content-Type: application/json" -d '{"name":"John","age":30}' https://httpbin.org/post
Set header to JSON and send JSON data.
- Pass Authentication Credentials
curl -u username:password https://example.com/protected
Use
-u
for basic HTTP authentication.- Download a File
curl -O https://example.com/file.zip
-O
saves the file with its original name.- Verbose Output (Detailed Request and Response)
curl -v https://www.example.com
Useful for debugging HTTP requests.
- Send a Custom Header
curl -H "X-Custom-Header: value" https://www.example.com
If you want explanation on any particular example or more advanced usage, just let me know!
Here are practical cURL command examples for beginners, starting from basic to more advanced usage:
1. Basic GET Requests
# Simple GET request
curl https://jsonplaceholder.typicode.com/posts# Save output to a file
curl -o output.txt https://jsonplaceholder.typicode.com/posts
# Follow redirects automatically
curl -L https://httpbin.org/redirect/1
# Show request details (verbose mode)
curl -v https://jsonplaceholder.typicode.com/posts/1
2. POST Requests
# Simple POST with data
curl -X POST https://httpbin.org/post -d "name=John&age=30"# POST with JSON data
curl -X POST https://httpbin.org/post \
-H "Content-Type: application/json" \
-d '{"name":"John","age":30}'
# POST with form data
curl -X POST https://httpbin.org/post \
-F "name=John" \
-F "age=30" \
-F "file=@document.txt"
3. Headers and Authentication
# Add custom headers
curl -H "Authorization: Bearer token123" \
-H "User-Agent: MyApp/1.0" \
https://api.example.com/data# Basic authentication
curl -u username:password https://api.example.com/protected
# View response headers only
curl -I https://jsonplaceholder.typicode.com/posts/1
4. File Operations
# Download a file
curl -O https://example.com/file.zip# Download with custom filename
curl -o myfile.zip https://example.com/file.zip
# Upload a file
curl -X POST https://example.com/upload \
-F "file=@localfile.txt"
5. Useful Options and Flags
# Limit download speed (10KB/s)
curl --limit-rate 10K https://example.com/largefile.zip# Resume interrupted download
curl -C - -O https://example.com/largefile.zip
# Ignore SSL certificate verification (not recommended for production)
curl -k https://self-signed-cert-site.com
# Show only the response body (silent mode)
curl -s https://jsonplaceholder.typicode.com/posts/1
6. Practical Examples
# Check if a website is up
curl -I -s -o /dev/null -w "%{http_code}" https://google.com# Test API endpoint
curl -X GET "https://api.github.com/users/octocat"
# Submit form data
curl -X POST "https://httpbin.org/post" \
-d "username=testuser" \
-d "password=testpass"
# Download with progress bar
curl -# -O https://releases.ubuntu.com/22.04/ubuntu-22.04-desktop-amd64.iso
7. Working with APIs
# GET request with parameters
curl "https://api.github.com/search/repositories?q=curl+language:python"# PUT request to update resource
curl -X PUT https://api.example.com/users/1 \
-H "Content-Type: application/json" \
-d '{"name":"John Updated"}'
# DELETE request
curl -X DELETE https://api.example.com/users/1
8. Useful Response Formatting
# Pretty print JSON response
curl -s https://jsonplaceholder.typicode.com/posts/1 | python -m json.tool# Or use jq if installed
curl -s https://jsonplaceholder.typicode.com/posts/1 | jq '.'
# Show timing information
curl -w "@curl-format.txt" https://jsonplaceholder.typicode.com/posts/1
Create a curl-format.txt
file with:
time_namelookup: %{time_namelookup}s\n
time_connect: %{time_connect}s\n
time_appconnect: %{time_appconnect}s\n
time_pretransfer: %{time_pretransfer}s\n
time_redirect: %{time_redirect}s\n
time_starttransfer: %{time_starttransfer}s\n
----------\n
time_total: %{time_total}s\n
Common Options Summary:
-X
: Specify HTTP method (GET, POST, PUT, DELETE)-H
: Add headers-d
: Send data in request body-F
: Send form data-o
: Save output to file-O
: Save with remote filename-v
: Verbose output-s
: Silent mode-L
: Follow redirects-u
: Authentication-I
: Show headers only
Start with simple GET requests and gradually try more complex operations as you get comfortable!
Curl Command Examples for Beginners
curl
is a powerful command-line tool for transferring data with URLs. It's widely used for testing APIs, downloading files, and interacting with web services. Here are some basic examples to get you started:
1. Simple Request - Getting a Webpage:
The most basic use of curl
is to fetch the HTML content of a webpage:
curl https://www.example.com
This command sends an HTTP GET request to https://www.example.com
and displays the HTML source code in your terminal.
2. Saving Output to a File:
Instead of printing the output to the console, you can save it to a file using the -o
or -O
option.
-o
(lowercase o) - Specifies the output filename:
curl -o my_webpage.html https://www.example.com
This downloads the content of
https://www.example.com
and saves it to a file named my_webpage.html
in the current directory.-O
(uppercase O) - Uses the filename from the URL:
curl -O https://www.example.com/images/logo.png
This downloads the image
logo.png
from the specified URL and saves it to your current directory with the same filename (logo.png
).3. Showing HTTP Headers:
To view the HTTP headers along with the content, use the -i
option:
curl -i https://www.example.com
This will show the HTTP headers (e.g., Content-Type, Date, Server) before the HTML content.
4. Following Redirects:
Some URLs will redirect you to another URL. To automatically follow redirects, use the -L
option:
curl -L https://bit.ly/shortened-url
This is useful when dealing with shortened URLs or when a website has moved to a new address.
5. Making a POST Request:
To send data to a server using the POST method, you can use the -d
(or --data
) option. This is often used for submitting forms or sending data to APIs.
curl -d "name=John&age=30" https://www.example.com/submit-form
This sends the data name=John&age=30
to the URL https://www.example.com/submit-form
as if it were submitted from a form. The -d
option will set the Content-Type
header to application/x-www-form-urlencoded
.
Important Note: Often APIs expect data in JSON format. See example 8 for that.
6. Setting Custom Headers:
You can set custom HTTP headers using the -H
option. This is often needed for authentication, specifying content types, or other API interactions.
curl -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_API_TOKEN" https://api.example.com/resource
This sends two headers:
Content-Type: application/json
(tells the server the data is in JSON format)Authorization: Bearer YOURAPITOKEN
(often used for API authentication)
7. Getting More Verbose Output:
For more detailed information about the request, use the -v
option:
curl -v https://www.example.com
This will show the entire request process, including the headers sent and received, which can be helpful for debugging.
8. Sending JSON Data with POST:
To send JSON data in a POST request, you need to set the Content-Type
header to application/json
. You'll also need to format the data as a valid JSON string.
curl -H "Content-Type: application/json" -d '{"name": "John", "age": 30}' https://www.example.com/api/users
'{"name": "John", "age": 30}'
: This is a JSON string containing the data to send. Make sure it's valid JSON.-H "Content-Type: application/json"
: This is crucial. It tells the server that the data being sent is in JSON format. Without this, the server may misinterpret the data.
9. Using a User-Agent:
Some websites or APIs may behave differently based on the User-Agent string. You can set a custom User-Agent using the -A
or --user-agent
option:
curl -A "MyCustomUserAgent/1.0" https://www.example.com
This tells the server that your request is coming from a client with the User-Agent string "MyCustomUserAgent/1.0". This can be useful for simulating different browsers or clients.
10. Downloading a File with Progress Bar:
To show a progress bar while downloading a file, use the #
symbol instead of -o
or -O
. However, using #
requires redirection to standard output (your terminal), so you also need to combine it with appropriate tools like pv
(pipe viewer) to avoid garbling the output if you are piping to another command.
curl https://www.example.com/largefile.zip | pv > largefile.zip
This pipes the output of curl
to pv
, which displays a progress bar, and then redirects pv
's output (the downloaded file) to largefile.zip
. You'll likely need to install pv
(sudo apt-get install pv
or brew install pv
).
A more straightforward (but potentially less feature-rich) option is -#
:
curl -# https://www.example.com/largefile.zip -o largefile.zip
This displays a simple progress bar using #
characters.
11. Dealing with Authentication (Basic Auth):
If a website requires basic authentication (username and password), you can use the -u
option:
curl -u username:password https://www.example.com/protected-resource
Replace username
and password
with your actual credentials. Security Warning: This transmits your password in plain text, so only use it over HTTPS (secure connections) and be aware of the risks. Consider using more secure authentication methods if available.
12. Deleting Resources (DELETE):
To send a DELETE request (e.g., to delete a resource on a server), use the -X
option:
curl -X DELETE https://api.example.com/resource/123
This sends a DELETE request to the specified URL. DELETE requests are often used in RESTful APIs.
Important Considerations:
- HTTPS: Always prefer using
https://
URLs for secure communication. - Error Handling:
curl
returns exit codes. A code of 0 usually means success. Non-zero codes indicate errors. You can check the exit code in a script using$?
(in bash). - Man Page: The
curl
command has a very extensive man page. Typeman curl
in your terminal to see all available options and features. - Context is Key: The specific options and data you need to send with
curl
will depend entirely on the API or web service you're interacting with. Always refer to the API documentation.
This covers the most common basic uses of
curl
. Experiment with these examples, and refer to the curl
documentation for more advanced options as needed. Good luck!💡 Try this comparison yourself:Compare AI models side-by-side on SNEOS
Analysis
This comparison demonstrates the different approaches each AI model takes when responding to the same prompt. Here are the key differences observed:
Response Characteristics
ChatGPT: Provides a concise response with 40 sentences.
DeepSeek: Provides a direct response with 68 sentences.
Gemini: Provides a direct response with 112 sentences.
Key Takeaways
- Each model brings unique strengths to this type of query
- Response styles vary significantly between models
- Consider your specific use case when choosing between these models
Try This Comparison Yourself
Want to test these models with your own prompts? Visit SNEOS.com to compare AI responses side-by-side in real-time.
This comparison was generated using the SNEOS AI Comparison ToolPublished: October 01, 2025 | Models: ChatGPT, DeepSeek, Gemini