API Documentation
Overview
This API provides various endpoints for managing clients, installations, devices, and user
authentication. It is built using [Link], Express, and MySQL, and includes functionalities for user
authentication, device status monitoring, and data manipulation.
Setup Instructions
1. Install dependencies:
npm install
2. Configure environment variables:
Create a .env file with the following variables:
DB_HOST=<your-database-host>
DB_USER=<your-database-user>
DB_PASSWORD=<your-database-password>
JWT_SECRET=<your-jwt-secret>
GRAPH_ENDPOINT=<your-graph-endpoint>
3. Run the server:
node [Link]
Endpoints
Authentication
Login
Endpoint: /api/login
Method: POST
Description: Authenticates a user and returns JWT tokens.
Request Body:
"Username": "string",
"Password": "string"
Response:
"accessToken": "string",
"refreshToken": "string"
Refresh Token
Endpoint: /api/refresh
Method: POST
Description: Refreshes the access token using the refresh token.
Request Body: None
Response:
"accessToken": "string"
Logout
Endpoint: /api/Logout
Method: POST
Description: Logs out the user and clears the tokens.
Request Body: None
Response: Logged out successfully
Client Management
Get Client Status
Endpoint: /api/GetClientStatus
Method: GET
Description: Retrieves the status of all clients.
Response:
"Client": "string",
"Connection": "boolean",
"LastHeartbeat": "string",
"ID": "number"
Device Management
Add Device
Endpoint: /api/add/Devices
Method: POST
Description: Adds a new device.
Request Body:
"Unique_ID": "string",
"Name": "string",
...
Response: Success
Get Devices
Endpoint: /api/GetDevices
Method: POST
Description: Retrieves devices based on client or installation.
Request Body:
"Client": "number",
"Installation": "number"
Response:
"ID": "number",
"Name": "string",
...
Installation Management
Get Installations
Endpoint: /api/GetInstallations
Method: POST
Description: Retrieves installations based on client.
Request Body:
"Client": "number"
Response:
"ID": "number",
"Name": "string",
...
Heartbeat Management
Heartbeat
Endpoint: /api/V2/Heartbeat
Method: POST
Description: Records a heartbeat from a device and returns plugin checksum.
Request Body:
"Device_ID": "string"
Response: string
Example Error Responses
401 Unauthorized: Missing or invalid authentication token.
404 Not Found: Requested resource not found.
409 Conflict: Resource already exists.
500 Internal Server Error: General server error.