Usage Examples
Below are example codes in various programming languages using this tool's API calls
Basic GET Request
Curl Command
curl -X GET https://curl-to/users
Generated JSON
{
"method": "GET",
"url": "https://curl-to/users",
"headers": {}
}
POST Request with JSON Data
Curl Command
curl -X POST https://curl-to/users \
-H 'Content-Type: application/json' \
-d '{"name":"John","email":"[email protected]"}'
Generated JSON
{
"method": "POST",
"url": "https://curl-to/users",
"headers": {
"Content-Type": "application/json"
},
"data": {
"name": "John",
"email": "[email protected]"
}
}
PUT Request with Authentication
Curl Command
curl -X PUT https://curl-to/users/123 \
-H 'Authorization: Bearer token123' \
-H 'Content-Type: application/json' \
-d '{"name":"Updated Name"}'
Generated JSON
{
"method": "PUT",
"url": "https://curl-to/users/123",
"headers": {
"Authorization": "Bearer token123",
"Content-Type": "application/json"
},
"data": {
"name": "Updated Name"
}
}
File Upload
Curl Command
curl -X POST https://curl-to/upload \
-F 'file=@/path/to/file.jpg' \
-F 'description=Profile picture'
Generated JSON
{
"method": "POST",
"url": "https://curl-to/upload",
"form_data": {
"file": {
"type": "file",
"path": "/path/to/file.jpg"
},
"description": {
"type": "text",
"value": "Profile picture"
}
}
}
Complex Request with Proxy
Curl Command
curl -X POST https://curl-to/data \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic dXNlcjpwYXNz' \
-H 'Accept: application/json' \
-d '{"query":"test"}' \
-x http://proxy.example.com:8080 \
-k
Generated JSON
{
"method": "POST",
"url": "https://curl-to/data",
"headers": {
"Content-Type": "application/json",
"Authorization": "Basic dXNlcjpwYXNz",
"Accept": "application/json"
},
"data": {
"query": "test"
},
"proxy": "http://proxy.example.com:8080",
"verify_ssl": false
}
Generate Curl from Python Code
Python Code
import requests
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer token123'
}
data = {
'name': 'John Doe',
'email': '[email protected]'
}
response = requests.post('https://curl-to/users',
headers=headers, json=data)
Generated Curl Command
curl -X POST \
'https://curl-to/users' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer token123' \
-d '{"name":"John Doe","email":"[email protected]"}'