tp-link-vigi-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tp_link_vigi_sdk-0.1.0/LICENSE +21 -0
- tp_link_vigi_sdk-0.1.0/PKG-INFO +159 -0
- tp_link_vigi_sdk-0.1.0/README.md +128 -0
- tp_link_vigi_sdk-0.1.0/pyproject.toml +65 -0
- tp_link_vigi_sdk-0.1.0/setup.cfg +4 -0
- tp_link_vigi_sdk-0.1.0/src/tp_link_vigi_sdk.egg-info/PKG-INFO +159 -0
- tp_link_vigi_sdk-0.1.0/src/tp_link_vigi_sdk.egg-info/SOURCES.txt +44 -0
- tp_link_vigi_sdk-0.1.0/src/tp_link_vigi_sdk.egg-info/dependency_links.txt +1 -0
- tp_link_vigi_sdk-0.1.0/src/tp_link_vigi_sdk.egg-info/requires.txt +6 -0
- tp_link_vigi_sdk-0.1.0/src/tp_link_vigi_sdk.egg-info/top_level.txt +1 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/__init__.py +98 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/auth.py +198 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/auth_provider.py +38 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/capabilities.py +6 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/client.py +52 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/crypto.py +33 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/devices.py +115 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/exceptions.py +77 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/http_transport.py +62 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/ipc_auth.py +221 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/ipc_control.py +48 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/ipc_session.py +25 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/models.py +156 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/records.py +257 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/session.py +34 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/stream.py +83 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/transport.py +60 -0
- tp_link_vigi_sdk-0.1.0/src/vigi/types.py +45 -0
- tp_link_vigi_sdk-0.1.0/tests/test_auth.py +114 -0
- tp_link_vigi_sdk-0.1.0/tests/test_auth_provider.py +89 -0
- tp_link_vigi_sdk-0.1.0/tests/test_devices.py +221 -0
- tp_link_vigi_sdk-0.1.0/tests/test_examples.py +40 -0
- tp_link_vigi_sdk-0.1.0/tests/test_imports.py +24 -0
- tp_link_vigi_sdk-0.1.0/tests/test_integration_auth.py +39 -0
- tp_link_vigi_sdk-0.1.0/tests/test_integration_devices.py +46 -0
- tp_link_vigi_sdk-0.1.0/tests/test_integration_ipc_auth.py +53 -0
- tp_link_vigi_sdk-0.1.0/tests/test_integration_records.py +72 -0
- tp_link_vigi_sdk-0.1.0/tests/test_ipc_auth.py +447 -0
- tp_link_vigi_sdk-0.1.0/tests/test_ipc_control.py +30 -0
- tp_link_vigi_sdk-0.1.0/tests/test_models.py +57 -0
- tp_link_vigi_sdk-0.1.0/tests/test_project_skeleton.py +76 -0
- tp_link_vigi_sdk-0.1.0/tests/test_records.py +335 -0
- tp_link_vigi_sdk-0.1.0/tests/test_session.py +17 -0
- tp_link_vigi_sdk-0.1.0/tests/test_streams.py +107 -0
- tp_link_vigi_sdk-0.1.0/tests/test_transport_auth_foundation.py +65 -0
- tp_link_vigi_sdk-0.1.0/tests/test_types.py +18 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 김건우
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tp-link-vigi-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for TP-Link VIGI NVR OpenAPI.
|
|
5
|
+
Author-email: 김건우 <gunwookim0221@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gunwookim0221/tp-link-vigi-sdk
|
|
8
|
+
Project-URL: Repository, https://github.com/gunwookim0221/tp-link-vigi-sdk
|
|
9
|
+
Project-URL: Issues, https://github.com/gunwookim0221/tp-link-vigi-sdk/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/gunwookim0221/tp-link-vigi-sdk/blob/main/docs/00-index.md
|
|
11
|
+
Keywords: tp-link,vigi,nvr,openapi,python,sdk,rtsp
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: coverage>=7; extra == "dev"
|
|
27
|
+
Requires-Dist: mypy>=1.8; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
29
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# TP-Link VIGI SDK
|
|
33
|
+
|
|
34
|
+
Python SDK for the documented, read-only portions of the
|
|
35
|
+
TP-Link VIGI NVR OpenAPI.
|
|
36
|
+
|
|
37
|
+
## Requirements and Installation
|
|
38
|
+
|
|
39
|
+
- Python 3.10 or later.
|
|
40
|
+
|
|
41
|
+
Install the project in an isolated environment from the repository root:
|
|
42
|
+
|
|
43
|
+
```powershell
|
|
44
|
+
python -m venv .venv
|
|
45
|
+
.\.venv\Scripts\Activate.ps1
|
|
46
|
+
python -m pip install -e ".[dev]"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quickstart
|
|
50
|
+
|
|
51
|
+
Set the NVR connection variables in your shell. `.env` is not loaded
|
|
52
|
+
automatically by the SDK, tests, or examples.
|
|
53
|
+
|
|
54
|
+
```powershell
|
|
55
|
+
$env:VIGI_HOST = "nvr.example.invalid"
|
|
56
|
+
$env:VIGI_PORT = "20443"
|
|
57
|
+
$env:VIGI_USERNAME = "admin"
|
|
58
|
+
$env:VIGI_PASSWORD = "<your-nvr-password>"
|
|
59
|
+
$env:VIGI_VERIFY_SSL = "true"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then authenticate and list NVR-managed devices:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import os
|
|
66
|
+
|
|
67
|
+
from vigi import AuthConfig, VigiClient
|
|
68
|
+
|
|
69
|
+
client = VigiClient(
|
|
70
|
+
AuthConfig(
|
|
71
|
+
host=os.environ["VIGI_HOST"],
|
|
72
|
+
port=int(os.getenv("VIGI_PORT", "20443")),
|
|
73
|
+
username=os.environ["VIGI_USERNAME"],
|
|
74
|
+
password=os.environ["VIGI_PASSWORD"],
|
|
75
|
+
verify_tls=os.getenv("VIGI_VERIFY_SSL", "true").lower() not in {"0", "false", "no"},
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
client.login()
|
|
79
|
+
devices = client.devices.list_added_devices()
|
|
80
|
+
for device in devices.devices:
|
|
81
|
+
print(device.channel_id, device.name, device.alias, device.online.value)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`client.login()` and service calls contact the configured NVR. Constructing a
|
|
85
|
+
client or importing `vigi` does not make a network request.
|
|
86
|
+
|
|
87
|
+
## Read-only workflows and examples
|
|
88
|
+
|
|
89
|
+
The detailed [usage guide](docs/12-usage-guide.md) covers authentication,
|
|
90
|
+
device inventory, recording-day and recording-result searches, explicit error
|
|
91
|
+
handling, and RTSP replay URL construction.
|
|
92
|
+
|
|
93
|
+
- [List devices](examples/list_devices.py)
|
|
94
|
+
- [Read-only recording workflow](examples/read_only_workflow.py)
|
|
95
|
+
- [Build a replay URL without logging in](examples/build_replay_url.py)
|
|
96
|
+
|
|
97
|
+
Examples read environment variables only when their `main()` function runs.
|
|
98
|
+
They do not load `.env`, print passwords or tokens, save files, or open RTSP
|
|
99
|
+
connections.
|
|
100
|
+
|
|
101
|
+
## Supported scope
|
|
102
|
+
|
|
103
|
+
Implemented read-only SDK support includes:
|
|
104
|
+
|
|
105
|
+
- Documented NVR authentication.
|
|
106
|
+
- NVR-managed device inventory with `client.devices.list_added_devices()`.
|
|
107
|
+
- Recording-day, free-search-process, and recording-result queries.
|
|
108
|
+
- `client.stream.build_replay_url(...)` for documented RTSP replay URLs.
|
|
109
|
+
|
|
110
|
+
The RTSP helper only builds a URL. It does not open RTSP, perform a Digest
|
|
111
|
+
handshake, download video, or save video files. Replay stream `1` and explicit
|
|
112
|
+
UTC `YYYYMMDDtHHMMSSz` times are required.
|
|
113
|
+
|
|
114
|
+
Unsupported or deferred:
|
|
115
|
+
|
|
116
|
+
- Snapshot: unsupported because the current official NVR and IPC OpenAPI
|
|
117
|
+
documents do not define a snapshot or capture API.
|
|
118
|
+
- Export/download, RTSP playback, video saving, ffmpeg, and image processing.
|
|
119
|
+
- CLI: deferred to a separate phase.
|
|
120
|
+
- Public standalone IPC/camera APIs.
|
|
121
|
+
|
|
122
|
+
## Tests
|
|
123
|
+
|
|
124
|
+
Run the default unit and smoke-test suite:
|
|
125
|
+
|
|
126
|
+
```powershell
|
|
127
|
+
python -m pytest
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Real-device integration tests are opt-in. Export the required `VIGI_*`
|
|
131
|
+
variables in the shell, then run the relevant test explicitly, for example:
|
|
132
|
+
|
|
133
|
+
```powershell
|
|
134
|
+
python -m pytest tests/test_integration_records.py -v
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
See [docs/05-test-strategy.md](docs/05-test-strategy.md) and
|
|
138
|
+
[.env.example](.env.example) for the supported local configuration variables.
|
|
139
|
+
|
|
140
|
+
## Documentation
|
|
141
|
+
|
|
142
|
+
Start with:
|
|
143
|
+
|
|
144
|
+
- [Documentation index](docs/00-index.md)
|
|
145
|
+
- [API scope](docs/03-api-scope.md)
|
|
146
|
+
- [Usage guide](docs/12-usage-guide.md)
|
|
147
|
+
- [Implementation checklist](docs/08-implementation-checklist.md)
|
|
148
|
+
- [Limitations](docs/10-limitations.md)
|
|
149
|
+
- [Roadmap](docs/11-roadmap.md)
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
154
|
+
|
|
155
|
+
## Disclaimer
|
|
156
|
+
|
|
157
|
+
This project is not affiliated with, endorsed by, or sponsored by TP-Link.
|
|
158
|
+
TP-Link and VIGI are trademarks of their respective owners. Use this SDK only
|
|
159
|
+
with devices and credentials you are authorized to access.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# TP-Link VIGI SDK
|
|
2
|
+
|
|
3
|
+
Python SDK for the documented, read-only portions of the
|
|
4
|
+
TP-Link VIGI NVR OpenAPI.
|
|
5
|
+
|
|
6
|
+
## Requirements and Installation
|
|
7
|
+
|
|
8
|
+
- Python 3.10 or later.
|
|
9
|
+
|
|
10
|
+
Install the project in an isolated environment from the repository root:
|
|
11
|
+
|
|
12
|
+
```powershell
|
|
13
|
+
python -m venv .venv
|
|
14
|
+
.\.venv\Scripts\Activate.ps1
|
|
15
|
+
python -m pip install -e ".[dev]"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quickstart
|
|
19
|
+
|
|
20
|
+
Set the NVR connection variables in your shell. `.env` is not loaded
|
|
21
|
+
automatically by the SDK, tests, or examples.
|
|
22
|
+
|
|
23
|
+
```powershell
|
|
24
|
+
$env:VIGI_HOST = "nvr.example.invalid"
|
|
25
|
+
$env:VIGI_PORT = "20443"
|
|
26
|
+
$env:VIGI_USERNAME = "admin"
|
|
27
|
+
$env:VIGI_PASSWORD = "<your-nvr-password>"
|
|
28
|
+
$env:VIGI_VERIFY_SSL = "true"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Then authenticate and list NVR-managed devices:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import os
|
|
35
|
+
|
|
36
|
+
from vigi import AuthConfig, VigiClient
|
|
37
|
+
|
|
38
|
+
client = VigiClient(
|
|
39
|
+
AuthConfig(
|
|
40
|
+
host=os.environ["VIGI_HOST"],
|
|
41
|
+
port=int(os.getenv("VIGI_PORT", "20443")),
|
|
42
|
+
username=os.environ["VIGI_USERNAME"],
|
|
43
|
+
password=os.environ["VIGI_PASSWORD"],
|
|
44
|
+
verify_tls=os.getenv("VIGI_VERIFY_SSL", "true").lower() not in {"0", "false", "no"},
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
client.login()
|
|
48
|
+
devices = client.devices.list_added_devices()
|
|
49
|
+
for device in devices.devices:
|
|
50
|
+
print(device.channel_id, device.name, device.alias, device.online.value)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`client.login()` and service calls contact the configured NVR. Constructing a
|
|
54
|
+
client or importing `vigi` does not make a network request.
|
|
55
|
+
|
|
56
|
+
## Read-only workflows and examples
|
|
57
|
+
|
|
58
|
+
The detailed [usage guide](docs/12-usage-guide.md) covers authentication,
|
|
59
|
+
device inventory, recording-day and recording-result searches, explicit error
|
|
60
|
+
handling, and RTSP replay URL construction.
|
|
61
|
+
|
|
62
|
+
- [List devices](examples/list_devices.py)
|
|
63
|
+
- [Read-only recording workflow](examples/read_only_workflow.py)
|
|
64
|
+
- [Build a replay URL without logging in](examples/build_replay_url.py)
|
|
65
|
+
|
|
66
|
+
Examples read environment variables only when their `main()` function runs.
|
|
67
|
+
They do not load `.env`, print passwords or tokens, save files, or open RTSP
|
|
68
|
+
connections.
|
|
69
|
+
|
|
70
|
+
## Supported scope
|
|
71
|
+
|
|
72
|
+
Implemented read-only SDK support includes:
|
|
73
|
+
|
|
74
|
+
- Documented NVR authentication.
|
|
75
|
+
- NVR-managed device inventory with `client.devices.list_added_devices()`.
|
|
76
|
+
- Recording-day, free-search-process, and recording-result queries.
|
|
77
|
+
- `client.stream.build_replay_url(...)` for documented RTSP replay URLs.
|
|
78
|
+
|
|
79
|
+
The RTSP helper only builds a URL. It does not open RTSP, perform a Digest
|
|
80
|
+
handshake, download video, or save video files. Replay stream `1` and explicit
|
|
81
|
+
UTC `YYYYMMDDtHHMMSSz` times are required.
|
|
82
|
+
|
|
83
|
+
Unsupported or deferred:
|
|
84
|
+
|
|
85
|
+
- Snapshot: unsupported because the current official NVR and IPC OpenAPI
|
|
86
|
+
documents do not define a snapshot or capture API.
|
|
87
|
+
- Export/download, RTSP playback, video saving, ffmpeg, and image processing.
|
|
88
|
+
- CLI: deferred to a separate phase.
|
|
89
|
+
- Public standalone IPC/camera APIs.
|
|
90
|
+
|
|
91
|
+
## Tests
|
|
92
|
+
|
|
93
|
+
Run the default unit and smoke-test suite:
|
|
94
|
+
|
|
95
|
+
```powershell
|
|
96
|
+
python -m pytest
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Real-device integration tests are opt-in. Export the required `VIGI_*`
|
|
100
|
+
variables in the shell, then run the relevant test explicitly, for example:
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
python -m pytest tests/test_integration_records.py -v
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
See [docs/05-test-strategy.md](docs/05-test-strategy.md) and
|
|
107
|
+
[.env.example](.env.example) for the supported local configuration variables.
|
|
108
|
+
|
|
109
|
+
## Documentation
|
|
110
|
+
|
|
111
|
+
Start with:
|
|
112
|
+
|
|
113
|
+
- [Documentation index](docs/00-index.md)
|
|
114
|
+
- [API scope](docs/03-api-scope.md)
|
|
115
|
+
- [Usage guide](docs/12-usage-guide.md)
|
|
116
|
+
- [Implementation checklist](docs/08-implementation-checklist.md)
|
|
117
|
+
- [Limitations](docs/10-limitations.md)
|
|
118
|
+
- [Roadmap](docs/11-roadmap.md)
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
123
|
+
|
|
124
|
+
## Disclaimer
|
|
125
|
+
|
|
126
|
+
This project is not affiliated with, endorsed by, or sponsored by TP-Link.
|
|
127
|
+
TP-Link and VIGI are trademarks of their respective owners. Use this SDK only
|
|
128
|
+
with devices and credentials you are authorized to access.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tp-link-vigi-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for TP-Link VIGI NVR OpenAPI."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = []
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "김건우", email = "gunwookim0221@gmail.com" },
|
|
15
|
+
]
|
|
16
|
+
keywords = [
|
|
17
|
+
"tp-link",
|
|
18
|
+
"vigi",
|
|
19
|
+
"nvr",
|
|
20
|
+
"openapi",
|
|
21
|
+
"python",
|
|
22
|
+
"sdk",
|
|
23
|
+
"rtsp",
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 3 - Alpha",
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"Operating System :: OS Independent",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Programming Language :: Python :: 3.13",
|
|
35
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/gunwookim0221/tp-link-vigi-sdk"
|
|
40
|
+
Repository = "https://github.com/gunwookim0221/tp-link-vigi-sdk"
|
|
41
|
+
Issues = "https://github.com/gunwookim0221/tp-link-vigi-sdk/issues"
|
|
42
|
+
Documentation = "https://github.com/gunwookim0221/tp-link-vigi-sdk/blob/main/docs/00-index.md"
|
|
43
|
+
|
|
44
|
+
[project.optional-dependencies]
|
|
45
|
+
dev = [
|
|
46
|
+
"coverage>=7",
|
|
47
|
+
"mypy>=1.8",
|
|
48
|
+
"pytest>=8",
|
|
49
|
+
"ruff>=0.5",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[tool.setuptools.packages.find]
|
|
53
|
+
where = ["src"]
|
|
54
|
+
|
|
55
|
+
[tool.pytest.ini_options]
|
|
56
|
+
testpaths = ["tests"]
|
|
57
|
+
pythonpath = ["src"]
|
|
58
|
+
|
|
59
|
+
[tool.ruff]
|
|
60
|
+
line-length = 100
|
|
61
|
+
target-version = "py310"
|
|
62
|
+
|
|
63
|
+
[tool.mypy]
|
|
64
|
+
python_version = "3.10"
|
|
65
|
+
warn_unused_configs = true
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tp-link-vigi-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for TP-Link VIGI NVR OpenAPI.
|
|
5
|
+
Author-email: 김건우 <gunwookim0221@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gunwookim0221/tp-link-vigi-sdk
|
|
8
|
+
Project-URL: Repository, https://github.com/gunwookim0221/tp-link-vigi-sdk
|
|
9
|
+
Project-URL: Issues, https://github.com/gunwookim0221/tp-link-vigi-sdk/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/gunwookim0221/tp-link-vigi-sdk/blob/main/docs/00-index.md
|
|
11
|
+
Keywords: tp-link,vigi,nvr,openapi,python,sdk,rtsp
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: coverage>=7; extra == "dev"
|
|
27
|
+
Requires-Dist: mypy>=1.8; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
29
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# TP-Link VIGI SDK
|
|
33
|
+
|
|
34
|
+
Python SDK for the documented, read-only portions of the
|
|
35
|
+
TP-Link VIGI NVR OpenAPI.
|
|
36
|
+
|
|
37
|
+
## Requirements and Installation
|
|
38
|
+
|
|
39
|
+
- Python 3.10 or later.
|
|
40
|
+
|
|
41
|
+
Install the project in an isolated environment from the repository root:
|
|
42
|
+
|
|
43
|
+
```powershell
|
|
44
|
+
python -m venv .venv
|
|
45
|
+
.\.venv\Scripts\Activate.ps1
|
|
46
|
+
python -m pip install -e ".[dev]"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quickstart
|
|
50
|
+
|
|
51
|
+
Set the NVR connection variables in your shell. `.env` is not loaded
|
|
52
|
+
automatically by the SDK, tests, or examples.
|
|
53
|
+
|
|
54
|
+
```powershell
|
|
55
|
+
$env:VIGI_HOST = "nvr.example.invalid"
|
|
56
|
+
$env:VIGI_PORT = "20443"
|
|
57
|
+
$env:VIGI_USERNAME = "admin"
|
|
58
|
+
$env:VIGI_PASSWORD = "<your-nvr-password>"
|
|
59
|
+
$env:VIGI_VERIFY_SSL = "true"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then authenticate and list NVR-managed devices:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import os
|
|
66
|
+
|
|
67
|
+
from vigi import AuthConfig, VigiClient
|
|
68
|
+
|
|
69
|
+
client = VigiClient(
|
|
70
|
+
AuthConfig(
|
|
71
|
+
host=os.environ["VIGI_HOST"],
|
|
72
|
+
port=int(os.getenv("VIGI_PORT", "20443")),
|
|
73
|
+
username=os.environ["VIGI_USERNAME"],
|
|
74
|
+
password=os.environ["VIGI_PASSWORD"],
|
|
75
|
+
verify_tls=os.getenv("VIGI_VERIFY_SSL", "true").lower() not in {"0", "false", "no"},
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
client.login()
|
|
79
|
+
devices = client.devices.list_added_devices()
|
|
80
|
+
for device in devices.devices:
|
|
81
|
+
print(device.channel_id, device.name, device.alias, device.online.value)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`client.login()` and service calls contact the configured NVR. Constructing a
|
|
85
|
+
client or importing `vigi` does not make a network request.
|
|
86
|
+
|
|
87
|
+
## Read-only workflows and examples
|
|
88
|
+
|
|
89
|
+
The detailed [usage guide](docs/12-usage-guide.md) covers authentication,
|
|
90
|
+
device inventory, recording-day and recording-result searches, explicit error
|
|
91
|
+
handling, and RTSP replay URL construction.
|
|
92
|
+
|
|
93
|
+
- [List devices](examples/list_devices.py)
|
|
94
|
+
- [Read-only recording workflow](examples/read_only_workflow.py)
|
|
95
|
+
- [Build a replay URL without logging in](examples/build_replay_url.py)
|
|
96
|
+
|
|
97
|
+
Examples read environment variables only when their `main()` function runs.
|
|
98
|
+
They do not load `.env`, print passwords or tokens, save files, or open RTSP
|
|
99
|
+
connections.
|
|
100
|
+
|
|
101
|
+
## Supported scope
|
|
102
|
+
|
|
103
|
+
Implemented read-only SDK support includes:
|
|
104
|
+
|
|
105
|
+
- Documented NVR authentication.
|
|
106
|
+
- NVR-managed device inventory with `client.devices.list_added_devices()`.
|
|
107
|
+
- Recording-day, free-search-process, and recording-result queries.
|
|
108
|
+
- `client.stream.build_replay_url(...)` for documented RTSP replay URLs.
|
|
109
|
+
|
|
110
|
+
The RTSP helper only builds a URL. It does not open RTSP, perform a Digest
|
|
111
|
+
handshake, download video, or save video files. Replay stream `1` and explicit
|
|
112
|
+
UTC `YYYYMMDDtHHMMSSz` times are required.
|
|
113
|
+
|
|
114
|
+
Unsupported or deferred:
|
|
115
|
+
|
|
116
|
+
- Snapshot: unsupported because the current official NVR and IPC OpenAPI
|
|
117
|
+
documents do not define a snapshot or capture API.
|
|
118
|
+
- Export/download, RTSP playback, video saving, ffmpeg, and image processing.
|
|
119
|
+
- CLI: deferred to a separate phase.
|
|
120
|
+
- Public standalone IPC/camera APIs.
|
|
121
|
+
|
|
122
|
+
## Tests
|
|
123
|
+
|
|
124
|
+
Run the default unit and smoke-test suite:
|
|
125
|
+
|
|
126
|
+
```powershell
|
|
127
|
+
python -m pytest
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Real-device integration tests are opt-in. Export the required `VIGI_*`
|
|
131
|
+
variables in the shell, then run the relevant test explicitly, for example:
|
|
132
|
+
|
|
133
|
+
```powershell
|
|
134
|
+
python -m pytest tests/test_integration_records.py -v
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
See [docs/05-test-strategy.md](docs/05-test-strategy.md) and
|
|
138
|
+
[.env.example](.env.example) for the supported local configuration variables.
|
|
139
|
+
|
|
140
|
+
## Documentation
|
|
141
|
+
|
|
142
|
+
Start with:
|
|
143
|
+
|
|
144
|
+
- [Documentation index](docs/00-index.md)
|
|
145
|
+
- [API scope](docs/03-api-scope.md)
|
|
146
|
+
- [Usage guide](docs/12-usage-guide.md)
|
|
147
|
+
- [Implementation checklist](docs/08-implementation-checklist.md)
|
|
148
|
+
- [Limitations](docs/10-limitations.md)
|
|
149
|
+
- [Roadmap](docs/11-roadmap.md)
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
154
|
+
|
|
155
|
+
## Disclaimer
|
|
156
|
+
|
|
157
|
+
This project is not affiliated with, endorsed by, or sponsored by TP-Link.
|
|
158
|
+
TP-Link and VIGI are trademarks of their respective owners. Use this SDK only
|
|
159
|
+
with devices and credentials you are authorized to access.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/tp_link_vigi_sdk.egg-info/PKG-INFO
|
|
5
|
+
src/tp_link_vigi_sdk.egg-info/SOURCES.txt
|
|
6
|
+
src/tp_link_vigi_sdk.egg-info/dependency_links.txt
|
|
7
|
+
src/tp_link_vigi_sdk.egg-info/requires.txt
|
|
8
|
+
src/tp_link_vigi_sdk.egg-info/top_level.txt
|
|
9
|
+
src/vigi/__init__.py
|
|
10
|
+
src/vigi/auth.py
|
|
11
|
+
src/vigi/auth_provider.py
|
|
12
|
+
src/vigi/capabilities.py
|
|
13
|
+
src/vigi/client.py
|
|
14
|
+
src/vigi/crypto.py
|
|
15
|
+
src/vigi/devices.py
|
|
16
|
+
src/vigi/exceptions.py
|
|
17
|
+
src/vigi/http_transport.py
|
|
18
|
+
src/vigi/ipc_auth.py
|
|
19
|
+
src/vigi/ipc_control.py
|
|
20
|
+
src/vigi/ipc_session.py
|
|
21
|
+
src/vigi/models.py
|
|
22
|
+
src/vigi/records.py
|
|
23
|
+
src/vigi/session.py
|
|
24
|
+
src/vigi/stream.py
|
|
25
|
+
src/vigi/transport.py
|
|
26
|
+
src/vigi/types.py
|
|
27
|
+
tests/test_auth.py
|
|
28
|
+
tests/test_auth_provider.py
|
|
29
|
+
tests/test_devices.py
|
|
30
|
+
tests/test_examples.py
|
|
31
|
+
tests/test_imports.py
|
|
32
|
+
tests/test_integration_auth.py
|
|
33
|
+
tests/test_integration_devices.py
|
|
34
|
+
tests/test_integration_ipc_auth.py
|
|
35
|
+
tests/test_integration_records.py
|
|
36
|
+
tests/test_ipc_auth.py
|
|
37
|
+
tests/test_ipc_control.py
|
|
38
|
+
tests/test_models.py
|
|
39
|
+
tests/test_project_skeleton.py
|
|
40
|
+
tests/test_records.py
|
|
41
|
+
tests/test_session.py
|
|
42
|
+
tests/test_streams.py
|
|
43
|
+
tests/test_transport_auth_foundation.py
|
|
44
|
+
tests/test_types.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
vigi
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""Python SDK for TP-Link VIGI NVR OpenAPI."""
|
|
2
|
+
|
|
3
|
+
from vigi.auth import AuthConfig, AuthService
|
|
4
|
+
from vigi.auth_provider import AuthProvider, AuthenticationContext, AuthenticationResult
|
|
5
|
+
from vigi.capabilities import Capability
|
|
6
|
+
from vigi.client import VigiClient
|
|
7
|
+
from vigi.devices import DeviceService
|
|
8
|
+
from vigi.exceptions import (
|
|
9
|
+
AuthenticationError,
|
|
10
|
+
CapabilityError,
|
|
11
|
+
ConnectionError,
|
|
12
|
+
DeviceError,
|
|
13
|
+
RecordError,
|
|
14
|
+
StreamError,
|
|
15
|
+
TimeoutError,
|
|
16
|
+
TransportError,
|
|
17
|
+
ValidationError,
|
|
18
|
+
VigiError,
|
|
19
|
+
)
|
|
20
|
+
from vigi.crypto import calculate_digest_response, sha256_hex
|
|
21
|
+
from vigi.http_transport import HttpTransport
|
|
22
|
+
from vigi.models import (
|
|
23
|
+
AddedDevice,
|
|
24
|
+
AddedDevicesResponse,
|
|
25
|
+
ChannelInfo,
|
|
26
|
+
DeviceInfo,
|
|
27
|
+
NvrInfo,
|
|
28
|
+
RecordDay,
|
|
29
|
+
RecordDaysResponse,
|
|
30
|
+
RecordSearchProcessResponse,
|
|
31
|
+
RecordSearchResultsResponse,
|
|
32
|
+
RecordSegment,
|
|
33
|
+
RtspStreamInfo,
|
|
34
|
+
TimeRange,
|
|
35
|
+
)
|
|
36
|
+
from vigi.records import RecordService
|
|
37
|
+
from vigi.session import Session, SessionInfo
|
|
38
|
+
from vigi.stream import StreamService
|
|
39
|
+
from vigi.transport import Request, Response, Timeout, Transport, TransportConfig
|
|
40
|
+
from vigi.types import (
|
|
41
|
+
AuthMode,
|
|
42
|
+
CapabilityName,
|
|
43
|
+
ChannelStatus,
|
|
44
|
+
DeviceType,
|
|
45
|
+
StreamType,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
__all__ = [
|
|
49
|
+
"AuthConfig",
|
|
50
|
+
"AuthMode",
|
|
51
|
+
"AuthProvider",
|
|
52
|
+
"AuthService",
|
|
53
|
+
"AuthenticationContext",
|
|
54
|
+
"AuthenticationError",
|
|
55
|
+
"AuthenticationResult",
|
|
56
|
+
"AddedDevice",
|
|
57
|
+
"AddedDevicesResponse",
|
|
58
|
+
"calculate_digest_response",
|
|
59
|
+
"Capability",
|
|
60
|
+
"CapabilityName",
|
|
61
|
+
"CapabilityError",
|
|
62
|
+
"ChannelInfo",
|
|
63
|
+
"ChannelStatus",
|
|
64
|
+
"ConnectionError",
|
|
65
|
+
"DeviceInfo",
|
|
66
|
+
"DeviceError",
|
|
67
|
+
"DeviceService",
|
|
68
|
+
"DeviceType",
|
|
69
|
+
"HttpTransport",
|
|
70
|
+
"NvrInfo",
|
|
71
|
+
"RecordDay",
|
|
72
|
+
"RecordDaysResponse",
|
|
73
|
+
"RecordError",
|
|
74
|
+
"RecordSearchProcessResponse",
|
|
75
|
+
"RecordSearchResultsResponse",
|
|
76
|
+
"RecordSegment",
|
|
77
|
+
"RecordService",
|
|
78
|
+
"Request",
|
|
79
|
+
"Response",
|
|
80
|
+
"RtspStreamInfo",
|
|
81
|
+
"Session",
|
|
82
|
+
"SessionInfo",
|
|
83
|
+
"sha256_hex",
|
|
84
|
+
"StreamError",
|
|
85
|
+
"StreamService",
|
|
86
|
+
"StreamType",
|
|
87
|
+
"Timeout",
|
|
88
|
+
"TimeoutError",
|
|
89
|
+
"TimeRange",
|
|
90
|
+
"Transport",
|
|
91
|
+
"TransportConfig",
|
|
92
|
+
"TransportError",
|
|
93
|
+
"ValidationError",
|
|
94
|
+
"VigiClient",
|
|
95
|
+
"VigiError",
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
__version__ = "0.1.0"
|