- Organization ID: 1
- Organization Name: Test Organization Inc
- Contact Name: John Doe
- Email: admin@test.com
- Client ID: testorgani_c4a6a01a
- API Key: dcx_EXAMPLE_API_KEY_FOR_TESTING
- Development Base URL: http://localhost:8081
- Production API Endpoint: https://api.datacorex.com/v1
Use for administrative operations:
curl -H "X-API-Key: dcx_UvYRRWRpRhpDSH6PMXAyVkrCiFYxGa7Q" \
http://localhost:8081/api/endpointFor user-specific operations:
# Login to get token
curl -X POST http://localhost:8081/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"your_username","password":"your_password"}'
# Use token in requests
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
http://localhost:8081/api/endpointFor organization dashboard access:
curl -X POST http://localhost:8081/api/organization/login \
-H "Content-Type: application/json" \
-d '{"email":"admin@test.com","password":"password123"}'- Register User:
POST /api/auth/register - Login User:
POST /api/auth/login - Get User Info:
GET /api/auth/me - User Operations:
GET /api/users
- Upload Files:
POST /api/storage/upload - List Files:
GET /api/storage/files - Download Files:
GET /api/storage/files/{id}/download - File Search:
GET /api/storage/search?query=filename
- Create Document:
POST /api/realtime-db/organizations/{orgId}/collections/{collection}/documents - Get Document:
GET /api/realtime-db/organizations/{orgId}/collections/{collection}/documents/{docId} - Query Collection:
POST /api/realtime-db/organizations/{orgId}/collections/{collection}/query
- WebSocket Connection:
ws://localhost:8081/ws - Send to User:
POST /api/realtime/send-to-user - Broadcast Message:
POST /api/realtime/broadcast - Live Data Updates:
POST /api/realtime/live-data
- Deploy Function:
POST /api/functions/deploy - Execute Function:
POST /api/functions/execute/{functionId} - List Functions:
GET /api/functions/list/{organizationId}
- Push Notifications:
POST /api/firebase/send-notification - Topic Notifications:
POST /api/firebase/send-to-topic - Multicast:
POST /api/firebase/send-multicast
- Activity Logs:
GET /api/activity-logs - System Health:
GET /api/health - System Info:
GET /api/system/info - System Metrics:
GET /api/system/metrics - Current Metrics:
GET /api/realtime-data/metrics/current - Metric History:
GET /api/realtime-data/metrics/{metricName}/history - Usage Stats:
GET /api/billing/organizations/{orgId}/stats - Usage Limits:
GET /api/billing/organizations/{orgId}/limits/check
- List Nodes:
GET /api/nodes - Add Node:
POST /api/nodes - Get Node:
GET /api/nodes/{id} - Update Node:
PUT /api/nodes/{id} - Delete Node:
DELETE /api/nodes/{id} - Update Health:
POST /api/nodes/{id}/health
- Create API Key:
POST /api/keys - Validate API Key:
POST /api/keys/validate - Get Organization Keys:
GET /api/keys/organization/{organizationId} - Deactivate Key:
DELETE /api/keys/{id}
- Execute Script:
POST /api/system/scripts/execute - Available Scripts:
GET /api/system/scripts - Start Maintenance:
POST /api/system/maintenance/start - Stop Maintenance:
POST /api/system/maintenance/stop
- System Information:
GET /api/debug/system-info - Environment Variables:
GET /api/debug/environment - Recent Errors:
GET /api/debug/errors - Test Logging:
POST /api/debug/test-log - Garbage Collection:
POST /api/debug/gc
class DataCoreXClient {
constructor() {
this.baseUrl = 'http://localhost:8081'
this.apiKey = 'dcx_UvYRRWRpRhpDSH6PMXAyVkrCiFYxGa7Q'
this.organizationId = 1
}
async authenticateUser(username, password) {
const response = await fetch(`${this.baseUrl}/api/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password }),
})
const data = await response.json()
if (data.success) {
localStorage.setItem('dcx_token', data.token)
return data.user
}
throw new Error(data.message)
}
async uploadFile(file) {
const formData = new FormData()
formData.append('file', file)
const response = await fetch(`${this.baseUrl}/api/storage/upload`, {
method: 'POST',
headers: {
Authorization: `Bearer ${localStorage.getItem('dcx_token')}`,
},
body: formData,
})
return response.json()
}
async createDocument(collection, data) {
const response = await fetch(
`${this.baseUrl}/api/realtime-db/organizations/${this.organizationId}/collections/${collection}/documents`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${localStorage.getItem('dcx_token')}`,
},
body: JSON.stringify(data),
}
)
return response.json()
}
connectWebSocket() {
const ws = new WebSocket(`ws://localhost:8081/ws`)
ws.onopen = () => console.log('Connected to DataCoreX real-time')
ws.onmessage = (event) => {
const data = JSON.parse(event.data)
this.handleRealtimeUpdate(data)
}
return ws
}
handleRealtimeUpdate(data) {
// Handle real-time updates in your website
console.log('Real-time update:', data)
}
}
// Usage
const dcx = new DataCoreXClient()const axios = require('axios')
class DataCoreXServer {
constructor() {
this.baseUrl = 'http://localhost:8081'
this.apiKey = 'dcx_UvYRRWRpRhpDSH6PMXAyVkrCiFYxGa7Q'
this.organizationId = 1
}
async deployFunction(name, code, runtime = 'javascript') {
try {
const response = await axios.post(
`${this.baseUrl}/api/functions/deploy?name=${name}&runtime=${runtime}&organizationId=${this.organizationId}`,
{ code },
{
headers: {
'X-API-Key': this.apiKey,
'Content-Type': 'application/json',
},
}
)
return response.data
} catch (error) {
console.error('Function deployment failed:', error.response?.data)
throw error
}
}
async trackUsage(eventType, metadata = {}) {
try {
const response = await axios.post(
`${this.baseUrl}/api/realtime-data/publish`,
{
dataType: 'usage_tracking',
data: {
organizationId: this.organizationId,
eventType,
timestamp: new Date().toISOString(),
metadata,
},
},
{
headers: {
'X-API-Key': this.apiKey,
'Content-Type': 'application/json',
},
}
)
return response.data
} catch (error) {
console.error('Usage tracking failed:', error.response?.data)
}
}
}curl -X POST http://localhost:8081/api/organization/login \
-H "Content-Type: application/json" \
-d '{"email":"admin@test.com","password":"password123"}'curl -X POST http://localhost:8081/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"websiteuser","email":"user@yourwebsite.com","password":"password123","role":"USER"}'curl http://localhost:8081/api/healthOpen in browser: http://localhost:8081/api-docs
# Create a document in a collection
curl -X POST "http://localhost:8081/api/realtime-db/organizations/1/collections/users/documents" \
-H "Content-Type: application/json" \
-H "X-API-Key: dcx_UvYRRWRpRhpDSH6PMXAyVkrCiFYxGa7Q" \
-d '{"name":"John Doe","email":"john@example.com","created":"2025-01-01"}'
# Query documents
curl -X POST "http://localhost:8081/api/realtime-db/organizations/1/collections/users/query" \
-H "Content-Type: application/json" \
-H "X-API-Key: dcx_UvYRRWRpRhpDSH6PMXAyVkrCiFYxGa7Q" \
-d '{"where":{"name":"John Doe"}}'# Get system metrics
curl -H "X-API-Key: dcx_UvYRRWRpRhpDSH6PMXAyVkrCiFYxGa7Q" \
http://localhost:8081/api/system/metrics
# Get real-time data statistics
curl http://localhost:8081/api/realtime-data/statistics# Deploy a simple function
curl -X POST "http://localhost:8081/api/functions/deploy?name=hello&runtime=javascript&organizationId=1" \
-H "Content-Type: application/json" \
-H "X-API-Key: dcx_UvYRRWRpRhpDSH6PMXAyVkrCiFYxGa7Q" \
-d '{"code":"function main(input) { return {message: \"Hello \" + (input.name || \"World\")}; }"}'
# List functions for your organization
curl -H "X-API-Key: dcx_UvYRRWRpRhpDSH6PMXAyVkrCiFYxGa7Q" \
http://localhost:8081/api/functions/list/1When moving to production:
- Update
baseUrlto your production DataCoreX server - Use HTTPS endpoints
- Store API keys securely (environment variables)
- Implement proper error handling
- Set up monitoring and logging
- API Documentation: http://localhost:8081/api-docs
- H2 Database Console: http://localhost:8081/h2-console
- Health Status: http://localhost:8081/actuator/health
- Application Dashboard: http://localhost:8081/
POST /api/organization/register- Register new organizationPOST /api/organization/login- Organization authenticationGET /api/organization/profile/{organizationId}- Get organization profilePOST /api/organization/regenerate-api-key/{organizationId}- Regenerate API key
POST /api/auth/register- Register new userPOST /api/auth/login- User authenticationPOST /api/auth/logout- User logoutPOST /api/auth/verify-token- Verify JWT tokenGET /api/auth/me- Get current user infoGET /api/users- List all usersPATCH /api/users/{id}- Update userDELETE /api/users/{id}- Delete user
POST /api/storage/upload- Upload filePOST /api/storage/upload-url- Generate pre-signed upload URLGET /api/storage/files- List all filesGET /api/storage/files/my- Get current user's filesGET /api/storage/files/{id}- Get file detailsGET /api/storage/files/{id}/download- Download fileDELETE /api/storage/files/{id}- Delete fileGET /api/storage/search- Search files by filenameGET /api/storage/stats- Get storage statistics
POST /api/realtime-db/organizations/{orgId}/collections/{collection}/documents- Create documentGET /api/realtime-db/organizations/{orgId}/collections/{collection}/documents/{docId}- Get documentPUT /api/realtime-db/organizations/{orgId}/collections/{collection}/documents/{docId}- Update documentDELETE /api/realtime-db/organizations/{orgId}/collections/{collection}/documents/{docId}- Delete documentPOST /api/realtime-db/organizations/{orgId}/collections/{collection}/query- Query collectionGET /api/realtime-db/organizations/{orgId}/stats- Get real-time stats
GET /api/realtime/status- Get real-time service statusGET /api/realtime/connections- Get active WebSocket connectionsPOST /api/realtime/system-notification- Send system notificationPOST /api/realtime/send-to-user- Send message to specific userPOST /api/realtime/send-to-channel- Send message to channelPOST /api/realtime/broadcast- Broadcast to all connected clientsPOST /api/realtime/live-data- Send live data updates
POST /api/realtime-data/publish- Publish data to streamsPOST /api/realtime-data/metrics- Record custom metricPOST /api/realtime-data/metrics/node-performance- Record node performanceGET /api/realtime-data/statistics- Get service statisticsGET /api/realtime-data/metrics/current- Get current metricsGET /api/realtime-data/metrics/{metricName}/history- Get metric historyGET /api/realtime-data/metrics/{metricName}/summary- Get metric summaryGET /api/realtime-data/cached-data- Get all cached dataGET /api/realtime-data/cached-data/{dataType}- Get cached data by type
POST /api/functions/deploy- Deploy serverless functionPOST /api/functions/execute/{functionId}- Execute functionGET /api/functions/{functionId}- Get function detailsGET /api/functions/{functionId}/logs- Get function execution logsDELETE /api/functions/{functionId}- Delete functionGET /api/functions/list/{organizationId}- List organization functionsGET /api/functions/health- Check functions service health
POST /api/firebase/send-notification- Send push notificationPOST /api/firebase/send-multicast- Send to multiple devicesPOST /api/firebase/send-to-topic- Send to topic subscribersPOST /api/firebase/subscribe-to-topic- Subscribe device to topicPOST /api/firebase/unsubscribe-from-topic- Unsubscribe from topicPOST /api/firebase/validate-token- Validate device tokenGET /api/firebase/status- Get Firebase service status
GET /api/nodes- List all nodesPOST /api/nodes- Add new nodeGET /api/nodes/{id}- Get node detailsPUT /api/nodes/{id}- Update nodeDELETE /api/nodes/{id}- Delete nodePOST /api/nodes/{id}/health- Update node health
GET /api/system/health- System health checkGET /api/system/info- System informationGET /api/system/metrics- System metricsGET /api/system/scripts- Available scriptsPOST /api/system/scripts/execute- Execute system scriptPOST /api/system/maintenance/start- Start maintenance modePOST /api/system/maintenance/stop- Stop maintenance mode
GET /api/activity-logs- Get all activity logs (paginated)GET /api/activity-logs/{id}- Get specific log entryGET /api/activity-logs/user/{userId}- Get logs by userGET /api/activity-logs/level/{level}- Get logs by levelGET /api/activity-logs/category/{category}- Get logs by categoryGET /api/activity-logs/action/{action}- Get logs by actionGET /api/activity-logs/search- Search logs by descriptionGET /api/activity-logs/date-range- Get logs within date rangeGET /api/activity-logs/statistics- Get log statisticsDELETE /api/activity-logs/cleanup- Cleanup old logs
GET /api/billing/organizations/{orgId}/usage/current- Current month usageGET /api/billing/organizations/{orgId}/usage- Usage for date rangeGET /api/billing/organizations/{orgId}/stats- Usage statisticsGET /api/billing/organizations/{orgId}/limits/check- Check usage limits
POST /api/keys- Create new API keyPOST /api/keys/validate- Validate API keyGET /api/keys/organization/{organizationId}- Get organization keysDELETE /api/keys/{id}- Deactivate API key
GET /api/debug/health- Application health checkGET /api/debug/system-info- System and JVM informationGET /api/debug/environment- Environment variablesGET /api/debug/errors- Recent error logsPOST /api/debug/test-log- Create test log entryPOST /api/debug/gc- Trigger garbage collection
POST /api/scripts/run- Run custom script
POST /api/monitoring/health- Get health scoreGET /api/info- API informationGET /api/health- Health check endpointGET /api/audit- Audit logs
Your DataCoreX BaaS platform is ready for integration! 🚀