Platform Information
Overviewβ
The /api/info
endpoint provides general platform information, health status, and system metrics. This is a public endpoint that doesn't require authentication and is useful for monitoring and integration purposes.
Endpoint Detailsβ
GET /api/info
Authentication: None required (public endpoint) Rate Limit: 60 requests per minute per IP
Responseβ
Success Response (200)β
{
"platform": {
"name": "Ring Platform",
"version": "1.0.0",
"description": "Revolutionary platform for professional networking and collaboration",
"environment": "production",
"region": "eu-central-1"
},
"status": {
"healthy": true,
"uptime": 2592000,
"timestamp": "2024-12-14T16:00:00Z",
"services": {
"database": "healthy",
"storage": "healthy",
"authentication": "healthy",
"notifications": "healthy",
"search": "healthy"
}
},
"statistics": {
"users": {
"total": 15420,
"active": 8934,
"verified": 12156,
"roles": {
"visitor": 2456,
"subscriber": 6789,
"member": 4321,
"confidential": 1234,
"admin": 12
}
},
"entities": {
"total": 3456,
"verified": 2890,
"categories": {
"startup": 1234,
"enterprise": 567,
"nonprofit": 234,
"government": 89,
"other": 1332
}
},
"opportunities": {
"total": 8765,
"active": 4321,
"types": {
"job": 5432,
"project": 2109,
"partnership": 876,
"investment": 348
}
},
"content": {
"news": 234,
"notifications": 45678
}
},
"features": {
"authentication": {
"providers": ["google", "apple", "metamask", "credentials"],
"web3": true,
"multiProvider": true
},
"content": {
"news": true,
"notifications": true,
"fileUpload": true,
"richText": true
},
"admin": {
"userManagement": true,
"contentManagement": true,
"analytics": true,
"roleManagement": true
},
"api": {
"endpoints": 38,
"rateLimit": true,
"documentation": true,
"versioning": "v1"
}
},
"limits": {
"fileUpload": {
"maxSize": "10MB",
"allowedTypes": ["image/jpeg", "image/png", "image/webp", "application/pdf", "text/plain"]
},
"rateLimit": {
"default": "60/minute",
"authenticated": "120/minute",
"admin": "300/minute"
},
"content": {
"maxBioLength": 500,
"maxSkills": 20,
"maxInterests": 10,
"maxNewsLength": 10000
}
},
"contact": {
"support": "support@ring.ck.ua",
"admin": "admin@ring.ck.ua",
"website": "https://ring.ck.ua",
"documentation": "https://docs.ring.ck.ua"
},
"legal": {
"termsOfService": "https://ring.ck.ua/terms",
"privacyPolicy": "https://ring.ck.ua/privacy",
"dataProtection": "GDPR compliant",
"lastUpdated": "2024-12-01T00:00:00Z"
}
}
Code Examplesβ
JavaScript/TypeScriptβ
// Get platform information
async function getPlatformInfo() {
try {
const response = await fetch('/api/info', {
headers: {
'Accept': 'application/json'
}
})
if (!response.ok) {
throw new Error('Failed to fetch platform info')
}
const info = await response.json()
return info
} catch (error) {
console.error('Error fetching platform info:', error)
throw error
}
}
// Check platform health
async function checkPlatformHealth() {
try {
const info = await getPlatformInfo()
return {
isHealthy: info.status.healthy,
services: info.status.services,
uptime: info.status.uptime
}
} catch (error) {
return {
isHealthy: false,
error: error.message
}
}
}
// Get platform statistics
async function getPlatformStats() {
try {
const info = await getPlatformInfo()
return info.statistics
} catch (error) {
console.error('Error fetching platform stats:', error)
return null
}
}
React Component Exampleβ
import { useState, useEffect } from 'react'
interface PlatformInfo {
platform: {
name: string
version: string
environment: string
}
status: {
healthy: boolean
uptime: number
services: Record<string, string>
}
statistics: {
users: { total: number; active: number }
entities: { total: number }
opportunities: { total: number; active: number }
}
}
export function PlatformStatus() {
const [info, setInfo] = useState<PlatformInfo | null>(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null)
useEffect(() => {
fetchPlatformInfo()
// Refresh every 30 seconds
const interval = setInterval(fetchPlatformInfo, 30000)
return () => clearInterval(interval)
}, [])
const fetchPlatformInfo = async () => {
try {
const response = await fetch('/api/info')
if (!response.ok) throw new Error('Failed to fetch')
const data = await response.json()
setInfo(data)
setError(null)
} catch (err) {
setError(err instanceof Error ? err.message : 'Unknown error')
} finally {
setLoading(false)
}
}
if (loading) return <div>Loading platform status...</div>
if (error) return <div>Error: {error}</div>
if (!info) return <div>No data available</div>
return (
<div className="platform-status">
<h2>{info.platform.name} Status</h2>
<div className={`status ${info.status.healthy ? 'healthy' : 'unhealthy'}`}>
Status: {info.status.healthy ? 'β
Healthy' : 'β Issues Detected'}
</div>
<div className="stats">
<div>Users: {info.statistics.users.total.toLocaleString()}</div>
<div>Entities: {info.statistics.entities.total.toLocaleString()}</div>
<div>Opportunities: {info.statistics.opportunities.total.toLocaleString()}</div>
</div>
<div className="services">
<h3>Services</h3>
{Object.entries(info.status.services).map(([service, status]) => (
<div key={service} className={`service ${status}`}>
{service}: {status}
</div>
))}
</div>
</div>
)
}
cURL Exampleβ
# Get platform information
curl -X GET "https://ring.ck.ua/api/info" \
-H "Accept: application/json"
# Check only health status
curl -X GET "https://ring.ck.ua/api/info" \
-H "Accept: application/json" | jq '.status.healthy'
# Get user statistics
curl -X GET "https://ring.ck.ua/api/info" \
-H "Accept: application/json" | jq '.statistics.users'
Python Exampleβ
import requests
import json
def get_platform_info():
"""Get platform information and status"""
try:
response = requests.get('https://ring.ck.ua/api/info')
response.raise_for_status()
return response.json()
except requests.RequestException as e:
print(f"Error fetching platform info: {e}")
return None
def check_platform_health():
"""Check if platform is healthy"""
info = get_platform_info()
if not info:
return False
return info.get('status', {}).get('healthy', False)
def get_platform_stats():
"""Get platform statistics"""
info = get_platform_info()
if not info:
return None
return info.get('statistics', {})
# Usage examples
if __name__ == "__main__":
# Check health
is_healthy = check_platform_health()
print(f"Platform healthy: {is_healthy}")
# Get statistics
stats = get_platform_stats()
if stats:
print(f"Total users: {stats.get('users', {}).get('total', 0)}")
print(f"Active opportunities: {stats.get('opportunities', {}).get('active', 0)}")
Health Check Integrationβ
Docker Health Checkβ
# Dockerfile health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/api/info || exit 1
Kubernetes Liveness Probeβ
# kubernetes deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: ring-platform
spec:
template:
spec:
containers:
- name: ring-app
image: ring-platform:latest
livenessProbe:
httpGet:
path: /api/info
port: 3000
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /api/info
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
Monitoring Integrationβ
// Prometheus metrics endpoint integration
import { register, collectDefaultMetrics, Gauge, Counter } from 'prom-client'
// Collect default metrics
collectDefaultMetrics()
// Custom metrics
const healthGauge = new Gauge({
name: 'ring_platform_health',
help: 'Platform health status (1 = healthy, 0 = unhealthy)'
})
const userCountGauge = new Gauge({
name: 'ring_platform_users_total',
help: 'Total number of users'
})
// Update metrics in /api/info handler
export async function updateMetrics() {
const info = await getPlatformInfo()
healthGauge.set(info.status.healthy ? 1 : 0)
userCountGauge.set(info.statistics.users.total)
}
Error Handlingβ
Service Unavailable (503)β
{
"error": "SERVICE_UNAVAILABLE",
"message": "Platform is temporarily unavailable",
"status": {
"healthy": false,
"services": {
"database": "unhealthy",
"storage": "healthy",
"authentication": "degraded"
}
},
"retryAfter": 60
}
Rate Limit Exceeded (429)β
{
"error": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests",
"retryAfter": 60
}
Response Fieldsβ
Platform Informationβ
Field | Type | Description |
---|---|---|
name | string | Platform name |
version | string | Current platform version |
description | string | Platform description |
environment | string | Environment (production, staging, development) |
region | string | Deployment region |
Status Informationβ
Field | Type | Description |
---|---|---|
healthy | boolean | Overall platform health |
uptime | number | Uptime in seconds |
timestamp | string | Current server timestamp |
services | object | Individual service health status |
Statisticsβ
Field | Type | Description |
---|---|---|
users.total | number | Total registered users |
users.active | number | Active users (last 30 days) |
users.verified | number | Verified users |
entities.total | number | Total entities |
opportunities.total | number | Total opportunities |
opportunities.active | number | Active opportunities |
Cachingβ
Response Cachingβ
- Cache Duration: 60 seconds
- Cache Key:
platform:info
- Invalidation: On service status change
Implementationβ
import { Redis } from 'ioredis'
const redis = new Redis(process.env.REDIS_URL)
export async function getCachedPlatformInfo() {
const cacheKey = 'platform:info'
// Try to get from cache
const cached = await redis.get(cacheKey)
if (cached) {
return JSON.parse(cached)
}
// Generate fresh data
const info = await generatePlatformInfo()
// Cache for 60 seconds
await redis.setex(cacheKey, 60, JSON.stringify(info))
return info
}
Security Considerationsβ
Information Disclosureβ
- Public Data Only: No sensitive information exposed
- Aggregated Statistics: Individual user data not revealed
- Rate Limiting: Prevents abuse and DoS attacks
- No Authentication: Reduces attack surface
Monitoringβ
- Access Logging: All requests logged for monitoring
- Anomaly Detection: Unusual request patterns flagged
- Performance Tracking: Response times monitored
Related Endpointsβ
/api/auth/[...nextauth]
- Authentication status/api/profile
- User profile information/api/entities
- Entity statistics/api/opportunities
- Opportunity statistics
Testingβ
Unit Testsβ
describe('Platform Info API', () => {
test('should return platform information', async () => {
const response = await request(app)
.get('/api/info')
.expect(200)
expect(response.body).toHaveProperty('platform')
expect(response.body).toHaveProperty('status')
expect(response.body).toHaveProperty('statistics')
expect(response.body.status).toHaveProperty('healthy')
})
test('should include all required fields', async () => {
const response = await request(app)
.get('/api/info')
.expect(200)
const { body } = response
// Platform info
expect(body.platform.name).toBe('Ring Platform')
expect(body.platform.version).toMatch(/^\d+\.\d+\.\d+$/)
// Status
expect(typeof body.status.healthy).toBe('boolean')
expect(typeof body.status.uptime).toBe('number')
// Statistics
expect(typeof body.statistics.users.total).toBe('number')
expect(typeof body.statistics.entities.total).toBe('number')
})
})
Integration Testsβ
describe('Platform Info Integration', () => {
test('should reflect actual system state', async () => {
// Create test data
await createTestUser()
await createTestEntity()
const response = await request(app)
.get('/api/info')
.expect(200)
expect(response.body.statistics.users.total).toBeGreaterThan(0)
expect(response.body.statistics.entities.total).toBeGreaterThan(0)
})
})
Troubleshootingβ
Common Issuesβ
Issue: "Service unavailable" Solution: Check individual service health in response
Issue: "Outdated statistics" Solution: Statistics are cached for 60 seconds, wait for refresh
Issue: "Rate limit exceeded" Solution: Reduce request frequency, current limit is 60/minute