Skip to content

Commit fd98ecc

Browse files
committed
Document API mode usage and REST limitations
1 parent 42401f9 commit fd98ecc

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,25 @@ The following script can be used as a quickstart.
6363
```python
6464
import asyncio
6565
from sagemcom_api.client import SagemcomClient
66-
from sagemcom_api.enums import EncryptionMethod
66+
from sagemcom_api.enums import ApiMode, EncryptionMethod
6767
from sagemcom_api.exceptions import NonWritableParameterException
6868

6969
HOST = ""
7070
USERNAME = ""
7171
PASSWORD = ""
7272
ENCRYPTION_METHOD = EncryptionMethod.SHA512 # or EncryptionMethod.MD5
7373
VALIDATE_SSL_CERT = True
74+
API_MODE = ApiMode.AUTO # auto, legacy or rest
7475

7576
async def main() -> None:
76-
async with SagemcomClient(HOST, USERNAME, PASSWORD, ENCRYPTION_METHOD, verify_ssl=VALIDATE_SSL_CERT) as client:
77+
async with SagemcomClient(
78+
HOST,
79+
USERNAME,
80+
PASSWORD,
81+
ENCRYPTION_METHOD,
82+
api_mode=API_MODE,
83+
verify_ssl=VALIDATE_SSL_CERT,
84+
) as client:
7785
try:
7886
await client.login()
7987
except Exception as exception: # pylint: disable=broad-except
@@ -119,6 +127,16 @@ asyncio.run(main())
119127

120128
## Advanced
121129

130+
### API Mode
131+
132+
The client supports two API variants:
133+
134+
- `ApiMode.LEGACY`: original `/cgi/json-req` API with XPath support
135+
- `ApiMode.REST`: newer `/api/v1/*` API used by newer firmwares
136+
- `ApiMode.AUTO` (default): tries legacy first, then falls back to REST when the legacy endpoint is unavailable
137+
138+
When REST mode is active, high-level helpers like `get_device_info()` and `get_hosts()` are supported. XPath-based methods (`get_value_by_xpath`, `set_value_by_xpath`, `get_values_by_xpaths`) are legacy-only.
139+
122140
### Determine the EncryptionMethod
123141

124142
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.

0 commit comments

Comments
 (0)