Skip to main content

Freebox client library

Features

  • Full API coverage
  • Https and Mdns discovery
  • Thin client wrapper library (<200 lines)
  • Small script to perform most tasks

pipeline status coverage report

Library usage

The library is available to create your own scripts. The REST API is generated at runtime with the creation of class attributes for all Freebox subsystems.

>>> from pyfbx import Fbx
>>> f=Fbx()             # By default, this will perform MDNS discovery
>>> f=Fbx(nomdns=True)  # Use faster http api discovery
>>> f.<TAB>
f.Airmedia         f.Download_Config  f.Lan              f.Rrd              f.Upnpav
f.Call             f.Download_Feeds   f.Lcd              f.Share            f.Vpn
f.Connection       f.Freeplug         f.Nat              f.Storage          f.Vpn_Client
f.Contacts         f.Fs               f.Network_Share    f.Switch           f.Wifi
f.Dhcp             f.Ftp              f.Parental         f.System           f.mksession(
f.Download         f.Igd              f.Pvr              f.Upload           f.register(
>>> f.Freeplug.<TAB>
f.Freeplug.Get_a_particular_Freeplug_information(
f.Freeplug.Reset_a_Freeplug(
f.Freeplug.Get_the_current_Freeplugs_networks(

# Register application to get app token. Physical access is required.
>>> token = f.register("AppId", "My App", "PC")
# Generate session token
>>> f.mksession(app_id="AppId", token=token)

>>> help(f.Lan.Update_the_current_Lan_configuration)
Help on method Update_the_current_Lan_configuration:

Update_the_current_Lan_configuration(post_data) method of pyfbx.client.Lan instance
    Update the current Lan configuration

    Url parameters:
    Post data:PostData

>>> help(f.Contacts.Access_a_given_contact_entry)
Help on method Access_a_given_contact_entry:

Access_a_given_contact_entry(id) method of pyfbx.client.Contacts instance
    Access a given contact entry

    Url parameters: id
    Post data:

>>> f.Lan.Get_the_current_Lan_configuration()
{'name_dns': 'freebox-server', 'name': 'Freebox Server', 'name_mdns': 'Freebox-Server', 
'mode': 'router', 'name_netbios': 'Freebox_Server', 'ip': '192.168.1.254'}

# Any subsequent call to mksession will refresh the session token
>>> f.mksession()

Script

The included script can perform a lot of tasks.

Basics

$ pyfbx -h
usage: pyfbx [-h] [-a APP_ID] [-t TOKEN] [-v] [-n] [-j] [-d DELAY] [-u URL]
             [-s SEND] [-c COMMAND]

optional arguments:
  -h, --help            show this help message and exit
  -a APP_ID, --app_id APP_ID
                        application identifier
  -t TOKEN, --token TOKEN
                        token (or f:<filename>)
  -v, --verbose         increase verbosity to INFO, use twice for DEBUG
  -n, --http            disable MDNS and use http known address
  -j, --json            json output
  -d DELAY, --delay DELAY
                        cylically send command (number of seconds)
  -u URL, --url URL     specific url to query
  -s SEND, --send SEND  url to send json to
  -c COMMAND, --command COMMAND
                        command, defaults to
                        System.Get_the_current_system_info()

First, register the application:

$ pyfbx -a SuperAppId

Once registration is done on the device, write down the application token. You can also create a file with token as first line and application Id as second.

Using this app token, acquire a session token to execute a test command.

$ pyfbx -t '<TOKEN>' -a SuperAppId

$ cat token.txt
2OUDy4hhM/KLQ7ru+70gfi83h5A4DUoOpDztOfqM4c2wuUiWJ+gXTHB1SbxHAFP7
SuperAppId

$ pyfbx -t f:token.txt -c 'Connection.Get_the_current_Connection_status()'
{   'bandwidth_down': 1000000000,
    [..]
    'state': 'up',
    'type': 'ethernet'}

Note : Don't forget to escape token and command with quotes.

Advanced

You can run any commands on the freebox and retrieve complete result or single value

$ pyfbx -t f:/home/foo/token.txt SuperAppId -c 'Contacts.Create_a_contact(\
post_data={"display_name": "Sandy Kilo", "first_name": "Sandy", "last_name":"Kilo"})'
{   'birthday': '',
    [..]
    'photo_url': ''}

$ pyfbx -u https://0s2efr3i.fbxos.fr:15628 -c "Connection.Get_the_current_Connection_status()['rate_up']" -t f:token.txt
1700

With the delay option, commands can be sent cyclically:

$ pyfbx -d 1 -c "Connection.Get_the_current_Connection_status()['rate_up']" -t f:token.txt
42460
50710
53400

With the send option, result can be sent to a remote URL. In the following, the result is sent cyclically to example.com in json format.

pyfbx -j -s http://example.com/values -d 10 -c "Connection.Get_the_current_Connection_status()" -t f:token.txt

It's possible to execute several commands. Here, two commands are sent cyclically and results sent to an URL.

pyfbx -c 'System.Get_the_current_system_info()' -c 'Connection.Get_the_current_Connection_status()' -d 10 -j -s http://localhost:8182/telegraf -t f:token.txt

Telegraf http listener v2 input plugin with json format can be used to plot data in realtime.

Telegraf and Graphana plots

You can use a telegraph configuration in /etc/telegraf/telegraf.d/freebox:

[[inputs.http_listener_v2]]
    service_address = ":8182"
    path = "/telegraf"
    methods = ["POST"]
    read_timeout = "10s"
    write_timeout = "10s"
    max_body_size = "5KB"
    data_format = "json"
    name_override = "pyfbx"

Grafana

Developpment

Testing

You can run tests with

pip3 install -r requirements-dev.txt
pytest tests

The library mechanisms are tested. To get 100% coverage, a Freebox on its default IP (192.168.1.254) is required.

The API description is generated and thus not functionnaly tested.

Metadata

Release files for pyfbx 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfbx 0.0.8
File Size Uploaded Provenance Actions
pyfbx-0.0.8.tar.gz 20.2 kB Without provenance Details for pyfbx-0.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyfbx 0.0.8
File Interpreter ABI Platform Actions
pyfbx-0.0.8-py3-none-any.whl Python 3 none any Details for pyfbx-0.0.8-py3-none-any.whl

Total release size: 48.7 kB

Release files / pyfbx-0.0.8.tar.gz

Download URL pyfbx-0.0.8.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ee7ad7bc70fe0fd49bfea4c1e331614322aacacd1844ef93e0a0392ecfc2b770
BLAKE2b-256 checksum
How to use checksums
8bd9a58032cf4e89d7af773216f3aa84e2ea3589b4b8684f2cda5bc551619081
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / pyfbx-0.0.8-py3-none-any.whl

Download URL pyfbx-0.0.8-py3-none-any.whl
Size 28.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b816390e7cb0ac3c9d261be43646f325fb9597ec125209774932949751f15229
BLAKE2b-256 checksum
How to use checksums
77d44bc1c352fdd8bf06157d050fa00410e6c65e84d31e9f5fc022a4ef3708b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Security for pyfbx 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page