justoneapi 1.0.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
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,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: justoneapi
3
+ Version: 1.0.0
4
+ Summary: Official Python SDK for Just One API
5
+ Author-email: Just One API <justoneapi@gmail.com>
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: requests
9
+ Dynamic: license-file
10
+
11
+ # Just One API - Python SDK
12
+
13
+ Official Python SDK for accessing [Just One API](https://justoneapi.com) — a unified data service platform offering structured data from Social, E-commerce platforms such as Xiaohongshu, Taobao, Douyin, Kuaishou, Bilibili, and Weibo.
14
+
15
+ This SDK simplifies API integration and request signing, allowing developers to easily retrieve platform-specific data with minimal setup.
16
+
17
+ ---
18
+
19
+ ## 🚀 Installation
20
+
21
+ Install via PyPI:
22
+
23
+ ```bash
24
+ pip install justoneapi
25
+ ```
26
+
27
+ ---
28
+
29
+ ## 🛠 Quick Start
30
+
31
+ ```python
32
+ from justoneapi.client import JustOneAPIClient
33
+
34
+ client = JustOneAPIClient(token="your_token")
35
+
36
+ # Example: Get Douyin Video detail
37
+ result, data, message = client.douyin.get_video_detail_v2(video_id="7428906452091145483")
38
+ print(result)
39
+ print(data)
40
+ print(message)
41
+
42
+ # Example: Douyin Video Search
43
+ result, data, message, has_next_page = client.douyin.search_video_v4(keyword="deepseek", sort_type="_0", publish_time="_0", duration="_0", page=1)
44
+ print(result)
45
+ print(data)
46
+ print(message)
47
+ print(has_next_page)
48
+ ```
49
+
50
+ ### 📦 Return Value Description
51
+
52
+ Each API method returns one or more of the following values:
53
+
54
+ | Variable | Type | Description |
55
+ |------------------|----------|-------------|
56
+ | `result` | `bool` | Whether the request was successful. `True` means success, `False` means failure. |
57
+ | `data` | `dict` / `list` | The actual data returned from the API. Structure varies by endpoint. |
58
+ | `message` | `str` | Message from the server. Contains error info when request fails. |
59
+ | `has_next_page` | `bool` | Present in paginated APIs. Indicates whether more data is available. |
60
+
61
+ ---
62
+
63
+ ## 🔐 Authentication
64
+
65
+ All API requests require a valid API token.
66
+ You can obtain your token by contact us:
67
+ 👉 [Contact](https://justoneapi.com/contact)
68
+
69
+ ---
70
+
71
+ ## 📚 Documentation
72
+
73
+ 👉 Full API docs: [https://justoneapi.com/docs](https://doc.justoneapi.com)
74
+
75
+ Includes:
76
+ - Request parameters
77
+ - Response fields
78
+ - Error codes
79
+
80
+ ---
81
+
82
+ ## 🏠 Official Website
83
+
84
+ 👉 [https://justoneapi.com](https://justoneapi.com)
85
+
86
+ Learn more about the project, data sources, and commercial integration opportunities.
87
+
88
+ ---
89
+
90
+ ## 📬 Contact Us
91
+
92
+ If you have any questions, feedback, or partnership inquiries:
93
+
94
+ - Email: **justoneapi@gmail.com**
95
+ - Telegram: [@justoneapi](https://t.me/justoneapi)
96
+
97
+ ---
98
+
99
+ ## 🪪 License
100
+
101
+ This project is licensed under the MIT License.
102
+ See the [LICENSE](./LICENSE) file for details.
@@ -0,0 +1,92 @@
1
+ # Just One API - Python SDK
2
+
3
+ Official Python SDK for accessing [Just One API](https://justoneapi.com) — a unified data service platform offering structured data from Social, E-commerce platforms such as Xiaohongshu, Taobao, Douyin, Kuaishou, Bilibili, and Weibo.
4
+
5
+ This SDK simplifies API integration and request signing, allowing developers to easily retrieve platform-specific data with minimal setup.
6
+
7
+ ---
8
+
9
+ ## 🚀 Installation
10
+
11
+ Install via PyPI:
12
+
13
+ ```bash
14
+ pip install justoneapi
15
+ ```
16
+
17
+ ---
18
+
19
+ ## 🛠 Quick Start
20
+
21
+ ```python
22
+ from justoneapi.client import JustOneAPIClient
23
+
24
+ client = JustOneAPIClient(token="your_token")
25
+
26
+ # Example: Get Douyin Video detail
27
+ result, data, message = client.douyin.get_video_detail_v2(video_id="7428906452091145483")
28
+ print(result)
29
+ print(data)
30
+ print(message)
31
+
32
+ # Example: Douyin Video Search
33
+ result, data, message, has_next_page = client.douyin.search_video_v4(keyword="deepseek", sort_type="_0", publish_time="_0", duration="_0", page=1)
34
+ print(result)
35
+ print(data)
36
+ print(message)
37
+ print(has_next_page)
38
+ ```
39
+
40
+ ### 📦 Return Value Description
41
+
42
+ Each API method returns one or more of the following values:
43
+
44
+ | Variable | Type | Description |
45
+ |------------------|----------|-------------|
46
+ | `result` | `bool` | Whether the request was successful. `True` means success, `False` means failure. |
47
+ | `data` | `dict` / `list` | The actual data returned from the API. Structure varies by endpoint. |
48
+ | `message` | `str` | Message from the server. Contains error info when request fails. |
49
+ | `has_next_page` | `bool` | Present in paginated APIs. Indicates whether more data is available. |
50
+
51
+ ---
52
+
53
+ ## 🔐 Authentication
54
+
55
+ All API requests require a valid API token.
56
+ You can obtain your token by contact us:
57
+ 👉 [Contact](https://justoneapi.com/contact)
58
+
59
+ ---
60
+
61
+ ## 📚 Documentation
62
+
63
+ 👉 Full API docs: [https://justoneapi.com/docs](https://doc.justoneapi.com)
64
+
65
+ Includes:
66
+ - Request parameters
67
+ - Response fields
68
+ - Error codes
69
+
70
+ ---
71
+
72
+ ## 🏠 Official Website
73
+
74
+ 👉 [https://justoneapi.com](https://justoneapi.com)
75
+
76
+ Learn more about the project, data sources, and commercial integration opportunities.
77
+
78
+ ---
79
+
80
+ ## 📬 Contact Us
81
+
82
+ If you have any questions, feedback, or partnership inquiries:
83
+
84
+ - Email: **justoneapi@gmail.com**
85
+ - Telegram: [@justoneapi](https://t.me/justoneapi)
86
+
87
+ ---
88
+
89
+ ## 🪪 License
90
+
91
+ This project is licensed under the MIT License.
92
+ See the [LICENSE](./LICENSE) file for details.
@@ -0,0 +1,2 @@
1
+ __version__ = "1.0.0"
2
+
File without changes
@@ -0,0 +1,82 @@
1
+ from justoneapi import config
2
+ from justoneapi.apis import request_util
3
+ from justoneapi.log import logger
4
+
5
+
6
+ class BilibiliAPI:
7
+ def __init__(self, token):
8
+ self.token = token
9
+
10
+ def get_video_detail_v2(self, bvid: str):
11
+ url = f"{config.BASE_URL}/api/bilibili/get-video-detail/v2"
12
+ params = {
13
+ "token": self.token,
14
+ "bvid": bvid,
15
+ }
16
+ return request_util.get_request(url, params)
17
+
18
+ def get_user_video_list_v2(self, uid: str, aid: str = None):
19
+ url = f"{config.BASE_URL}/api/bilibili/get-user-video-list/v2"
20
+ params = {
21
+ "token": self.token,
22
+ "uid": uid,
23
+ }
24
+ if aid:
25
+ params["aid"] = aid
26
+
27
+ has_next_page = False
28
+ result, data, message = request_util.get_request_page(url, params)
29
+ try:
30
+ if data:
31
+ if data.get("data", {}).get("has_next", False) is True:
32
+ has_next_page = True
33
+ except Exception as e:
34
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
35
+ return result, data, message, has_next_page
36
+
37
+ def get_user_detail_v2(self, uid: str):
38
+ url = f"{config.BASE_URL}/api/bilibili/get-user-detail/v2"
39
+ params = {
40
+ "token": self.token,
41
+ "uid": uid,
42
+ }
43
+ return request_util.get_request(url, params)
44
+
45
+ def get_video_comment_v2(self, aid: str, cursor: str = None):
46
+ url = f"{config.BASE_URL}/api/bilibili/get-video-comment/v2"
47
+ params = {
48
+ "token": self.token,
49
+ "aid": aid,
50
+ }
51
+ if cursor:
52
+ params["cursor"] = cursor
53
+
54
+ has_next_page = False
55
+ result, data, message = request_util.get_request_page(url, params)
56
+ try:
57
+ if data:
58
+ if data.get("data", {}).get("has_next", False) is True:
59
+ has_next_page = True
60
+ except Exception as e:
61
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
62
+ return result, data, message, has_next_page
63
+
64
+ def search_video_v2(self, keyword: str, page: int):
65
+ url = f"{config.BASE_URL}/api/bilibili/search-video/v2"
66
+ params = {
67
+ "token": self.token,
68
+ "keyword": keyword,
69
+ "page": page,
70
+ }
71
+
72
+ has_next_page = False
73
+ result, data, message = request_util.get_request_page(url, params)
74
+ try:
75
+ if data:
76
+ if data.get("data", {}).get("result"):
77
+ if page < data.get("data", {}).get("numPages", 0):
78
+ has_next_page = True
79
+ except Exception as e:
80
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
81
+ return result, data, message, has_next_page
82
+
@@ -0,0 +1,121 @@
1
+ from justoneapi import config
2
+ from justoneapi.apis import request_util
3
+ from justoneapi.log import logger
4
+
5
+
6
+ class DouyinAPI:
7
+ def __init__(self, token):
8
+ self.token = token
9
+
10
+ def get_user_detail_v3(self, sec_uid: str):
11
+ url = f"{config.BASE_URL}/api/douyin/get-user-detail/v3"
12
+ params = {
13
+ "token": self.token,
14
+ "secUid": sec_uid,
15
+ }
16
+ return request_util.get_request(url, params)
17
+
18
+ def get_user_video_list_v3(self, sec_uid: str, max_cursor: int):
19
+ url = f"{config.BASE_URL}/api/douyin/get-user-video-list/v3"
20
+ params = {
21
+ "token": self.token,
22
+ "secUid": sec_uid,
23
+ "maxCursor": max_cursor,
24
+ }
25
+
26
+ has_next_page = False
27
+ result, data, message = request_util.get_request_page(url, params)
28
+ try:
29
+ if data:
30
+ if data.get("has_more") == 1:
31
+ has_next_page = True
32
+ except Exception as e:
33
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
34
+ return result, data, message, has_next_page
35
+
36
+ def get_video_detail_v2(self, video_id: str):
37
+ url = f"{config.BASE_URL}/api/douyin/get-video-detail/v2"
38
+ params = {
39
+ "token": self.token,
40
+ "videoId": video_id,
41
+ }
42
+ return request_util.get_request(url, params)
43
+
44
+ def search_video_v4(self, keyword: str, sort_type: str, publish_time: str, duration: str, page: int, search_id: str = None):
45
+ url = f"{config.BASE_URL}/api/douyin/search-video/v4"
46
+ params = {
47
+ "token": self.token,
48
+ "keyword": keyword,
49
+ "sortType": sort_type,
50
+ "publishTime": publish_time,
51
+ "duration": duration,
52
+ "page": page,
53
+ }
54
+ if search_id:
55
+ params["searchId"] = search_id
56
+
57
+ has_next_page = False
58
+ result, data, message = request_util.get_request_page(url, params)
59
+ try:
60
+ if data:
61
+ if data.get("business_config", {}).get("has_more", 0) == 1:
62
+ has_next_page = True
63
+ except Exception as e:
64
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
65
+ return result, data, message, has_next_page
66
+
67
+ def search_user_v2(self, keyword: str, page: int, user_type: str = None):
68
+ url = f"{config.BASE_URL}/api/douyin/search-user/v2"
69
+ params = {
70
+ "token": self.token,
71
+ "keyword": keyword,
72
+ "page": page,
73
+ }
74
+ if user_type:
75
+ params["userType"] = user_type
76
+
77
+ has_next_page = False
78
+ result, data, message = request_util.get_request_page(url, params)
79
+ try:
80
+ if data:
81
+ if data.get("business_config", {}).get("has_more", 0) == 1:
82
+ has_next_page = True
83
+ except Exception as e:
84
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
85
+ return result, data, message, has_next_page
86
+
87
+ def get_video_comment_v1(self, aweme_id: str, page: int):
88
+ url = f"{config.BASE_URL}/api/douyin/get-video-comment/v1"
89
+ params = {
90
+ "token": self.token,
91
+ "awemeId": aweme_id,
92
+ "page": page,
93
+ }
94
+
95
+ has_next_page = False
96
+ result, data, message = request_util.get_request_page(url, params)
97
+ try:
98
+ if data:
99
+ if data.get("has_more") == 1:
100
+ has_next_page = True
101
+ except Exception as e:
102
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
103
+ return result, data, message, has_next_page
104
+
105
+ def get_video_sub_comment_v1(self, comment_id: str, page: int):
106
+ url = f"{config.BASE_URL}/api/douyin/get-video-sub-comment/v1"
107
+ params = {
108
+ "token": self.token,
109
+ "commentId": comment_id,
110
+ "page": page,
111
+ }
112
+
113
+ has_next_page = False
114
+ result, data, message = request_util.get_request_page(url, params)
115
+ try:
116
+ if data:
117
+ if data.get("has_more") == 1:
118
+ has_next_page = True
119
+ except Exception as e:
120
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
121
+ return result, data, message, has_next_page
@@ -0,0 +1,80 @@
1
+ from justoneapi import config
2
+ from justoneapi.apis import request_util
3
+ from justoneapi.log import logger
4
+
5
+
6
+ class KuaishouAPI:
7
+ def __init__(self, token):
8
+ self.token = token
9
+
10
+ def search_user_v2(self, keyword: str, page: int):
11
+ url = f"{config.BASE_URL}/api/kuaishou/search-user/v2"
12
+ params = {
13
+ "token": self.token,
14
+ "keyword": keyword,
15
+ "page": page,
16
+ }
17
+
18
+ has_next_page = False
19
+ result, data, message = request_util.get_request_page(url, params)
20
+ try:
21
+ if data:
22
+ if data.get("users"):
23
+ has_next_page = True
24
+ except Exception as e:
25
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
26
+ return result, data, message, has_next_page
27
+
28
+ def get_user_video_list_v2(self, user_id: str, pcursor: str = None):
29
+ url = f"{config.BASE_URL}/api/kuaishou/get-user-video-list/v2"
30
+ params = {
31
+ "token": self.token,
32
+ "userId": user_id,
33
+ }
34
+ if pcursor:
35
+ params["pcursor"] = pcursor
36
+
37
+ has_next_page = False
38
+ result, data, message = request_util.get_request_page(url, params)
39
+ try:
40
+ if data:
41
+ if data.get("feeds"):
42
+ has_next_page = True
43
+ except Exception as e:
44
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
45
+ return result, data, message, has_next_page
46
+
47
+ def get_video_detail_v2(self, video_id: str):
48
+ url = f"{config.BASE_URL}/api/kuaishou/get-video-detail/v2"
49
+ params = {
50
+ "token": self.token,
51
+ "videoId": video_id,
52
+ }
53
+ return request_util.get_request(url, params)
54
+
55
+ def search_video_v2(self, keyword: str, page: int):
56
+ url = f"{config.BASE_URL}/api/kuaishou/search-video/v2"
57
+ params = {
58
+ "token": self.token,
59
+ "keyword": keyword,
60
+ "page": page,
61
+ }
62
+
63
+ has_next_page = False
64
+ result, data, message = request_util.get_request_page(url, params)
65
+ try:
66
+ if data:
67
+ if data.get("feeds"):
68
+ has_next_page = True
69
+ except Exception as e:
70
+ logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
71
+ return result, data, message, has_next_page
72
+
73
+ def get_user_detail_v2(self, user_id: str):
74
+ url = f"{config.BASE_URL}/api/kuaishou/get-user-detail/v1"
75
+ params = {
76
+ "token": self.token,
77
+ "userId": user_id,
78
+ }
79
+ return request_util.get_request(url, params)
80
+
@@ -0,0 +1,58 @@
1
+ import requests
2
+ from justoneapi import __version__
3
+
4
+ from justoneapi.log import logger
5
+
6
+
7
+ def _request(method: str, url: str, params: dict, timeout: int) -> requests.Response:
8
+ headers = {
9
+ "JUSTONEAPI_PYTHON_SKD_VERSION": __version__,
10
+ }
11
+ response = requests.request(method, url, params=params, timeout=timeout, headers=headers)
12
+
13
+ log_message = response.headers.get("JUSTONEAPI_PYTHON_SDK_LOG_MESSAGE")
14
+ if log_message:
15
+ logger.warning(log_message)
16
+ version_deprecated = response.headers.get("JUSTONEAPI_PYTHON_SDK_VERSION_DEPRECATED")
17
+ if version_deprecated:
18
+ raise RuntimeError(f"JustoneAPI Python SDK version {__version__} is deprecated, please update to the latest version.")
19
+
20
+ return response
21
+
22
+
23
+ def get_request(url: str, params: dict):
24
+ try:
25
+ response_data = _request(method="GET", url=url, params=params, timeout=60).json()
26
+ code = response_data["code"]
27
+ data = response_data["data"]
28
+ message = response_data["message"]
29
+
30
+ if code == 0:
31
+ return True, data, message
32
+ if str(code).startswith('2'):
33
+ return True, data, message
34
+ return False, data, message
35
+ except RuntimeError as re:
36
+ raise re
37
+ except Exception as e:
38
+ logger.exception(e)
39
+ return False, None, "request error"
40
+
41
+
42
+ def get_request_page(url: str, params: dict):
43
+ try:
44
+ response_data = _request(method="GET", url=url, params=params, timeout=60).json()
45
+ code = response_data["code"]
46
+ data = response_data["data"]
47
+ message = response_data["message"]
48
+
49
+ if code == 0:
50
+ return True, data, message
51
+ if str(code).startswith('2'):
52
+ return True, data, message
53
+ return False, data, message
54
+ except RuntimeError as re:
55
+ raise re
56
+ except Exception as e:
57
+ logger.exception(e)
58
+ return False, None, "request error"