Something went wrong. Try again.
Freebox router API client
Something went wrong. Try again.
Files
- OCaml 100%
README.md
freebox #
A client for the local REST API of the Freebox, the router that the French ISP Free supplies to its subscribers.
The Freebox exposes nearly everything its web interface shows (connected hosts, port forwarding, WiFi, the phone log, downloads) through a JSON API on the LAN. Each application must first be paired by pressing a button on the box, and then opens sessions with the token it received. This library handles that pairing and session flow, stores the token, and returns typed OCaml records for each part of the API.
Installation #
Install with opam:
$ opam install freebox
If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install freebox
Usage #
let run () =
Eio_main.run @@ fun env ->
Eio.Switch.run @@ fun sw ->
let clock = Eio.Stdenv.clock env in
let http = Requests_eio.v ~sw ~mono:env#mono_clock ~clock env#net in
let store = Freebox.Auth.memory_token_store () in
(* List connected devices. *)
(match Freebox.Hosts.all_hosts http ~clock store with
| Ok hosts ->
List.iter
(fun h -> Fmt.pr "%s (%s)@." h.Freebox.Hosts.hostname h.ip)
hosts
| Error (`Msg m) -> Fmt.epr "hosts: %s@." m);
(* Get system info. *)
match Freebox.System.info http ~clock store with
| Ok sys ->
Fmt.pr "Uptime: %s, board: %s@." sys.Freebox.System.uptime sys.board_name
| Error (`Msg m) -> Fmt.epr "system: %s@." m
Modules #
| Module | Description |
|---|---|
Auth |
Application pairing, session authentication and token storage |
Hosts |
Connected devices and network information |
Firewall |
Port forwarding and firewall rules |
Activity |
Network activity monitoring |
System |
System information, reboot and firmware |
Connection |
WAN connection status and bandwidth |
Wifi |
WiFi configuration and clients |
Switch |
Ethernet switch ports |
Calls |
Phone call log |
Downloads |
Download manager |
Parental |
Parental controls |
Fs |
File system browser |
Licence #
ISC. See LICENSE.md.