The NEPA platform provides a comprehensive RESTful API following OpenAPI 3.0 specifications for decentralized utility payments, DeFi yield generation, and third-party integrations.
- v1: Legacy API with basic functionality
- v2: Current version with enhanced features and OAuth 2.0
- Latest: Always points to v2 (current stable version)
- Production:
https://api.nepa.com/v2 - Staging:
https://staging-api.nepa.com/v2 - Sandbox:
https://sandbox-api.nepa.com/v2
- OAuth 2.0: Primary authentication method
- JWT Bearer Tokens: For API access
- API Keys: For service-to-service communication
- OAuth 2.0 authorization flow
- User profile management
- Token refresh and verification
- Role-based access control
- Utility bill payments
- Payment history and analytics
- Scheduled and bulk payments
- Multi-method payment support
- Yield strategy management
- Position tracking and performance
- Automated strategy execution
- Risk assessment and monitoring
- Credit score retrieval
- Fraud detection
- Credit monitoring and alerts
- Dispute management
- Account linking and management
- Transaction processing
- Balance inquiries
- Account validation
- Provider discovery and linking
- Bill retrieval and payment
- Usage analytics and reporting
- Service outage monitoring
- Dashboard analytics
- Payment analytics
- Usage analytics
- Yield performance metrics
GET /api/health
GET /api/v2/health
Returns API health status, uptime, and service metrics.
POST /api/v2/auth/oauth/authorize
POST /api/v2/auth/oauth/token
GET /api/v2/auth/verify
GET /api/v2/users/profile
PUT /api/v2/users/profile
GET /api/v2/users/preferences
PUT /api/v2/users/preferences
GET /api/v2/payments/bills
POST /api/v2/payments/bills
GET /api/v2/payments/bills/{billId}
GET /api/v2/payments/history
POST /api/v2/payments/schedule
POST /api/v2/payments/bulk
GET /api/v2/yield/strategies
POST /api/v2/yield/deploy
POST /api/v2/yield/withdraw
GET /api/v2/yield/positions
GET /api/v2/yield/performance
POST /api/v2/yield/automated/start
POST /api/v2/yield/automated/stop
GET /api/v2/credit/score
GET /api/v2/credit/report
POST /api/v2/credit/fraud/detect
GET /api/v2/credit/monitoring
GET /api/v2/banking/accounts
POST /api/v2/banking/link
POST /api/v2/banking/payments
GET /api/v2/banking/transactions
POST /api/v2/banking/validate
GET /api/v2/utilities/providers
POST /api/v2/utilities/link
GET /api/v2/utilities/bills
POST /api/v2/utilities/payments
GET /api/v2/utilities/usage
GET /api/v2/utilities/outages
GET /api/v2/analytics/dashboard
GET /api/v2/analytics/payments
GET /api/v2/analytics/usage
GET /api/v2/analytics/yield
{
"success": true,
"data": { ... },
"error": {
"code": "ERROR_CODE",
"message": "Human readable error message",
"details": { ... }
},
"meta": {
"timestamp": "2024-02-21T12:00:00Z",
"requestId": "req_123456789",
"version": "2.0.0",
"pagination": {
"page": 1,
"limit": 20,
"total": 100,
"totalPages": 5
}
}
}- 400 Bad Request: Validation errors
- 401 Unauthorized: Authentication required
- 403 Forbidden: Insufficient permissions
- 404 Not Found: Endpoint not found
- 429 Too Many Requests: Rate limiting
- 500 Internal Server Error: Server errors
- Window: 60 seconds
- Max Requests: 100 per window
- Headers: Rate limiting headers included
- OAuth 2.0 with PKCE
- JWT tokens with expiration
- Refresh token rotation
- Multi-factor authentication support
- Content Security Policy (CSP)
- CORS configuration
- XSS protection
- Frame options
- Request schema validation
- Input sanitization
- SQL injection prevention
- XSS protection
- Correlation IDs for request tracking
- Request/response timing
- User identification
- Error tracking
- Response time metrics
- Error rate monitoring
- Rate limiting tracking
- Service health checks
- Real-time error alerts
- Performance degradation alerts
- Security incident notifications
- Unit tests for all endpoints
- Integration tests for workflows
- Performance testing
- Security testing
- Load testing
- Mock data for consistent testing
- Test user accounts
- Test payment scenarios
- Error condition testing
- File:
src/api/openapi.yaml - Format: OpenAPI 3.0.3
- Tools: Swagger UI, Postman Collection
- Swagger UI:
/api/docs/swagger - Postman Collection:
/api/docs/postman - API Versioning:
/api/docs
{
"dependencies": {
"express": "^4.18.2",
"cors": "^2.8.5",
"helmet": "^7.1.0",
"compression": "^1.7.4",
"express-rate-limit": "^7.1.5",
"joi": "^17.11.0",
"winston": "^3.11.0",
"dotenv": "^16.3.1"
},
"devDependencies": {
"jest": "^29.7.0",
"supertest": "^6.3.3",
"@types/jest": "^29.5.8",
"typescript": "^5.6.2"
}
}# Development
npm run dev
# Testing
npm run test
npm run test:watch
npm run test:coverage
# Build
npm run build
# Production
npm start- RESTful principles
- Consistent response formats
- Proper HTTP status codes
- Pagination support
- Filtering and sorting
- Input validation
- Authentication middleware
- Rate limiting
- Security headers
- Response compression
- Request caching
- Database optimization
- CDN integration
- Structured logging
- Performance metrics
- Error tracking
- Health checks
import axios from 'axios';
const apiClient = axios.create({
baseURL: 'https://api.nepa.com/v2',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
}
});
// Get user profile
const profile = await apiClient.get('/users/profile');
// Pay bill
const payment = await apiClient.post('/payments/bills', {
bill_id: 'bill-123',
amount: 150.00,
payment_method: 'bank_transfer'
});# Get user profile
curl -X GET "https://api.nepa.com/v2/users/profile" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
# Pay bill
curl -X POST "https://api.nepa.com/v2/payments/bills" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"bill_id": "bill-123",
"amount": 150.00,
"payment_method": "bank_transfer"
}'- Load balancing
- Auto-scaling
- Database replication
- CDN configuration
- SSL/TLS termination
NODE_ENV=production
PORT=3000
API_VERSION=2.0.0
CORS_ORIGINS=https://nepa.com,https://app.nepa.com
RATE_LIMIT_WINDOW=60000
RATE_LIMIT_MAX=100
LOG_LEVEL=info- API Docs: https://docs.nepa.com
- Swagger UI: https://api.nepa.com/docs/swagger
- Postman: https://api.nepa.com/docs/postman
- Email: support@nepa.com
- Discord: https://discord.gg/nepa
- Status Page: https://status.nepa.com
- Real-time: https://status.nepa.com
- Historical: https://status.nepa.com/history
- GraphQL API
- WebSocket support for real-time updates
- Advanced analytics endpoints
- Enhanced security features
- Mobile SDKs
- v2.0.0: Current version with all features
- v1.0.0: Legacy version (maintained for compatibility)
- v0.9.0: Beta version (deprecated)
This comprehensive RESTful API provides a robust foundation for the NEPA platform with proper versioning, security, monitoring, and documentation following industry best practices.