Coder Social home page Coder Social logo

soif / hackapi Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 764 KB

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

License: GNU General Public License v3.0

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

hackapi's Introduction

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

  • 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

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

Requirements

  • php >= 5.4
  • curl php extension

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

  • 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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.