Basic Examples
Simple HTTP request configurations to get you started with curl-runner. Copy and modify these examples for your own use cases.
Simple GET Request
BasicBasic HTTP GET request to fetch data
get-request.yaml
# Simple GET request
request:
name: Get JSONPlaceholder Post
url: https://jsonplaceholder.typicode.com/posts/1
method: GET
POST Request with JSON Body
BasicCreate a new resource with JSON payload
post-request.yaml
# POST request with JSON body
request:
name: Create New Post
url: https://jsonplaceholder.typicode.com/posts
method: POST
headers:
Content-Type: application/json
body:
title: My New Post
body: This is the content of my new post
userId: 1
Request with Headers and Authentication
AuthInclude custom headers and Bearer token authentication
auth-request.yaml
# Request with authentication
request:
name: Get Protected Resource
url: https://api.example.com/protected/resource
method: GET
headers:
Authorization: Bearer your-token-here
Content-Type: application/json
X-API-Version: "1.0"
User-Agent: curl-runner/1.0.0
PUT Request to Update Resource
BasicUpdate an existing resource completely
put-request.yaml
# PUT request to update resource
request:
name: Update Post
url: https://jsonplaceholder.typicode.com/posts/1
method: PUT
headers:
Content-Type: application/json
body:
id: 1
title: Updated Post Title
body: This post has been updated
userId: 1
PATCH Request for Partial Update
BasicUpdate specific fields of a resource
patch-request.yaml
# PATCH request for partial update
request:
name: Update Post Title
url: https://jsonplaceholder.typicode.com/posts/1
method: PATCH
headers:
Content-Type: application/json
body:
title: Partially Updated Title
DELETE Request
BasicRemove a resource from the server
delete-request.yaml
# DELETE request
request:
name: Delete Post
url: https://jsonplaceholder.typicode.com/posts/1
method: DELETE
headers:
Authorization: Bearer your-token-here
Request with Query Parameters
BasicInclude URL query parameters in your request
query-params.yaml
# Request with query parameters
request:
name: Search Posts
url: https://jsonplaceholder.typicode.com/posts?userId=1&_limit=5
method: GET
headers:
Accept: application/json
Form Data Request
FormsSend form-encoded data (application/x-www-form-urlencoded)
form-request.yaml
# Form data request
request:
name: Submit Contact Form
url: https://httpbin.org/post
method: POST
headers:
Content-Type: application/x-www-form-urlencoded
body: "name=John+Doe&email=john@example.com&message=Hello+World"
Request with Timeout and Retries
AdvancedConfigure request timeout and retry behavior
timeout-retry.yaml
# Request with timeout and retries
request:
name: Slow API Call
url: https://httpbin.org/delay/2
method: GET
timeout: 5000 # 5 seconds
retries: 3
headers:
Accept: application/json
Running the Examples
Save any of the above examples to a YAML file and run them with curl-runner
:
# Run a specific example
curl-runner get-request.yaml
# Run with verbose output
curl-runner post-request.yaml -v
# Run with timeout
curl-runner auth-request.yaml --timeout 10000
# Save results to file
curl-runner query-params.yaml --output results.json
Tips
Testing APIs
- Use
https://jsonplaceholder.typicode.com
for testing - it's a free REST API for testing and prototyping - Try
https://httpbin.org
for testing different HTTP scenarios like delays, status codes, and headers
Best Practices
- Always include meaningful names for your requests
- Use appropriate HTTP methods (GET for reading, POST for creating, etc.)
- Include proper Content-Type headers when sending data
Debugging & Troubleshooting
- Use the
--verbose
flag to see detailed request and response information - Check response headers for debugging information and API limits
- Test with simple requests first, then add complexity gradually
- Validate your YAML syntax if requests aren't working as expected
On This Page