soif / HackApi

Unified API client for devices (like Routers, Modems, ISP boxes, SmartHome...). Supports Huawei modems, OpenWRT, Opnsense, SFR boxes, ZTE modems
GNU General Public License v3.0
5 stars 0 forks source link
api api-client box huawei modem openwrt opnsense php router sfr smarthome sms wifi zte

HackApi

A fast, lighweight and solid API client written in PHP, to interact with various devices (mainly Routers, Modems or Smart Home hardware).

You can use it to interface with the currently implemented devices, or use it as a base to quickly develop your own client.

Why HackApi ?

While numerous API clients and frameworks excel with well-documented public APIs, they often prove excessive and challenging for tasks involving hardware devices like routers, modems, ISP boxes, and smart home devices. In situations where internal APIs, often undocumented and not intended for public access, come into play, existing tools can be overcomplicated, possess a steep learning curve, and lack suitability.

Enter HackApi: a straightforward, lightweight solution designed for ease of learning and debugging, specifically catering to the challenges posed by undocumented APIs. With just the HackApi main class file and a concise device-specific class file (e.g., openwrt) accompanied by its autogenerated trait.php file from a template.php file (essentially an API endpoint definition), HackApi simplifies the process, eliminating the need to reinvent the wheel.

Features

Currently Supported Devices

All tested models are listed in: /src/devices/(BRAND)/Readme.md

Requirements

How to use

Example:

require('src/devices/huawei_modem/main.php');
$client= new HackApi_Huawei_modem();

//Set Credentials (if not set in default.php) file
//$client->SetHost('192.168.0.1');
//$client->SetLogin('admin','password');

// List messages from the SMS Inbox
$messages = $client->ApiSmsListReceived();
print_r($messages);

// Send an SMS
$done = $client->ApiSmsSend('0612345678','Hello world');

// Reboot modem
$done = $client->ApiReboot();

Very Simple, isn't it?

Contribute

Enjoy!