Metadata-Version: 2.4
Name: fritzconnection
Version: 1.13.2
Summary: Communicate with the AVM FRITZ!Box
Home-page: https://github.com/kbr/fritzconnection
Author: Klaus Bremer
Author-email: bremer@bremer-media.com
License: MIT
Keywords: AVM FRITZ!Box fritzbox fritz
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >= 3.7
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: requests>=2.22.0
Provides-Extra: qr
Requires-Dist: segno>=1.4.1; extra == "qr"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary


# fritzconnection

![](https://img.shields.io/pypi/pyversions/fritzconnection.svg)
![](https://img.shields.io/pypi/l/fritzconnection.svg)

Python-Interface to communicate with the AVM Fritz!Box. Supports the TR-064 protocol, the (AHA-)HTTP-Interface and also allows call-monitoring.


## Installation

For installation use pip:

```
    $ pip install fritzconnection
      or
    $ pip install fritzconnection[qr]
```

The latter will install the [segno](https://github.com/heuer/segno) package to enable QR-code creation for wifi login.

## Quickstart

Using fritzconnection is as easy as:

```
    from fritzconnection import FritzConnection

    fc = FritzConnection(address="192.168.178.1", user="user", password="pw")
    print(fc)  # print router model information

    # tr-064 interface: reconnect for a new ip
    fc.call_action("WANIPConn1", "ForceTermination")

    # http interface: gets history data from a device with given 'ain'
    fc.call_http("getbasicdevicestats", "12345 7891011")
```

FritzConnection provides two basic commands to communicate with the router APIs: `call_action()` for the __TR-064-Interface__ and `call_http()` for the __(AHA)-HTTP-Interface__. Both APIs can be used on the same FritzConnection instance side by side.

### call_action

`call_action()` expects a __TR-064__ service- and an action-name (and optional arguments). In general FritzConnection can execute every service and action provided by the (model-specific) API as documented by AVM. For i.e. this can be network settings, status informations, access to home automation devices and much more. The `call_action()` method returns the response from the router as a dictionary with the values already converted to the matching Python datatypes.

### call_http

`call_http()` expects a command for the __http-interface__ like "getbasicdevicestats" and, depending on the command, additional arguments like a device "ain" (identifier). A call to the method returns a dictionary with the `content-type`, the `encoding` and the `response` data of the http-response. The content-type of the response-data is typical "text/plain" or "text/xml" and may need further processing.

### Username and password

To avoid hardcoding the arguments `user` and `password` in applications FritzConnection can read both from the environment variables `FRITZ_USERNAME` and `FRITZ_PASSWORD`.


### Caching

On instanciation FritzConnection has to inspect the model-specific router-API. This causes a lot of network requests and can take some seconds. To avoid this FritzConnection provides a cache that can get activated by the `use_cache` parameter:

```
    fc = FritzConnection(..., use_cache=True)
```

This argument defaults to `False`. After creating the cache FritzConnection will start up much more faster.


## Library


The package comes with library-modules to make some API calls easier and also demonstrates how to implement applications on top of FritzConnection.


## Documentation

The full documentation and release notes are at [https://fritzconnection.readthedocs.org](https://fritzconnection.readthedocs.org)

