API Documentation
v1.0.0
Code Examples
Copy-paste ready examples in multiple languages to get started quickly.
Language:
cURL Examples
These examples work in any terminal with cURL installed.
Complete Conversion Workflow
#!/bin/bash
API_KEY="your_api_key_here"
BASE_URL="https://agentsfordata.com/api/public/v1"
# Step 1: Get upload URLs
echo "Getting upload URLs..."
URLS_RESPONSE=$(curl -s -X POST "$BASE_URL/convert/upload-urls" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sourceFormat": "csv",
"destinationFormat": "json",
"filename": "my-data"
}')
# Extract URLs using jq (or parse JSON manually)
UPLOAD_URL=$(echo $URLS_RESPONSE | jq -r '.data.source.uploadUrl')
FILE_PATH=$(echo $URLS_RESPONSE | jq -r '.data.source.filePath')
# Step 2: Upload your file
echo "Uploading file..."
curl -X PUT "$UPLOAD_URL" \
-H "Content-Type: text/csv" \
--data-binary @input.csv
# Step 3: Convert the file
echo "Converting file..."
CONVERT_RESPONSE=$(curl -s -X POST "$BASE_URL/convert" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"sourceUrl\": \"$FILE_PATH\",
\"sourceFormat\": \"csv\",
\"destinationFormat\": \"json\"
}")
# Extract download URL
DOWNLOAD_URL=$(echo $CONVERT_RESPONSE | jq -r '.data.downloadUrl')
# Step 4: Download the result
echo "Downloading result..."
curl -o output.json "$DOWNLOAD_URL"
echo "Done! Output saved to output.json"
Quick Single Request
Get upload URLs for a conversion
curl -X POST https://agentsfordata.com/api/public/v1/convert/upload-urls \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"sourceFormat": "csv",
"destinationFormat": "json"
}'
Best Practices
Store API Keys Securely
Never hardcode API keys in your source code. Always use environment variables.
Handle Rate Limits
Implement exponential backoff when you receive 429 errors. Check the X-RateLimit-Remaining
header to monitor your usage.
Validate Responses
Always check the success
field in API responses before processing data.
Need More Help?
If you have questions or need examples in other languages, we're here to help.
Email us at support@agentsfordata.com