A modern, fully-typed TypeScript API for interacting with the Nexecur alarm system. This is an unofficial API that provides a clean, well-documented interface for controlling and monitoring your Nexecur security system.
This project is a complete refactor and modernization of the original codebase of Baudev, featuring improved code structure, comprehensive testing, and robust error handling.
git clone https://github.com/Loule95450/Nexecur-Unofficial-API.git
cd Nexecur-Unofficial-API
npm install
npm run buildConfigure the config.json file with your Nexecur credentials:
{
"token": "",
"id_site": "your-site-id",
"password": "your-password",
"id_device": "",
"pin": "your-pin",
"deviceName": "My API Device"
}Required fields:
id_site: Your site identification number (also called wiring code)password: Your account password (also called PIN)
Optional fields:
deviceName: Display name for this API client in the system logs
The token and id_device fields are automatically populated during device registration.
import { NexecurAPI, AlarmStatus } from 'nexecur-api';
async function main() {
try {
// Get current alarm status
const status = await NexecurAPI.getAlarmStatus();
console.log(`Alarm is currently: ${status === AlarmStatus.Enabled ? 'Armed' : 'Disarmed'}`);
// Enable the alarm
await NexecurAPI.enableAlarm();
console.log('Alarm has been armed');
// Get event history
const events = await NexecurAPI.getEventHistory();
console.log(`Found ${events.length} recent events`);
} catch (error) {
console.error('Error:', error.message);
}
}
main();import {
NexecurAPI,
AlarmStatus,
OrderAlarmError,
UndefinedApiError,
NexecurError
} from 'nexecur-api';
async function controlAlarm() {
try {
const currentStatus = await NexecurAPI.getAlarmStatus();
if (currentStatus === AlarmStatus.Disabled) {
console.log('Arming alarm system...');
await NexecurAPI.enableAlarm();
console.log('β
Alarm system armed successfully');
} else {
console.log('Disarming alarm system...');
await NexecurAPI.disableAlarm();
console.log('β
Alarm system disarmed successfully');
}
} catch (error) {
if (error instanceof OrderAlarmError) {
console.error('π¨ Failed to control alarm:', error.message);
} else if (error instanceof UndefinedApiError) {
console.error('π API communication error:', error.message);
} else if (error instanceof NexecurError) {
console.error(`π§ Nexecur error [${error.code}]:`, error.message);
} else {
console.error('β Unexpected error:', error.message);
}
}
}import { NexecurAPI, UserConfiguration, NexecurConfiguration } from 'nexecur-api';
// Use a custom configuration file location
NexecurConfiguration.setConfigFilePath('./my-custom-config.json');
// Or set configuration programmatically
const customConfig = new UserConfiguration({
idSite: 'your-site-id',
password: 'your-password',
deviceName: 'Custom Device Name'
});
NexecurAPI.setUserConfiguration(customConfig);Returns the current status of the alarm system.
Arms the alarm system. Waits for confirmation that the operation completed.
Disarms the alarm system. Waits for confirmation that the operation completed.
Retrieves the recent event history from the alarm system.
Requests stream (camera) data for a device identified by its serial field as returned in devices from the site payload.
enum AlarmStatus {
Disabled = 0, // Alarm is disarmed
Enabled = 1 // Alarm is armed
}interface IUserConfiguration {
token: string;
idSite: string;
password: string;
idDevice: string;
pin: string;
deviceName: string;
}All errors extend the base NexecurError class and include:
SaltGenerationError: Salt generation failedTokenGenerationError: Authentication token generation failedRegisteringDeviceError: Device registration failedOrderAlarmError: Alarm control operation failedUndefinedApiError: General API communication errorStillPendingError: Operation timeout (took too long to complete)
npm run build # Build TypeScript to JavaScript
npm run build:watch # Build with file watching
npm run clean # Clean build artifactsnpm test # Run all tests
npm run test:watch # Run tests with file watchingsrc/
βββ controllers/ # Main API classes
βββ models/ # Data models and configuration
βββ helpers/ # Utility functions
βββ interfaces/ # TypeScript interfaces
βββ index.ts # Main entry point
tests/ # Test files
βββ *.test.ts # Unit tests for individual components
βββ tests.ts # Integration tests
dist/ # Compiled JavaScript output
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Make your changes and add tests
- Run tests:
npm test - Build the project:
npm run build - Commit your changes:
git commit -am 'Add new feature' - Push to the branch:
git push origin feature/new-feature - Submit a pull request
MIT License
Copyright (c) 2025 Loule95450.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Nexecur or any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.