An open API service indexing awesome lists of open source software.

https://github.com/soif/hackapi

Unified API client for devices (like Routers, Modems, ISP boxes, SmartHome...). Supports Huawei modems, OpenWRT, Opnsense, SFR boxes, ZTE modems
https://github.com/soif/hackapi

api api-client box huawei modem openwrt opnsense php router sfr smarthome sms wifi zte

Last synced: 10 months ago
JSON representation

Unified API client for devices (like Routers, Modems, ISP boxes, SmartHome...). Supports Huawei modems, OpenWRT, Opnsense, SFR boxes, ZTE modems

Awesome Lists containing this project

README

          

# 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](src/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](src/lib/Hackapi.php) file and a concise device-specific class file (e.g., [openwrt](src/devices/openwrt/main.php)) accompanied by its autogenerated [trait.php file](src/devices/openwrt/trait.php) from a [template.php file](src/devices/openwrt/template.php) (essentially an API endpoint definition), HackApi simplifies the process, eliminating the need to reinvent the wheel.

## Features

- Standardised API methods
- Full debug to ease API client development
- Template based for building API endpoints methods & documentation very quickly
- CLI commands to build, test, and debug API methods

## Currently Supported Devices

- **[Huawei](src/devices/huawei_modem)** modems
- **[OpenWRT](src/devices/openwrt)** based routers
- **[OPNSense](src/devices/opnsense)** routers
- **[SFR](src/devices/sfr_box)** internet boxes provided by french "SFR" (or "Red-by-SFR") ISP
- **[ZTE](src/devices/zte_modem)** modems

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

## Requirements

- php >= 5.4
- curl php extension

## How to use

Example:

```php
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

- Please submit the products models that you have tested
- Write new device specifics clients and submit them back
- Enhance the documentation : *yes, I know, my english writing sucks!*
- Pull Requests are always **welcome**!

Enjoy!