cURL Examples

Command-line examples using cURL for testing and quick integration.

Basic Request

bash
curl -X POST https://captchakings.com/api/process.php \
  -H "Authorization: Bearer ck_your_api_key_here" \
  -F "captcha=@captcha.jpg"

With Pretty JSON Output

bash
curl -X POST https://captchakings.com/api/process.php \
  -H "Authorization: Bearer ck_your_api_key_here" \
  -F "captcha=@captcha.jpg" \
  | jq .

Save Response to File

bash
curl -X POST https://captchakings.com/api/process.php \
  -H "Authorization: Bearer ck_your_api_key_here" \
  -F "captcha=@captcha.jpg" \
  -o response.json

Extract Specific Fields

bash
# Extract prediction only
curl -s -X POST https://captchakings.com/api/process.php \
  -H "Authorization: Bearer ck_your_api_key_here" \
  -F "captcha=@captcha.jpg" \
  | jq -r '.data.prediction'

# Output: GXL4

Shell Script Example

bash
#!/bin/bash

API_KEY="ck_your_api_key_here"
CAPTCHA_IMAGE="captcha.jpg"

echo "Processing CAPTCHA..."

RESPONSE=$(curl -s -X POST https://captchakings.com/api/process.php \
  -H "Authorization: Bearer $API_KEY" \
  -F "captcha=@$CAPTCHA_IMAGE")

SUCCESS=$(echo "$RESPONSE" | jq -r '.success')

if [ "$SUCCESS" = "true" ]; then
    PREDICTION=$(echo "$RESPONSE" | jq -r '.data.prediction')
    CONFIDENCE=$(echo "$RESPONSE" | jq -r '.data.confidence')
    CREDITS=$(echo "$RESPONSE" | jq -r '.credits.credits_remaining')
    
    echo "✅ SUCCESS!"
    echo "Prediction: $PREDICTION"
    echo "Confidence: $CONFIDENCE"
    echo "Credits Remaining: $CREDITS"
else
    ERROR=$(echo "$RESPONSE" | jq -r '.error')
    echo "❌ ERROR: $ERROR"
fi

See full examples in the examples/ folder of your installation.