Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3e3018a
Add API mode support with legacy/rest auto-detection
espipj Feb 22, 2026
cfcc7e8
Add unit tests for REST mode and auto fallback
espipj Feb 22, 2026
f81a502
Document API mode usage and REST limitations
espipj Feb 22, 2026
abe949a
Add REST reboot support and hosts endpoint fallback
espipj Feb 22, 2026
00c5f05
Accept REST cookies from IP hosts with unsafe CookieJar
espipj Feb 22, 2026
0352eb6
Add test for IP-cookie acceptance in default session
espipj Feb 22, 2026
7fdf78e
Expose EncryptionMethod.NONE results
espipj Feb 23, 2026
37668b2
Log API mode outcome and logout response
espipj Feb 23, 2026
5557749
Make authentication_method optional again
espipj Feb 23, 2026
577a198
Remove client logging instrumentation
espipj Feb 23, 2026
33a412b
Probe REST when auto detecting encryption
espipj Feb 24, 2026
376e09c
Document YouFibre 5598 entry
espipj Feb 24, 2026
99e8995
Fix post-rebase prek issues
iMicknl Apr 6, 2026
177e648
Correct REST request semantics
iMicknl Jul 28, 2026
9f0459c
Handle rejected REST availability probes
iMicknl Jul 28, 2026
85c457d
Isolate REST cookie and mode selection
iMicknl Jul 28, 2026
75fa3c7
Keep explicit legacy mode isolated
iMicknl Jul 28, 2026
77739d1
Harden REST response handling
iMicknl Jul 28, 2026
0b9cae1
Handle malformed REST host collections
iMicknl Jul 28, 2026
841b581
Preserve constructor positional compatibility
iMicknl Jul 28, 2026
5092b7d
Restore legacy state when AUTO REST fallback fails
iMicknl Oct 28, 2026
0add81e
Test that AUTO mode stops on a legacy login lockout
iMicknl Oct 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The Sagemcom F@st series is used by multiple cable companies, where some cable c
| Sagemcom F@st 5370e | Telia | sha512 | |
| Sagemcom F@st 5380 | TDC | md5 | |
| Sagemcom F@st 5566 | Bell (Home Hub 3000) | md5 | username: guest, password: "" |
| Sagemcom F@st 5598 | YouFibre | None / New API | username: admin, password: "" |
| Sagemcom F@st 5688T | Salt (FibreBox_X6) | sha512 | username: admin |
| Sagemcom F@st 5689 | Bell (Home Hub 4000) | md5 | username: admin, password: "" |
| Sagemcom F@st 5689E | Bell (Giga Hub) | sha512 | username: admin, password: "" |
Expand Down Expand Up @@ -63,17 +64,25 @@ The following script can be used as a quickstart.
```python
import asyncio
from sagemcom_api.client import SagemcomClient
from sagemcom_api.enums import EncryptionMethod
from sagemcom_api.enums import ApiMode, EncryptionMethod
from sagemcom_api.exceptions import NonWritableParameterException

HOST = ""
USERNAME = ""
PASSWORD = ""
ENCRYPTION_METHOD = EncryptionMethod.SHA512 # or EncryptionMethod.MD5
VALIDATE_SSL_CERT = True
API_MODE = ApiMode.AUTO # auto, legacy or rest

async def main() -> None:
async with SagemcomClient(HOST, USERNAME, PASSWORD, ENCRYPTION_METHOD, verify_ssl=VALIDATE_SSL_CERT) as client:
async with SagemcomClient(
HOST,
USERNAME,
PASSWORD,
ENCRYPTION_METHOD,
api_mode=API_MODE,
verify_ssl=VALIDATE_SSL_CERT,
) as client:
try:
await client.login()
except Exception as exception: # pylint: disable=broad-except
Expand Down Expand Up @@ -119,11 +128,23 @@ asyncio.run(main())

## Advanced

### API Mode

The client supports two API variants:

- `ApiMode.LEGACY`: original `/cgi/json-req` API with XPath support
- `ApiMode.REST`: newer `/api/v1/*` API used by newer firmwares
- `ApiMode.AUTO` (default): tries legacy first, then falls back to REST when the legacy endpoint is unavailable

When REST mode is active, high-level helpers like `get_device_info()`, `get_hosts()` and `reboot()` are supported. XPath-based methods (`get_value_by_xpath`, `set_value_by_xpath`, `get_values_by_xpaths`) are legacy-only.

REST firmware sets its session cookie on the router's IP address. Sessions created by the client accept such cookies in REST mode only; if you pass your own `session` for a REST router, create it with `CookieJar(unsafe=True)`.

### Determine the EncryptionMethod

If you are not sure which encryption method to use, you can leave it empty or pass `None` and use `get_encryption_method` to determine the encryption method.

`get_encryption_method` will return an `EncryptionMethod` when a match is found. Best would be to use this function only during your initial investigation.
`get_encryption_method` will return an `EncryptionMethod` when a match is found, `EncryptionMethod.NONE` when the router uses the REST API, and `None` if no method matches. Best would be to use this function only during your initial investigation.

This function will throw a `LoginTimeoutException` when no match is found, since this is still a HTTP Time Out. This could caused by the wrong encryption method, but also by trying to connect to an inaccessible host.

Expand Down
Loading
Loading