shopee-global-api 1.0.0__py3-none-any.whl
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.
- shopee_api_sdk/__init__.py +3 -0
- shopee_api_sdk/client.py +73 -0
- shopee_global_api-1.0.0.dist-info/METADATA +126 -0
- shopee_global_api-1.0.0.dist-info/RECORD +7 -0
- shopee_global_api-1.0.0.dist-info/WHEEL +5 -0
- shopee_global_api-1.0.0.dist-info/licenses/LICENSE +21 -0
- shopee_global_api-1.0.0.dist-info/top_level.txt +1 -0
shopee_api_sdk/client.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Zero-dependency Python client for the Shopee Global E-Commerce, Live & Affiliate API (RapidAPI)."""
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import urllib.parse
|
|
5
|
+
import urllib.request
|
|
6
|
+
|
|
7
|
+
DEFAULT_HOST = "shopee-e-commerce-live-affiliate-intelligence.p.rapidapi.com"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ShopeeClient:
|
|
11
|
+
def __init__(self, rapidapi_key: str | None = None, host: str = DEFAULT_HOST, timeout: int = 20):
|
|
12
|
+
self.api_key = rapidapi_key or os.environ.get("RAPIDAPI_KEY", "")
|
|
13
|
+
if not self.api_key:
|
|
14
|
+
raise ValueError("Provide rapidapi_key or set RAPIDAPI_KEY environment variable.")
|
|
15
|
+
self.host = host
|
|
16
|
+
self.timeout = timeout
|
|
17
|
+
|
|
18
|
+
def _request(self, method: str, path: str, params: dict | None = None, body: dict | None = None) -> dict:
|
|
19
|
+
qs = ""
|
|
20
|
+
if params:
|
|
21
|
+
clean = {k: v for k, v in params.items() if v is not None and v != ""}
|
|
22
|
+
if clean:
|
|
23
|
+
qs = "?" + urllib.parse.urlencode(clean)
|
|
24
|
+
url = f"https://{self.host}{path}{qs}"
|
|
25
|
+
headers = {
|
|
26
|
+
"X-RapidAPI-Key": self.api_key,
|
|
27
|
+
"X-RapidAPI-Host": self.host,
|
|
28
|
+
"Accept": "application/json",
|
|
29
|
+
"User-Agent": "jistudio-shopee-sdk-py/1.0",
|
|
30
|
+
}
|
|
31
|
+
data = None
|
|
32
|
+
if body is not None:
|
|
33
|
+
headers["Content-Type"] = "application/json"
|
|
34
|
+
data = json.dumps(body).encode("utf-8")
|
|
35
|
+
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
|
36
|
+
with urllib.request.urlopen(req, timeout=self.timeout) as resp:
|
|
37
|
+
return json.loads(resp.read().decode("utf-8"))
|
|
38
|
+
|
|
39
|
+
def health(self, country: str = "vn") -> dict:
|
|
40
|
+
return self._request("GET", "/v1/rapidapi/health", {"country": country})
|
|
41
|
+
|
|
42
|
+
def get_product_detail(self, url: str = "", shop_id: str = "", item_id: str = "", country: str = "vn", affiliate_id: str = "") -> dict:
|
|
43
|
+
return self._request("GET", "/v1/rapidapi/product/detail", {"url": url, "shop_id": shop_id, "item_id": item_id, "country": country, "affiliate_id": affiliate_id})
|
|
44
|
+
|
|
45
|
+
def batch_products(self, urls: list[str], country: str = "vn", affiliate_id: str = "") -> dict:
|
|
46
|
+
return self._request("POST", "/v1/rapidapi/product/batch", body={"urls": urls, "country": country, "affiliate_id": affiliate_id})
|
|
47
|
+
|
|
48
|
+
def get_categories(self, url: str = "", shop_id: str = "", item_id: str = "", country: str = "vn") -> dict:
|
|
49
|
+
return self._request("GET", "/v1/rapidapi/product/categories", {"url": url, "shop_id": shop_id, "item_id": item_id, "country": country})
|
|
50
|
+
|
|
51
|
+
def get_daily_discover(self, country: str = "vn", limit: int = 15, offset: int = 0) -> dict:
|
|
52
|
+
return self._request("GET", "/v1/rapidapi/trends/daily-discover", {"country": country, "limit": limit, "offset": offset})
|
|
53
|
+
|
|
54
|
+
def get_hot_picks(self, country: str = "vn", preset_key: str = "beauty_hair", limit: int = 10) -> dict:
|
|
55
|
+
return self._request("GET", "/v1/rapidapi/trends/hot-picks", {"country": country, "preset_key": preset_key, "limit": limit})
|
|
56
|
+
|
|
57
|
+
def search_keywords(self, keyword: str, country: str = "vn") -> dict:
|
|
58
|
+
return self._request("GET", "/v1/rapidapi/trends/search-keywords", {"keyword": keyword, "country": country})
|
|
59
|
+
|
|
60
|
+
def get_shop_profile(self, shop_id: str, country: str = "vn") -> dict:
|
|
61
|
+
return self._request("GET", "/v1/rapidapi/shop/profile", {"shop_id": shop_id, "country": country})
|
|
62
|
+
|
|
63
|
+
def discover_live_rooms(self, country: str = "vn", limit: int = 10, offset: int = 0) -> dict:
|
|
64
|
+
return self._request("GET", "/v1/rapidapi/live/discover", {"country": country, "limit": limit, "offset": offset})
|
|
65
|
+
|
|
66
|
+
def get_live_bag_items(self, session_id: str | int, country: str = "vn", offset: int = 0) -> dict:
|
|
67
|
+
return self._request("GET", "/v1/rapidapi/live/bag-items", {"session_id": str(session_id), "country": country, "offset": offset})
|
|
68
|
+
|
|
69
|
+
def get_live_stream_info(self, session_id: str | int, country: str = "vn") -> dict:
|
|
70
|
+
return self._request("GET", "/v1/rapidapi/live/stream-info", {"session_id": str(session_id), "country": country})
|
|
71
|
+
|
|
72
|
+
def analyze_affiliate(self, urls: list[str], affiliate_id: str, country: str = "vn", sub_ids: list[str] | None = None) -> dict:
|
|
73
|
+
return self._request("POST", "/v1/rapidapi/affiliate/analyze", body={"urls": urls, "affiliate_id": affiliate_id, "country": country, "sub_ids": sub_ids or []})
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shopee-global-api
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Zero-dependency Python SDK for Shopee Global 8-Market API (exact unrounded sold counts, Live bags, batch 20 SKUs & affiliate).
|
|
5
|
+
Author-email: JiStudio <dev@jistudio.dev>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://jistudio-dev.github.io/shopee-api/
|
|
8
|
+
Project-URL: Repository, https://github.com/jistudio-dev/shopee-api-sdk
|
|
9
|
+
Project-URL: Documentation, https://jistudio-dev.github.io/shopee-api/
|
|
10
|
+
Keywords: shopee,shopee-api,ecommerce,price-tracker,rapidapi,apify
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# Shopee API SDK — 8 Markets, Exact Unrounded Sold Count, Live Bags & Affiliate (Python / Node.js / n8n)
|
|
26
|
+
|
|
27
|
+
[](https://rapidapi.com/Techssss/api/shopee-e-commerce-live-affiliate-intelligence/playground)
|
|
28
|
+
|
|
29
|
+
Zero-dependency **Python** and **Node.js (ESM)** SDK + ready-to-import **n8n price tracker workflow** for the **Shopee Global E-Commerce, Live & Affiliate API** across all 8 Shopee markets (`VN, ID, TH, PH, MY, SG, TW, BR`).
|
|
30
|
+
|
|
31
|
+
- **Exact unrounded sales**: Receive `historical_sold: 1096754` and `monthly_sold: 27202` instead of `"10k+ sold"`.
|
|
32
|
+
- **All 8 countries**: `vn`, `id`, `th`, `ph`, `my`, `sg`, `tw`, `br` (auto-detected when passing a product URL or shortlink).
|
|
33
|
+
- **13 endpoints**: Product detail, 20x batch fetch, category tree, Daily Discover, Hot Picks, buyer search autocomplete, Shop profile, Shopee Live rooms/bags/HLS streams, and 8-format affiliate link & commission calculator.
|
|
34
|
+
- **Zero cookies, zero browser setup, zero pip/npm dependency bloat.**
|
|
35
|
+
|
|
36
|
+
<p>
|
|
37
|
+
<a href="https://rapidapi.com/Techssss/api/shopee-e-commerce-live-affiliate-intelligence/playground"><img src="https://api.apify.com/v2/key-value-stores/0J5jsCbmj4kPfyj6H/records/rapid-shopee-cta-v1.png" width="268" height="48" alt="Test Shopee Global API on RapidAPI →"></a>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
> Need bulk scheduled dataset exports (CSV / Excel / Google Sheets)? Also available on [Apify Store (`jistudio/shopee-scraper`)](https://apify.com/jistudio/shopee-scraper).
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## How It Works
|
|
45
|
+
|
|
46
|
+
<p align="center">
|
|
47
|
+
<img src="https://api.apify.com/v2/key-value-stores/0J5jsCbmj4kPfyj6H/records/rapid-shopee-step1-v1.png" width="820" alt="Step 1: Pass any Shopee URL or IDs"/><br/>
|
|
48
|
+
<img src="https://api.apify.com/v2/key-value-stores/0J5jsCbmj4kPfyj6H/records/step-arrow-down.svg" width="40" alt=""/><br/>
|
|
49
|
+
<img src="https://api.apify.com/v2/key-value-stores/0J5jsCbmj4kPfyj6H/records/rapid-shopee-step2-v1.png" width="820" alt="Step 2: Receive structured JSON with exact unrounded sold count"/>
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quickstart
|
|
55
|
+
|
|
56
|
+
### 1. Python (Zero Dependencies — Standard Library Only)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
export RAPIDAPI_KEY="YOUR_RAPIDAPI_KEY"
|
|
60
|
+
python examples/quickstart.py
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from python.shopee_api_sdk import ShopeeClient
|
|
65
|
+
|
|
66
|
+
client = ShopeeClient(rapidapi_key="YOUR_RAPIDAPI_KEY")
|
|
67
|
+
|
|
68
|
+
# 1. Exact product detail (auto-detects country, shop_id, item_id)
|
|
69
|
+
detail = client.get_product_detail(url="https://shopee.vn/product/37251933/41412722725")
|
|
70
|
+
p = detail["product"]
|
|
71
|
+
print(p["name"], "| Price:", p["price"], "| Exact Sold:", p["historical_sold"])
|
|
72
|
+
|
|
73
|
+
# 2. Indonesia Daily Discover trending products
|
|
74
|
+
id_trends = client.get_daily_discover(country="id", limit=5)
|
|
75
|
+
print("Top ID item:", id_trends["items"][0]["name"])
|
|
76
|
+
|
|
77
|
+
# 3. Affiliate commission & 8 tracking link formats
|
|
78
|
+
aff = client.analyze_affiliate(
|
|
79
|
+
urls=["https://shopee.vn/product/37251933/41412722725"],
|
|
80
|
+
affiliate_id="17321010010",
|
|
81
|
+
country="vn",
|
|
82
|
+
)
|
|
83
|
+
print("Commission:", aff["items"][0]["affiliate_commission"])
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. Node.js 18+ (Zero Dependencies — Native `fetch`)
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
export RAPIDAPI_KEY="YOUR_RAPIDAPI_KEY"
|
|
90
|
+
node examples/quickstart.mjs
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
import { ShopeeClient } from "./node/index.mjs";
|
|
95
|
+
|
|
96
|
+
const client = new ShopeeClient(process.env.RAPIDAPI_KEY);
|
|
97
|
+
const res = await client.getProductDetail({ url: "https://shopee.vn/product/37251933/41412722725" });
|
|
98
|
+
console.log(res.product.name, "Exact Sold:", res.product.historical_sold);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 3. n8n Automated Price & Sales Tracker
|
|
102
|
+
|
|
103
|
+
Import [`workflows/n8n-shopee-price-tracker.json`](./workflows/n8n-shopee-price-tracker.json) into n8n, set your `RAPIDAPI_KEY` header on the HTTP Request node, and schedule hourly price & sold-velocity tracking.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Supported 8 Marketplaces
|
|
108
|
+
|
|
109
|
+
| Code | Country | Domain | Currency |
|
|
110
|
+
| :-: | :--- | :--- | :-: |
|
|
111
|
+
| `vn` | Vietnam | `shopee.vn` | `VND` |
|
|
112
|
+
| `id` | Indonesia | `shopee.co.id` | `IDR` |
|
|
113
|
+
| `th` | Thailand | `shopee.co.th` | `THB` |
|
|
114
|
+
| `ph` | Philippines | `shopee.ph` | `PHP` |
|
|
115
|
+
| `my` | Malaysia | `shopee.com.my` | `MYR` |
|
|
116
|
+
| `sg` | Singapore | `shopee.sg` | `SGD` |
|
|
117
|
+
| `tw` | Taiwan | `shopee.tw` | `TWD` |
|
|
118
|
+
| `br` | Brazil | `shopee.com.br` | `BRL` |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## JiStudio Ecosystem
|
|
123
|
+
|
|
124
|
+
- **RapidAPI**: [Shopee Global API](https://rapidapi.com/Techssss/api/shopee-e-commerce-live-affiliate-intelligence) · [TikTok & Shop API](https://rapidapi.com/Techssss/api/tiktok-data-tiktok-shop-no-watermark-video) · [Twitter (X) & Crypto API](https://rapidapi.com/Techssss/api/twitter-x-real-time-data-crypto-x-intel)
|
|
125
|
+
- **GitHub Org**: [github.com/jistudio-dev](https://github.com/jistudio-dev) · **Apify Store**: [apify.com/jistudio](https://apify.com/jistudio)
|
|
126
|
+
- **License**: MIT — Independent public market research & affiliate SDK; not affiliated with Shopee or Sea Limited.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
shopee_api_sdk/__init__.py,sha256=xVF49AMZDQ_eJJjpeQcF2AtFd37BoOA799nN3WWr6jc,61
|
|
2
|
+
shopee_api_sdk/client.py,sha256=QnqYaCg_AcSbsi5TNJcF6QI_V6EMIhdZndr9WcCfKWk,4329
|
|
3
|
+
shopee_global_api-1.0.0.dist-info/licenses/LICENSE,sha256=9XaDjeRcS3kb2YaM101hq4LFeh2rGvaFzI_5V9wzWXg,1099
|
|
4
|
+
shopee_global_api-1.0.0.dist-info/METADATA,sha256=HflNeQ04IkA1bcwrZXL1BNGeVOYUQIUlkNcoBdudMIk,6082
|
|
5
|
+
shopee_global_api-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
+
shopee_global_api-1.0.0.dist-info/top_level.txt,sha256=y1ujTeJ4OSqmGO6aMhkOHfsRLjnEcxkIanPLd6Xr8pI,15
|
|
7
|
+
shopee_global_api-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JiStudio (https://github.com/jistudio-dev)
|
|
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 @@
|
|
|
1
|
+
shopee_api_sdk
|