API Reference
Complete documentation for God Panel's API endpoints and services.
Overview
The God Panel API provides RESTful endpoints for all application functionality. The API is built with nuxt 4's server-side capabilities and follows RESTful conventions.
Base URL
Production: https://api.your-domain.com
Development: http://localhost:3000/apiAuthentication
Most API endpoints require authentication. Include the JWT token in the Authorization header:
curl -H "Authorization: Bearer your-jwt-token" \
https://api.your-domain.com/api/usersResponse Format
All API responses follow a consistent format:
{
"success": true,
"data": {
// Response data
},
"message": "Operation successful",
"timestamp": "2025-01-15T10:30:00Z"
}Error Format
Error responses include detailed information:
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input data",
"details": {
"email": ["Email is required"],
"password": ["Password must be at least 8 characters"]
}
},
"timestamp": "2025-01-15T10:30:00Z"
}Rate Limiting
API requests are rate-limited to prevent abuse:
- Default: 100 requests per minute per IP
- Authenticated: 1000 requests per minute per user
- Headers: Rate limit information is included in response headers
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200Endpoints
Authentication
Login
POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}Response:
{
"success": true,
"data": {
"user": {
"id": "123",
"email": "user@example.com",
"name": "John Doe"
},
"token": "eyJhbGciOiJIUzI1NiIs...",
"expiresAt": "2025-01-15T11:30:00Z"
}
}Register
POST /api/auth/register
Content-Type: application/json
{
"name": "John Doe",
"email": "user@example.com",
"password": "password123",
"password_confirmation": "password123"
}Logout
POST /api/auth/logout
Authorization: Bearer your-jwt-tokenRefresh Token
POST /api/auth/refresh
Authorization: Bearer your-jwt-tokenUsers
Get Current User
GET /api/users/me
Authorization: Bearer your-jwt-tokenUpdate Profile
PUT /api/users/me
Authorization: Bearer your-jwt-token
Content-Type: application/json
{
"name": "Updated Name",
"email": "newemail@example.com"
}Change Password
PUT /api/users/me/password
Authorization: Bearer your-jwt-token
Content-Type: application/json
{
"current_password": "oldpassword",
"password": "newpassword123",
"password_confirmation": "newpassword123"
}List Users (Admin)
GET /api/users
Authorization: Bearer admin-jwt-tokenQuery Parameters:
page: Page number (default: 1)limit: Items per page (default: 20)search: Search termrole: Filter by role
Get User by ID (Admin)
GET /api/users/{id}
Authorization: Bearer admin-jwt-tokenCreate User (Admin)
POST /api/users
Authorization: Bearer admin-jwt-token
Content-Type: application/json
{
"name": "New User",
"email": "newuser@example.com",
"password": "password123",
"role": "user"
}Update User (Admin)
PUT /api/users/{id}
Authorization: Bearer admin-jwt-token
Content-Type: application/json
{
"name": "Updated Name",
"email": "updated@example.com",
"role": "admin"
}Delete User (Admin)
DELETE /api/users/{id}
Authorization: Bearer admin-jwt-tokenSettings
Get Settings
GET /api/settings
Authorization: Bearer your-jwt-tokenUpdate Settings
PUT /api/settings
Authorization: Bearer your-jwt-token
Content-Type: application/json
{
"theme": "dark",
"language": "en",
"notifications": {
"email": true,
"push": false
}
}Get Public Settings
GET /api/settings/publicDashboard
Get Dashboard Data
GET /api/dashboard
Authorization: Bearer your-jwt-tokenResponse:
{
"success": true,
"data": {
"stats": {
"users": 1250,
"orders": 89,
"revenue": 45678.90,
"growth": 12.5
},
"recentActivity": [...],
"charts": {
"users": [...],
"revenue": [...]
}
}
}Get Widget Data
GET /api/dashboard/widgets/{widgetId}
Authorization: Bearer your-jwt-tokenContent Management
List Content
GET /api/content
Authorization: Bearer your-jwt-tokenQuery Parameters:
type: Content type filterstatus: Status filter (draft, published, archived)page: Page numberlimit: Items per page
Get Content by ID
GET /api/content/{id}
Authorization: Bearer your-jwt-tokenCreate Content
POST /api/content
Authorization: Bearer your-jwt-token
Content-Type: application/json
{
"title": "New Article",
"content": "Article content in markdown",
"type": "blog",
"status": "draft",
"tags": ["tag1", "tag2"]
}Update Content
PUT /api/content/{id}
Authorization: Bearer your-jwt-token
Content-Type: application/json
{
"title": "Updated Article",
"content": "Updated content",
"status": "published"
}Delete Content
DELETE /api/content/{id}
Authorization: Bearer your-jwt-tokenFile Upload
Upload File
POST /api/upload
Authorization: Bearer your-jwt-token
Content-Type: multipart/form-data
file: (binary file data)Response:
{
"success": true,
"data": {
"id": "file_123",
"filename": "uploaded-file.jpg",
"url": "https://cdn.your-domain.com/uploads/uploaded-file.jpg",
"size": 2048576,
"mimeType": "image/jpeg"
}
}Delete File
DELETE /api/upload/{fileId}
Authorization: Bearer your-jwt-tokenHealth & Monitoring
Health Check
GET /api/healthResponse:
{
"status": "healthy",
"timestamp": "2025-01-15T10:30:00Z",
"version": "2.0.0",
"services": {
"database": "connected",
"redis": "connected",
"storage": "available"
},
"uptime": "7d 14h 32m"
}System Metrics
GET /api/metrics
Authorization: Bearer admin-jwt-tokenResponse:
{
"success": true,
"data": {
"cpu": 45.2,
"memory": 67.8,
"disk": 23.1,
"network": {
"inbound": 1024,
"outbound": 2048
},
"requests": {
"total": 15432,
"successful": 15321,
"failed": 111
}
}
}Status Codes
| Code | Description |
|---|---|
| 200 | Success |
| 201 | Created |
| 204 | No Content |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 422 | Validation Error |
| 429 | Rate Limited |
| 500 | Internal Server Error |
Client Libraries
API Client Service
For frontend applications, use the built-in API Client Service:
import { apiClient } from '~/services/api-client'
// Simple GET request
const users = await apiClient.get('/api/users')
// POST with automatic error handling
const newUser = await apiClient.post('/api/users', userData)→ API Client Service Documentation - Complete HTTP client documentation
JavaScript SDK
npm install @god-panel/sdkimport { GodPanel } from '@god-panel/sdk'
const client = new GodPanel({
baseURL: 'https://api.your-domain.com',
apiKey: 'your-api-key'
})
const users = await client.users.list()TypeScript Types
npm install @god-panel/typesimport type { User, ApiResponse } from '@god-panel/types'
const response: ApiResponse<User[]> = await $fetch('/api/users')Webhooks
Configure webhooks to receive real-time notifications:
Webhook Events
user.createduser.updateduser.deletedcontent.publishedcontent.updatedsystem.alert
Webhook Configuration
POST /api/webhooks
Authorization: Bearer your-jwt-token
Content-Type: application/json
{
"url": "https://your-app.com/webhooks",
"events": ["user.created", "content.published"],
"secret": "your-webhook-secret"
}API Versions
Current API version: v1
Versioning Strategy
- URL versioning:
/api/v1/users - Header versioning:
Accept: application/vnd.god-panel.v1+json
Changelog
Check the Changelog for API changes and migration guides.
Support
Getting Help
- Documentation: This API reference
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Rate Limits
- Review your current usage in response headers
- Request limit increases for verified applications
- Implement exponential backoff for retries
Breaking Changes
- Major version updates may include breaking changes
- Review changelog before upgrading
- Test thoroughly in staging environment
Next Steps
- Authentication Guide - Implement user authentication
- Integration Examples - Code examples
- Contributing - Help improve the API