curl -X GET "https://api.strike.markets/health"
{
"status" : "healthy" ,
"timestamp" : "2024-01-15T10:30:00Z" ,
"version" : "1.0.0" ,
"environment" : "production" ,
"uptime" : 86400 ,
"services" : {
"database" : {
"status" : "healthy" ,
"response_time_ms" : 2.5
},
"redis" : {
"status" : "healthy" ,
"response_time_ms" : 0.8
},
"rpc" : {
"status" : "healthy" ,
"response_time_ms" : 15.2
}
},
"metrics" : {
"active_users" : 1250 ,
"open_positions" : 3420 ,
"total_volume_24h" : "2500000.00"
}
}
Overview
Get the current health status of the Strike Protocol API and its dependencies. This endpoint provides real-time information about system health, service availability, and key operational metrics.
This endpoint is publicly accessible and does not require authentication. It’s designed for monitoring and status page integrations.
Response Fields
Overall system status: “healthy”, “degraded”, or “unhealthy”
ISO 8601 timestamp of when the health check was performed
Deployment environment (production, staging, development)
Health status of individual services PostgreSQL database connection status Database status: “healthy”, “degraded”, or “unhealthy”
Database query response time in milliseconds
Redis cache connection status Redis status: “healthy”, “degraded”, or “unhealthy”
Redis command response time in milliseconds
Blockchain RPC connection status RPC status: “healthy”, “degraded”, or “unhealthy”
RPC call response time in milliseconds
Key operational metrics Number of active users in the last 24 hours
Total number of currently open positions
Total trading volume in the last 24 hours (USD)
Health Status Levels
Healthy
Status : “healthy”
Condition : All services operational with normal response times
Response Time : < 100ms average
Service Availability : 100%
Degraded
Status : “degraded”
Condition : Some services experiencing issues or high latency
Response Time : 100-500ms average
Service Availability : 90-99%
Unhealthy
Status : “unhealthy”
Condition : Critical services down or severely impaired
Response Time : > 500ms average or timeouts
Service Availability : < 90%
Service Dependencies
Database (PostgreSQL)
Purpose : User data, positions, trading history
Health Check : Simple SELECT query execution
Threshold : Response time < 50ms for healthy status
Critical Impact : Trading operations, account data
Redis Cache
Purpose : Session management, rate limiting, real-time data
Health Check : PING command execution
Threshold : Response time < 10ms for healthy status
Critical Impact : Authentication, performance, real-time updates
RPC (Blockchain)
Purpose : On-chain data, transaction broadcasting
Health Check : Latest block number query
Threshold : Response time < 100ms for healthy status
Critical Impact : Deposits, withdrawals, price feeds
Usage Examples
Basic Health Check
async function checkSystemHealth () {
try {
const response = await fetch ( 'https://api.strike.markets/health' );
const health = await response . json ();
console . log ( `System Status: ${ health . status } ` );
console . log ( `Uptime: ${ Math . floor ( health . uptime / 3600 ) } hours` );
if ( health . status === 'healthy' ) {
console . log ( '✅ All systems operational' );
} else if ( health . status === 'degraded' ) {
console . log ( '⚠️ Some services experiencing issues' );
} else {
console . log ( '❌ System experiencing problems' );
}
return health ;
} catch ( error ) {
console . error ( 'Health check failed:' , error );
return { status: 'unknown' , error: error . message };
}
}
// Usage
const health = await checkSystemHealth ();
Service-Specific Monitoring
function analyzeServiceHealth ( health ) {
const results = {
overall: health . status ,
issues: [],
recommendations: []
};
// Check individual services
for ( const [ serviceName , serviceData ] of Object . entries ( health . services )) {
if ( serviceData . status !== 'healthy' ) {
results . issues . push ({
service: serviceName ,
status: serviceData . status ,
responseTime: serviceData . response_time_ms
});
}
// Check response times
const thresholds = {
database: 50 ,
redis: 10 ,
rpc: 100
};
if ( serviceData . response_time_ms > thresholds [ serviceName ]) {
results . recommendations . push (
` ${ serviceName } response time ( ${ serviceData . response_time_ms } ms) exceeds threshold`
);
}
}
return results ;
}
// Usage
const health = await checkSystemHealth ();
const analysis = analyzeServiceHealth ( health );
if ( analysis . issues . length > 0 ) {
console . log ( 'Service Issues:' , analysis . issues );
}
if ( analysis . recommendations . length > 0 ) {
console . log ( 'Recommendations:' , analysis . recommendations );
}
Monitoring Dashboard Integration
class HealthMonitor {
constructor ( checkInterval = 30000 ) {
this . interval = checkInterval ;
this . isMonitoring = false ;
this . listeners = [];
this . lastHealth = null ;
}
onHealthChange ( callback ) {
this . listeners . push ( callback );
}
async startMonitoring () {
if ( this . isMonitoring ) return ;
this . isMonitoring = true ;
console . log ( 'Starting health monitoring...' );
const monitor = async () => {
if ( ! this . isMonitoring ) return ;
try {
const health = await this . checkHealth ();
if ( this . hasHealthChanged ( health )) {
this . notifyListeners ( health );
}
this . lastHealth = health ;
} catch ( error ) {
console . error ( 'Health monitoring error:' , error );
}
if ( this . isMonitoring ) {
setTimeout ( monitor , this . interval );
}
};
monitor ();
}
stopMonitoring () {
this . isMonitoring = false ;
console . log ( 'Stopping health monitoring...' );
}
async checkHealth () {
const response = await fetch ( 'https://api.strike.markets/health' );
return await response . json ();
}
hasHealthChanged ( newHealth ) {
if ( ! this . lastHealth ) return true ;
return (
this . lastHealth . status !== newHealth . status ||
JSON . stringify ( this . lastHealth . services ) !== JSON . stringify ( newHealth . services )
);
}
notifyListeners ( health ) {
this . listeners . forEach ( callback => {
try {
callback ( health , this . lastHealth );
} catch ( error ) {
console . error ( 'Health change listener error:' , error );
}
});
}
getHealthSummary ( health ) {
const unhealthyServices = Object . entries ( health . services )
. filter (([ _ , service ]) => service . status !== 'healthy' )
. map (([ name , _ ]) => name );
return {
status: health . status ,
timestamp: health . timestamp ,
uptime: health . uptime ,
unhealthyServices: unhealthyServices ,
activeUsers: health . metrics . active_users ,
openPositions: health . metrics . open_positions
};
}
}
// Usage
const monitor = new HealthMonitor ( 10000 ); // Check every 10 seconds
monitor . onHealthChange (( currentHealth , previousHealth ) => {
const summary = monitor . getHealthSummary ( currentHealth );
if ( previousHealth && previousHealth . status !== currentHealth . status ) {
console . log ( `🚨 Status changed: ${ previousHealth . status } → ${ currentHealth . status } ` );
}
if ( summary . unhealthyServices . length > 0 ) {
console . log ( `⚠️ Unhealthy services: ${ summary . unhealthyServices . join ( ', ' ) } ` );
}
// Update dashboard UI
updateDashboard ( summary );
});
await monitor . startMonitoring ();
function updateDashboard ( summary ) {
// Update your monitoring dashboard with the health summary
document . getElementById ( 'status' ). textContent = summary . status ;
document . getElementById ( 'uptime' ). textContent = ` ${ Math . floor ( summary . uptime / 3600 ) } h` ;
document . getElementById ( 'users' ). textContent = summary . activeUsers . toLocaleString ();
document . getElementById ( 'positions' ). textContent = summary . openPositions . toLocaleString ();
}
Status Page Integration
class StatusPage {
constructor () {
this . statusHistory = [];
this . maxHistory = 100 ;
}
async generateStatusReport () {
const health = await fetch ( 'https://api.strike.markets/health' ). then ( r => r . json ());
const report = {
timestamp: new Date (). toISOString (),
overall: {
status: health . status ,
uptime: health . uptime ,
environment: health . environment
},
services: Object . entries ( health . services ). map (([ name , data ]) => ({
name: name . charAt ( 0 ). toUpperCase () + name . slice ( 1 ),
status: data . status ,
responseTime: data . response_time_ms ,
statusIcon: this . getStatusIcon ( data . status )
})),
metrics: {
activeUsers: health . metrics . active_users . toLocaleString (),
openPositions: health . metrics . open_positions . toLocaleString (),
dailyVolume: `$ ${ Number ( health . metrics . total_volume_24h ). toLocaleString () } `
},
incidents: this . getActiveIncidents ( health )
};
this . addToHistory ( report );
return report ;
}
getStatusIcon ( status ) {
const icons = {
healthy: '🟢' ,
degraded: '🟡' ,
unhealthy: '🔴'
};
return icons [ status ] || '⚪' ;
}
getActiveIncidents ( health ) {
const incidents = [];
Object . entries ( health . services ). forEach (([ serviceName , serviceData ]) => {
if ( serviceData . status !== 'healthy' ) {
incidents . push ({
service: serviceName ,
status: serviceData . status ,
message: ` ${ serviceName } is experiencing ${ serviceData . status === 'degraded' ? 'performance issues' : 'connectivity problems' } ` ,
responseTime: serviceData . response_time_ms
});
}
});
return incidents ;
}
addToHistory ( report ) {
this . statusHistory . unshift ( report );
if ( this . statusHistory . length > this . maxHistory ) {
this . statusHistory = this . statusHistory . slice ( 0 , this . maxHistory );
}
}
getUptimePercentage ( hours = 24 ) {
const recentReports = this . statusHistory . slice ( 0 , hours );
if ( recentReports . length === 0 ) return 100 ;
const healthyCount = recentReports . filter ( r => r . overall . status === 'healthy' ). length ;
return (( healthyCount / recentReports . length ) * 100 ). toFixed ( 2 );
}
}
// Usage
const statusPage = new StatusPage ();
setInterval ( async () => {
const report = await statusPage . generateStatusReport ();
console . log ( '📊 Status Report:' , report );
// Display uptime percentage
const uptime = statusPage . getUptimePercentage ();
console . log ( `📈 24h Uptime: ${ uptime } %` );
}, 60000 ); // Generate report every minute
Integration Patterns
Load Balancer Health Checks
# HAProxy health check configuration
backend strike_api
option httpchk GET /health
http-check expect status 200
http-check expect string "healthy"
server api1 10.0.1.10:8000 check
server api2 10.0.1.11:8000 check
Kubernetes Readiness Probe
readinessProbe :
httpGet :
path : /health
port : 8000
initialDelaySeconds : 10
periodSeconds : 5
timeoutSeconds : 3
successThreshold : 1
failureThreshold : 3
Monitoring Alerts
// Prometheus metrics collection
function collectHealthMetrics ( health ) {
// Overall status (0 = unhealthy, 1 = degraded, 2 = healthy)
const statusValue = { unhealthy: 0 , degraded: 1 , healthy: 2 }[ health . status ];
prometheus . gauge ( 'strike_api_health_status' ). set ( statusValue );
// Service-specific metrics
Object . entries ( health . services ). forEach (([ service , data ]) => {
prometheus . gauge ( 'strike_service_response_time_ms' , { service }). set ( data . response_time_ms );
prometheus . gauge ( 'strike_service_status' , { service }). set (
{ unhealthy: 0 , degraded: 1 , healthy: 2 }[ data . status ]
);
});
// Operational metrics
prometheus . gauge ( 'strike_active_users' ). set ( health . metrics . active_users );
prometheus . gauge ( 'strike_open_positions' ). set ( health . metrics . open_positions );
prometheus . gauge ( 'strike_daily_volume_usd' ). set ( Number ( health . metrics . total_volume_24h ));
}
Use this endpoint for automated monitoring, status pages, and load balancer health checks. The response includes both high-level status and detailed service metrics.
A “degraded” status indicates some services are experiencing issues but the system remains functional. An “unhealthy” status suggests critical problems that may affect trading operations.