easybrowser-local-api-sdk 0.1.4__tar.gz → 0.1.6__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.
@@ -1,102 +1,136 @@
1
- Metadata-Version: 2.4
2
- Name: easybrowser-local-api-sdk
3
- Version: 0.1.4
4
- Summary: EasyBrowser local API SDK
5
- Requires-Python: >=3.10
6
- Description-Content-Type: text/markdown
7
- Requires-Dist: requests>=2.31
8
- Requires-Dist: loguru>=0.7
9
- Requires-Dist: patchright
10
- Requires-Dist: PySocks>=1.7
11
-
12
- # EasyBrowser Local API SDK
13
-
14
- EasyBrowser Local API SDK is a small Python client for the EasyBrowser local API.
15
-
16
- Website: https://easybrowser.pages.dev/
17
-
18
- ## Install
19
-
20
- ```bash
21
- pip install easybrowser-local-api-sdk
22
- ```
23
-
24
- ## Quick Start
25
-
26
- ```python
27
- from easybrowser_sdk import EasyBrowserAPI
28
-
29
- api = EasyBrowserAPI()
30
- api.ensure_local_api_available()
31
-
32
- environment = api.ensure_container(
33
- name="TestEnv",
34
- defaultUrl="https://example.com",
35
- )
36
- print(environment["id"])
37
- ```
38
-
39
- ## Requirements
40
-
41
- - Python 3.10+
42
- - EasyLauncher installed and running
43
-
44
- Free VIP activation is available inside EasyLauncher.
45
-
46
- ## Publish
47
-
48
- ```bash
49
- python -m pip install build twine
50
- python -m build
51
- python -m twine check dist/*
52
- python -m twine upload dist/*
53
- ```
54
-
55
- Use `__token__` as the username and a PyPI API token as the password.
56
-
57
- ---
58
-
59
- # EasyBrowser Local API SDK
60
-
61
- EasyBrowser Local API SDK 是一个用于 EasyBrowser 本地 API 的简洁 Python 客户端。
62
-
63
- 官网:https://easybrowser.pages.dev/
64
-
65
- ## 安装
66
-
67
- ```bash
68
- pip install easybrowser-local-api-sdk
69
- ```
70
-
71
- ## 快速开始
72
-
73
- ```python
74
- from easybrowser_sdk import EasyBrowserAPI
75
-
76
- api = EasyBrowserAPI()
77
- api.ensure_local_api_available()
78
-
79
- environment = api.ensure_container(
80
- name="TestEnv",
81
- defaultUrl="https://example.com",
82
- )
83
- print(environment["id"])
84
- ```
85
-
86
- ## 运行要求
87
-
88
- - Python 3.10 及以上
89
- - 已安装并运行 EasyLauncher
90
-
91
- EasyLauncher 内可免费开通 VIP。
92
-
93
- ## 发布
94
-
95
- ```bash
96
- python -m pip install build twine
97
- python -m build
98
- python -m twine check dist/*
99
- python -m twine upload dist/*
100
- ```
101
-
102
- 用户名使用 `__token__`,密码使用 PyPI API token。
1
+ Metadata-Version: 2.4
2
+ Name: easybrowser-local-api-sdk
3
+ Version: 0.1.6
4
+ Summary: EasyBrowser local API SDK
5
+ Project-URL: Homepage, https://easybrowser.pages.dev/
6
+ Project-URL: Repository, https://github.com/EasyBrowserMaster/easybrowser-local-api-sdk
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: requests>=2.31
10
+ Requires-Dist: loguru>=0.7
11
+ Requires-Dist: patchright
12
+ Requires-Dist: PySocks>=1.7
13
+
14
+ # EasyBrowser Local API SDK
15
+
16
+ EasyBrowser Local API SDK is a small Python client for the EasyBrowser local API.
17
+
18
+ Website: https://easybrowser.pages.dev/
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ pip install easybrowser-local-api-sdk
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ```python
29
+ from easybrowser_sdk import EasyBrowserAPI
30
+
31
+ api = EasyBrowserAPI()
32
+ api.ensure_local_api_available()
33
+
34
+ environment = api.ensure_container(
35
+ name="TestEnv",
36
+ defaultUrl="https://example.com",
37
+ )
38
+ print(environment["id"])
39
+ ```
40
+
41
+ ## Container lifecycle
42
+
43
+ ```python
44
+ # Soft delete (moves to trash, recoverable)
45
+ api.delete_container(env_id)
46
+
47
+ # Restore from trash
48
+ api.restore_container(env_id)
49
+
50
+ # List trashed containers
51
+ api.trash_list()
52
+
53
+ # Permanently delete + clean browser data (cookies/storage). Irreversible.
54
+ api.delete_permanently(env_id)
55
+ ```
56
+
57
+ ## Requirements
58
+
59
+ - Python 3.10+
60
+ - EasyLauncher installed and running
61
+
62
+ Free VIP activation is available inside EasyLauncher.
63
+
64
+ ## Publish
65
+
66
+ ```bash
67
+ python -m pip install build twine
68
+ python -m build
69
+ python -m twine check dist/*
70
+ python -m twine upload dist/*
71
+ ```
72
+
73
+ Use `__token__` as the username and a PyPI API token as the password.
74
+
75
+ ---
76
+
77
+ # EasyBrowser Local API SDK
78
+
79
+ EasyBrowser Local API SDK 是一个用于 EasyBrowser 本地 API 的简洁 Python 客户端。
80
+
81
+ 官网:https://easybrowser.pages.dev/
82
+
83
+ ## 安装
84
+
85
+ ```bash
86
+ pip install easybrowser-local-api-sdk
87
+ ```
88
+
89
+ ## 快速开始
90
+
91
+ ```python
92
+ from easybrowser_sdk import EasyBrowserAPI
93
+
94
+ api = EasyBrowserAPI()
95
+ api.ensure_local_api_available()
96
+
97
+ environment = api.ensure_container(
98
+ name="TestEnv",
99
+ defaultUrl="https://example.com",
100
+ )
101
+ print(environment["id"])
102
+ ```
103
+
104
+ ## 环境生命周期
105
+
106
+ ```python
107
+ # 软删除(移入回收站,可恢复)
108
+ api.delete_container(env_id)
109
+
110
+ # 从回收站恢复
111
+ api.restore_container(env_id)
112
+
113
+ # 查看回收站
114
+ api.trash_list()
115
+
116
+ # 彻底删除 + 清理浏览器数据(Cookie/存储),不可恢复
117
+ api.delete_permanently(env_id)
118
+ ```
119
+
120
+ ## 运行要求
121
+
122
+ - Python 3.10 及以上
123
+ - 已安装并运行 EasyLauncher
124
+
125
+ EasyLauncher 内可免费开通 VIP。
126
+
127
+ ## 发布
128
+
129
+ ```bash
130
+ python -m pip install build twine
131
+ python -m build
132
+ python -m twine check dist/*
133
+ python -m twine upload dist/*
134
+ ```
135
+
136
+ 用户名使用 `__token__`,密码使用 PyPI API token。
@@ -1,102 +1,123 @@
1
- Metadata-Version: 2.4
2
- Name: easybrowser-local-api-sdk
3
- Version: 0.1.4
4
- Summary: EasyBrowser local API SDK
5
- Requires-Python: >=3.10
6
- Description-Content-Type: text/markdown
7
- Requires-Dist: requests>=2.31
8
- Requires-Dist: loguru>=0.7
9
- Requires-Dist: patchright
10
- Requires-Dist: PySocks>=1.7
11
-
12
- # EasyBrowser Local API SDK
13
-
14
- EasyBrowser Local API SDK is a small Python client for the EasyBrowser local API.
15
-
16
- Website: https://easybrowser.pages.dev/
17
-
18
- ## Install
19
-
20
- ```bash
21
- pip install easybrowser-local-api-sdk
22
- ```
23
-
24
- ## Quick Start
25
-
26
- ```python
27
- from easybrowser_sdk import EasyBrowserAPI
28
-
29
- api = EasyBrowserAPI()
30
- api.ensure_local_api_available()
31
-
32
- environment = api.ensure_container(
33
- name="TestEnv",
34
- defaultUrl="https://example.com",
35
- )
36
- print(environment["id"])
37
- ```
38
-
39
- ## Requirements
40
-
41
- - Python 3.10+
42
- - EasyLauncher installed and running
43
-
44
- Free VIP activation is available inside EasyLauncher.
45
-
46
- ## Publish
47
-
48
- ```bash
49
- python -m pip install build twine
50
- python -m build
51
- python -m twine check dist/*
52
- python -m twine upload dist/*
53
- ```
54
-
55
- Use `__token__` as the username and a PyPI API token as the password.
56
-
57
- ---
58
-
59
- # EasyBrowser Local API SDK
60
-
61
- EasyBrowser Local API SDK 是一个用于 EasyBrowser 本地 API 的简洁 Python 客户端。
62
-
63
- 官网:https://easybrowser.pages.dev/
64
-
65
- ## 安装
66
-
67
- ```bash
68
- pip install easybrowser-local-api-sdk
69
- ```
70
-
71
- ## 快速开始
72
-
73
- ```python
74
- from easybrowser_sdk import EasyBrowserAPI
75
-
76
- api = EasyBrowserAPI()
77
- api.ensure_local_api_available()
78
-
79
- environment = api.ensure_container(
80
- name="TestEnv",
81
- defaultUrl="https://example.com",
82
- )
83
- print(environment["id"])
84
- ```
85
-
86
- ## 运行要求
87
-
88
- - Python 3.10 及以上
89
- - 已安装并运行 EasyLauncher
90
-
91
- EasyLauncher 内可免费开通 VIP。
92
-
93
- ## 发布
94
-
95
- ```bash
96
- python -m pip install build twine
97
- python -m build
98
- python -m twine check dist/*
99
- python -m twine upload dist/*
100
- ```
101
-
102
- 用户名使用 `__token__`,密码使用 PyPI API token。
1
+ # EasyBrowser Local API SDK
2
+
3
+ EasyBrowser Local API SDK is a small Python client for the EasyBrowser local API.
4
+
5
+ Website: https://easybrowser.pages.dev/
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install easybrowser-local-api-sdk
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```python
16
+ from easybrowser_sdk import EasyBrowserAPI
17
+
18
+ api = EasyBrowserAPI()
19
+ api.ensure_local_api_available()
20
+
21
+ environment = api.ensure_container(
22
+ name="TestEnv",
23
+ defaultUrl="https://example.com",
24
+ )
25
+ print(environment["id"])
26
+ ```
27
+
28
+ ## Container lifecycle
29
+
30
+ ```python
31
+ # Soft delete (moves to trash, recoverable)
32
+ api.delete_container(env_id)
33
+
34
+ # Restore from trash
35
+ api.restore_container(env_id)
36
+
37
+ # List trashed containers
38
+ api.trash_list()
39
+
40
+ # Permanently delete + clean browser data (cookies/storage). Irreversible.
41
+ api.delete_permanently(env_id)
42
+ ```
43
+
44
+ ## Requirements
45
+
46
+ - Python 3.10+
47
+ - EasyLauncher installed and running
48
+
49
+ Free VIP activation is available inside EasyLauncher.
50
+
51
+ ## Publish
52
+
53
+ ```bash
54
+ python -m pip install build twine
55
+ python -m build
56
+ python -m twine check dist/*
57
+ python -m twine upload dist/*
58
+ ```
59
+
60
+ Use `__token__` as the username and a PyPI API token as the password.
61
+
62
+ ---
63
+
64
+ # EasyBrowser Local API SDK
65
+
66
+ EasyBrowser Local API SDK 是一个用于 EasyBrowser 本地 API 的简洁 Python 客户端。
67
+
68
+ 官网:https://easybrowser.pages.dev/
69
+
70
+ ## 安装
71
+
72
+ ```bash
73
+ pip install easybrowser-local-api-sdk
74
+ ```
75
+
76
+ ## 快速开始
77
+
78
+ ```python
79
+ from easybrowser_sdk import EasyBrowserAPI
80
+
81
+ api = EasyBrowserAPI()
82
+ api.ensure_local_api_available()
83
+
84
+ environment = api.ensure_container(
85
+ name="TestEnv",
86
+ defaultUrl="https://example.com",
87
+ )
88
+ print(environment["id"])
89
+ ```
90
+
91
+ ## 环境生命周期
92
+
93
+ ```python
94
+ # 软删除(移入回收站,可恢复)
95
+ api.delete_container(env_id)
96
+
97
+ # 从回收站恢复
98
+ api.restore_container(env_id)
99
+
100
+ # 查看回收站
101
+ api.trash_list()
102
+
103
+ # 彻底删除 + 清理浏览器数据(Cookie/存储),不可恢复
104
+ api.delete_permanently(env_id)
105
+ ```
106
+
107
+ ## 运行要求
108
+
109
+ - Python 3.10 及以上
110
+ - 已安装并运行 EasyLauncher
111
+
112
+ EasyLauncher 内可免费开通 VIP。
113
+
114
+ ## 发布
115
+
116
+ ```bash
117
+ python -m pip install build twine
118
+ python -m build
119
+ python -m twine check dist/*
120
+ python -m twine upload dist/*
121
+ ```
122
+
123
+ 用户名使用 `__token__`,密码使用 PyPI API token。
@@ -1,3 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: easybrowser-local-api-sdk
3
+ Version: 0.1.6
4
+ Summary: EasyBrowser local API SDK
5
+ Project-URL: Homepage, https://easybrowser.pages.dev/
6
+ Project-URL: Repository, https://github.com/EasyBrowserMaster/easybrowser-local-api-sdk
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: requests>=2.31
10
+ Requires-Dist: loguru>=0.7
11
+ Requires-Dist: patchright
12
+ Requires-Dist: PySocks>=1.7
13
+
1
14
  # EasyBrowser Local API SDK
2
15
 
3
16
  EasyBrowser Local API SDK is a small Python client for the EasyBrowser local API.
@@ -25,6 +38,22 @@ environment = api.ensure_container(
25
38
  print(environment["id"])
26
39
  ```
27
40
 
41
+ ## Container lifecycle
42
+
43
+ ```python
44
+ # Soft delete (moves to trash, recoverable)
45
+ api.delete_container(env_id)
46
+
47
+ # Restore from trash
48
+ api.restore_container(env_id)
49
+
50
+ # List trashed containers
51
+ api.trash_list()
52
+
53
+ # Permanently delete + clean browser data (cookies/storage). Irreversible.
54
+ api.delete_permanently(env_id)
55
+ ```
56
+
28
57
  ## Requirements
29
58
 
30
59
  - Python 3.10+
@@ -72,6 +101,22 @@ environment = api.ensure_container(
72
101
  print(environment["id"])
73
102
  ```
74
103
 
104
+ ## 环境生命周期
105
+
106
+ ```python
107
+ # 软删除(移入回收站,可恢复)
108
+ api.delete_container(env_id)
109
+
110
+ # 从回收站恢复
111
+ api.restore_container(env_id)
112
+
113
+ # 查看回收站
114
+ api.trash_list()
115
+
116
+ # 彻底删除 + 清理浏览器数据(Cookie/存储),不可恢复
117
+ api.delete_permanently(env_id)
118
+ ```
119
+
75
120
  ## 运行要求
76
121
 
77
122
  - Python 3.10 及以上
@@ -1,6 +1,7 @@
1
1
  README.md
2
2
  easybrowser_sdk.py
3
3
  pyproject.toml
4
+ setup.cfg
4
5
  easybrowser_local_api_sdk.egg-info/PKG-INFO
5
6
  easybrowser_local_api_sdk.egg-info/SOURCES.txt
6
7
  easybrowser_local_api_sdk.egg-info/dependency_links.txt
@@ -261,6 +261,22 @@ class EasyBrowserAPI:
261
261
  except ValueError as exc:
262
262
  raise RuntimeError(f"Invalid JSON response from {self.base}{path}: {exc}") from exc
263
263
 
264
+ def _post_raw(self, path, data=None):
265
+ """POST 并返回原始响应 dict(不校验 code,供需要判断 msg 的调用方使用)。"""
266
+ try:
267
+ r = requests.post(
268
+ f"{self.base}{path}",
269
+ json=data,
270
+ headers=self.headers,
271
+ timeout=self.timeout,
272
+ )
273
+ except requests.RequestException as exc:
274
+ raise RuntimeError(format_api_unavailable_error(self.base, exc)) from exc
275
+ try:
276
+ return r.json()
277
+ except ValueError as exc:
278
+ raise RuntimeError(f"Invalid JSON response from {self.base}{path}: {exc}") from exc
279
+
264
280
  def create_container(self, name, **kw):
265
281
  return self._post("/api/v1/container/create", {"name": name, **kw})
266
282
 
@@ -305,6 +321,33 @@ class EasyBrowserAPI:
305
321
  ids = list(env_ids)
306
322
  return self._post("/api/v1/container/delete", {"ids": ids})
307
323
 
324
+ def restore_container(self, env_ids):
325
+ """Restore one or more containers from the trash. Accepts a single id or a list of ids."""
326
+ if isinstance(env_ids, str):
327
+ ids = [env_ids]
328
+ else:
329
+ ids = list(env_ids)
330
+ return self._post("/api/v1/container/restore", {"ids": ids})
331
+
332
+ def delete_permanently(self, env_ids):
333
+ """Permanently delete containers and their browser data (incl. cookies). Irreversible.
334
+
335
+ Calls /api/v1/container/delete_permanently; falls back to the legacy
336
+ /api/v1/container/purge when talking to older clients that only expose purge.
337
+ """
338
+ if isinstance(env_ids, str):
339
+ ids = [env_ids]
340
+ else:
341
+ ids = list(env_ids)
342
+ res = self._post_raw("/api/v1/container/delete_permanently", {"ids": ids})
343
+ # 老客户端没有新路由,会返回 {"code":-1,"msg":"not found"},回退到旧别名 purge
344
+ if res.get("code") != 0 and "not found" in str(res.get("msg", "")).lower():
345
+ res = self._post_raw("/api/v1/container/purge", {"ids": ids})
346
+ return self._check(res)
347
+
348
+ def trash_list(self):
349
+ return self._get("/api/v1/container/trash")
350
+
308
351
  def list_containers(self, page=1, page_size=100):
309
352
  return self._get(
310
353
  "/api/v1/container/list",
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "easybrowser-local-api-sdk"
7
- version = "0.1.4"
7
+ version = "0.1.6"
8
8
  description = "EasyBrowser local API SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -15,5 +15,9 @@ dependencies = [
15
15
  "PySocks>=1.7",
16
16
  ]
17
17
 
18
+ [project.urls]
19
+ Homepage = "https://easybrowser.pages.dev/"
20
+ Repository = "https://github.com/EasyBrowserMaster/easybrowser-local-api-sdk"
21
+
18
22
  [tool.setuptools]
19
23
  py-modules = ["easybrowser_sdk"]
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+