Learn how to use the ChatGPT Scraper API with cURL for quick testing and shell script integration
This guide shows you how to use the ChatGPT Scraper API with cURL to programmatically collect AI-generated responses from the command line or shell scripts.
Replace YOUR_API_KEY with your actual API key from the cloro dashboard.
export CLORO_API_KEY="YOUR_API_KEY"
2
Make a basic request
Send a POST request to the ChatGPT API endpoint.
curl -X POST https://api.cloro.dev/v1/monitor/chatgpt \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "Compare the top 3 programming languages for web development in 2025", "country": "US", "include": { "markdown": true, "rawResponse": true, "searchQueries": true } }'
3
Process the response
The API returns a JSON response that you can pipe to other commands or save to a file.
# Pretty print the responsecurl -X POST https://api.cloro.dev/v1/monitor/chatgpt \ -H "Authorization: Bearer $CLORO_API_KEY" \ -H "Content-Type: application/json" \ -d '{"prompt": "Your prompt here"}' | jq .# Save to filecurl -X POST https://api.cloro.dev/v1/monitor/chatgpt \ -H "Authorization: Bearer $CLORO_API_KEY" \ -H "Content-Type: application/json" \ -d '{"prompt": "Your prompt here"}' > response.json
curl -X POST https://api.cloro.dev/v1/monitor/chatgpt \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "Compare the top 3 programming languages for web development in 2025", "country": "US", "include": { "markdown": true, "rawResponse": true, "searchQueries": true } }'
For better readability, use multi-line formatting:
curl -X POST https://api.cloro.dev/v1/monitor/chatgpt \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "Compare the top 3 programming languages for web development in 2025", "country": "US", "include": { "markdown": true, "rawResponse": true, "searchQueries": true } }'
The API returns a JSON response with this structure:
{ "status": "success", "result": { "model": "gpt-5-mini", "text": "When comparing programming languages for web development in 2025, three languages stand out...", "markdown": "**When comparing programming languages for web development in 2025**, three languages stand out...", "shoppingCards": [...], "searchQueries": ["web development languages 2025"], "rawResponse": [...] }}
Here’s a complete example of integrating the API into a shell script:
#!/bin/bash# Load API key from environment or config fileAPI_KEY="${CLORO_API_KEY:-YOUR_API_KEY}"# Create payloadread -r -d '' PAYLOAD << EOF{ "prompt": "Compare the top 3 programming languages for web development in 2025", "country": "US", "include": { "markdown": true }}EOF# Make requestresponse=$(curl -X POST https://api.cloro.dev/v1/monitor/chatgpt \ --max-time 180 \ --silent \ --show-error \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d "$PAYLOAD")# Check if request was successfulif [ $? -eq 0 ]; then # Extract and display the text response echo "$response" | jq -r '.result.text' # Save full response to file echo "$response" | jq . > response.json echo "Full response saved to response.json"else echo "Request failed" >&2 exit 1fi
Always validate the response structure and check for the success status before attempting to access nested fields.