Health Check
The health check endpoint provides a simple way to verify that the Screenshot API service is running and accessible. This endpoint is useful for monitoring, load balancers, and automated health checks.
Note: This endpoint does not require authentication and is publicly accessible.
Get Service Health
This endpoint returns the current status of the Screenshot API service, including uptime information and a timestamp.
Response fields
- Name
status
- Type
- string
- Description
Service status indicator, always returns
"ok"
when the service is operational.
- Name
uptime
- Type
- number
- Description
Server uptime in seconds since the last restart.
- Name
timestamp
- Type
- string
- Description
Current server timestamp in ISO 8601 format.
Request
curl https://api.webcapture.ai/health
Response
{
"status": "ok",
"uptime": 86400.5,
"timestamp": "2023-12-07T10:30:00.000Z"
}
Usage Examples
Basic Health Check
The simplest way to check if the service is running:
curl https://api.webcapture.ai/health
Monitoring Script
Example monitoring script that checks service health:
#!/bin/bash
HEALTH_URL="https://api.webcapture.ai/health"
RESPONSE=$(curl -s -w "%{http_code}" -o /tmp/health.json "$HEALTH_URL")
HTTP_CODE="${RESPONSE: -3}"
if [ "$HTTP_CODE" = "200" ]; then
STATUS=$(cat /tmp/health.json | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
if [ "$STATUS" = "ok" ]; then
echo "✅ Service is healthy"
exit 0
else
echo "❌ Service returned unhealthy status: $STATUS"
exit 1
fi
else
echo "❌ Service is not responding (HTTP $HTTP_CODE)"
exit 1
fi
Load Balancer Configuration
Example Nginx upstream health check configuration:
upstream screenshot_api {
server api1.webcapture.ai;
server api2.webcapture.ai;
}
location /health {
access_log off;
proxy_pass http://screenshot_api;
proxy_set_header Host $host;
proxy_connect_timeout 5s;
proxy_read_timeout 10s;
}
Integration Tips
Monitoring Services
Most monitoring services can use this endpoint for uptime checks:
- Pingdom: Set up HTTP check pointing to
/health
- UptimeRobot: Monitor with keyword check for
"status":"ok"
- Datadog: Use synthetic tests with JSON assertion
- New Relic: Configure availability monitoring
Docker Health Checks
Add to your Dockerfile:
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
Kubernetes Readiness Probe
Configure in your deployment:
readinessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 10
periodSeconds: 5