Skip to content

Commit 7f1e793

Browse files
authored
Merge pull request #3 from guoming0000/feature/2026-03-19/support-more-methods
update sdk
2 parents 9b83b13 + bafad21 commit 7f1e793

17 files changed

Lines changed: 661 additions & 0 deletions

appstore/01_get_classify_list.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Get App Category List
3+
4+
Retrieve the list of supported app categories for use when creating an app.
5+
6+
API: POST /v2/appstore/appstore/app/getClassifyList
7+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmimeghjk546
8+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmimeghjk546
9+
"""
10+
11+
import json
12+
import os
13+
14+
from client import SunmiAppStoreClient
15+
16+
client = SunmiAppStoreClient(
17+
app_id=os.environ["SUNMI_APP_ID"],
18+
app_key=os.environ["SUNMI_APP_KEY"],
19+
)
20+
21+
response = client.post("/v2/appstore/appstore/app/getClassifyList", {
22+
"lan_type": 1, # 1: Chinese, 2: English
23+
})
24+
25+
print(json.dumps(response, indent=4, ensure_ascii=False))

appstore/02_get_terminal_list.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Get Terminal List
3+
4+
Retrieve the list of supported device terminal models for use when creating or updating an app.
5+
6+
API: POST /v2/appstore/appstore/app/getTerminalList
7+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmifeghjk535
8+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmifeghjk535
9+
"""
10+
11+
import json
12+
import os
13+
14+
from client import SunmiAppStoreClient
15+
16+
client = SunmiAppStoreClient(
17+
app_id=os.environ["SUNMI_APP_ID"],
18+
app_key=os.environ["SUNMI_APP_KEY"],
19+
)
20+
21+
response = client.post("/v2/appstore/appstore/app/getTerminalList", {})
22+
23+
print(json.dumps(response, indent=4, ensure_ascii=False))

appstore/03_get_language_list.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Get Language List
3+
4+
Retrieve the list of country language codes for configuring multilingual app names and descriptions.
5+
6+
API: POST /v2/appstore/appstore/app/getLanguageList
7+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmideghjk524
8+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmideghjk524
9+
"""
10+
11+
import json
12+
import os
13+
14+
from client import SunmiAppStoreClient
15+
16+
client = SunmiAppStoreClient(
17+
app_id=os.environ["SUNMI_APP_ID"],
18+
app_key=os.environ["SUNMI_APP_KEY"],
19+
)
20+
21+
response = client.post("/v2/appstore/appstore/app/getLanguageList", {})
22+
23+
print(json.dumps(response, indent=4, ensure_ascii=False))

appstore/04_upload_apk.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Upload APK
3+
4+
Upload an APK file to obtain a resource UUID, which is required for creating
5+
or upgrading an app.
6+
7+
API: POST /v2/midplat/filecore/file/uploadApk
8+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmireghjk568
9+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmireghjk568
10+
"""
11+
12+
import json
13+
import os
14+
15+
from client import SunmiAppStoreClient
16+
17+
client = SunmiAppStoreClient(
18+
app_id=os.environ["SUNMI_APP_ID"],
19+
app_key=os.environ["SUNMI_APP_KEY"],
20+
)
21+
22+
file_path = "your_app.apk"
23+
24+
params = {
25+
"md5": SunmiAppStoreClient.calculate_md5(file_path),
26+
"file_type_key": "appstore_apk",
27+
}
28+
29+
response = client.upload("/v2/midplat/filecore/file/uploadApk", file_path, params)
30+
31+
print(json.dumps(response, indent=4, ensure_ascii=False))
32+
print("apk_uuid =", response.get("data", {}).get("uuid", ""))

appstore/05_upload_image.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Upload Image
3+
4+
Upload an image file (icon, vertical screenshot, or horizontal screenshot) to
5+
obtain a resource UUID, which is required for creating or updating an app.
6+
7+
API: POST /v2/midplat/filecore/file/uploadImage
8+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmizeghjk557
9+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmizeghjk557
10+
11+
file_type_key options:
12+
appstore_icon - App icon
13+
appstore_vscreenshot - Vertical screenshot
14+
appstore_hscreenshot - Horizontal screenshot
15+
"""
16+
17+
import json
18+
import os
19+
20+
from client import SunmiAppStoreClient
21+
22+
client = SunmiAppStoreClient(
23+
app_id=os.environ["SUNMI_APP_ID"],
24+
app_key=os.environ["SUNMI_APP_KEY"],
25+
)
26+
27+
file_path = "your_image.png"
28+
29+
params = {
30+
"md5": SunmiAppStoreClient.calculate_md5(file_path),
31+
"file_type_key": "appstore_icon", # appstore_icon / appstore_vscreenshot / appstore_hscreenshot
32+
}
33+
34+
response = client.upload("/v2/midplat/filecore/file/uploadImage", file_path, params)
35+
36+
print(json.dumps(response, indent=4, ensure_ascii=False))
37+
print("image_uuid =", response.get("data", {}).get("uuid", ""))

appstore/06_create_app.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""
2+
Create App
3+
4+
Create a new app on the Sunmi AppStore. Before calling this API, you need to:
5+
1. Upload the APK -> get apk_uuid (04_upload_apk.py)
6+
2. Upload icon/images -> get icon/image UUIDs (05_upload_image.py)
7+
3. Get category list -> get cf_id (01_get_classify_list.py)
8+
4. Get terminal list -> get terminal names (02_get_terminal_list.py)
9+
5. Get language list -> get lan_id (03_get_language_list.py)
10+
11+
API: POST /v2/appstore/appstore/app/createApp
12+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmrfeghjk535
13+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmrfeghjk535
14+
"""
15+
16+
import json
17+
import os
18+
19+
from client import SunmiAppStoreClient
20+
21+
client = SunmiAppStoreClient(
22+
app_id=os.environ["SUNMI_APP_ID"],
23+
app_key=os.environ["SUNMI_APP_KEY"],
24+
)
25+
26+
response = client.post("/v2/appstore/appstore/app/createApp", {
27+
"app_name": "Your App Name",
28+
"icon_url_uuid": "YOUR_ICON_UUID",
29+
"pic_vertical_screen_uuid": [
30+
"YOUR_SCREENSHOT_UUID_1",
31+
"YOUR_SCREENSHOT_UUID_2",
32+
"YOUR_SCREENSHOT_UUID_3",
33+
],
34+
# "pic_horizontal_screen_uuid": ["YOUR_HSCREENSHOT_UUID"], # optional
35+
"apk_uuid": "YOUR_APK_UUID",
36+
"app_introduction": "A brief description of your app (10-1000 characters).",
37+
"cf_id": "YOUR_CATEGORY_ID", # from Get App Category List API
38+
"terminals": ["P2", "V3"], # from Get Terminal List API
39+
"area": [1, 2, 3], # 1: Mainland China, 2: HK/MO/TW, 3: Overseas
40+
"range": 0, # 0: visible to all, 1: visible to own channel only
41+
"deployment_type": 1, # 1: full deployment, 2: gray deployment
42+
"language": [ # multilingual app names (optional)
43+
{"lan_id": "YOUR_LAN_ID", "name": "App Name in English"},
44+
],
45+
"language_introduction": [ # multilingual descriptions (optional)
46+
{"lan_id": "YOUR_LAN_ID", "introduction": "App description in English"},
47+
],
48+
"remarks": "Remarks for the reviewer (10-200 characters).",
49+
# "notify_url": "https://example.com/your-callback", # optional audit result callback URL
50+
"pond_type": 0, # 0: public store, 1: private store
51+
52+
# --- Gray deployment params (only when deployment_type=2) ---
53+
# "gray_msn_list": ["MSN1", "MSN2"],
54+
# "gray_version": 0, # 0: default gray, 2: percentage-based gray
55+
# "gray_ppm": 10000, # gray ratio, 10000 = 1% (only when gray_version=2)
56+
# "gray_entity_id_list": ["entity1"],
57+
# "gray_start_time": 1700000000, # unix timestamp
58+
# "gray_time_zone": "Asia/Shanghai",
59+
# "deploy_location_id_list": ["CN"],
60+
})
61+
62+
print(json.dumps(response, indent=4, ensure_ascii=False))

appstore/07_get_app_detail.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
Get App Detail
3+
4+
Query the basic detail configuration of an app by its package name.
5+
6+
API: POST /v2/appstore/appstore/app/getAppDetail
7+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmrzeghjk557
8+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmrzeghjk557
9+
"""
10+
11+
import json
12+
import os
13+
14+
from client import SunmiAppStoreClient
15+
16+
client = SunmiAppStoreClient(
17+
app_id=os.environ["SUNMI_APP_ID"],
18+
app_key=os.environ["SUNMI_APP_KEY"],
19+
)
20+
21+
response = client.post("/v2/appstore/appstore/app/getAppDetail", {
22+
"package_name": "com.example.yourapp",
23+
"pond_type": 0, # 0: public store, 1: private store
24+
})
25+
26+
print(json.dumps(response, indent=4, ensure_ascii=False))

appstore/08_update_app_detail.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""
2+
Update App Detail
3+
4+
Update basic information of an existing app such as introduction, screenshots,
5+
compatible terminals, and distribution regions. Changes require a new review.
6+
7+
API: POST /v2/appstore/appstore/app/updateAppDetail
8+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmiqeghjk513
9+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmiqeghjk513
10+
"""
11+
12+
import json
13+
import os
14+
15+
from client import SunmiAppStoreClient
16+
17+
client = SunmiAppStoreClient(
18+
app_id=os.environ["SUNMI_APP_ID"],
19+
app_key=os.environ["SUNMI_APP_KEY"],
20+
)
21+
22+
response = client.post("/v2/appstore/appstore/app/updateAppDetail", {
23+
"package_name": "com.example.yourapp",
24+
"language": [
25+
{"lan_id": "YOUR_LAN_ID", "name": "Updated App Name"},
26+
],
27+
"app_introduction": "Updated app description (10-1000 characters).",
28+
"language_introduction": [
29+
{"lan_id": "YOUR_LAN_ID", "introduction": "Updated description in English"},
30+
],
31+
"terminals": ["P2", "V3"],
32+
"pic_vertical_screen_uuid": [
33+
"YOUR_SCREENSHOT_UUID_1",
34+
"YOUR_SCREENSHOT_UUID_2",
35+
"YOUR_SCREENSHOT_UUID_3",
36+
],
37+
# "pic_horizontal_screen_uuid": ["YOUR_HSCREENSHOT_UUID"],
38+
"area": [1, 2, 3],
39+
"range": 0,
40+
"icon_url_uuid": "YOUR_ICON_UUID",
41+
# "notify_url": "https://example.com/your-callback",
42+
"pond_type": 0,
43+
})
44+
45+
print(json.dumps(response, indent=4, ensure_ascii=False))

appstore/09_upgrade_app_version.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
Upgrade App Version
3+
4+
Upgrade the version of an audited app. Supports both full and gray deployment.
5+
Before calling this API, upload the new APK via the Upload APK API first.
6+
7+
API: POST /v2/appstore/appstore/app/upgradeAppVersion
8+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmiceghjk502
9+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmiceghjk502
10+
"""
11+
12+
import json
13+
import os
14+
15+
from client import SunmiAppStoreClient
16+
17+
client = SunmiAppStoreClient(
18+
app_id=os.environ["SUNMI_APP_ID"],
19+
app_key=os.environ["SUNMI_APP_KEY"],
20+
)
21+
22+
response = client.post("/v2/appstore/appstore/app/upgradeAppVersion", {
23+
"package_name": "com.example.yourapp",
24+
"remarks": "Remarks for the reviewer (10-200 characters).",
25+
"update_content": "What's new in this version (3-2500 characters).",
26+
"update_flag": 1, # 1: full release, 2: gray release
27+
"apk_uuid": "YOUR_APK_UUID", # UUID from Upload APK API
28+
# "notify_url": "https://example.com/your-callback",
29+
"pond_type": 0, # 0: public store, 1: private store
30+
31+
# --- Gray deployment params (only when update_flag=2) ---
32+
# "gray_msn_list": ["MSN1", "MSN2"],
33+
# "gray_version": 0,
34+
# "gray_ppm": 10000,
35+
# "gray_entity_id_list": ["entity1"],
36+
# "gray_start_time": 1700000000,
37+
# "gray_time_zone": "Asia/Shanghai",
38+
# "deploy_location_id_list": ["CN"],
39+
})
40+
41+
print(json.dumps(response, indent=4, ensure_ascii=False))

appstore/10_get_audit_result.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Get Audit Result
3+
4+
Batch query the audit status and results for app creation, version upgrade,
5+
or detail modification. Supports up to 100 package names per request.
6+
7+
API: POST /v2/appstore/appstore/app/getAuditResult
8+
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmrmeghjk546
9+
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmrmeghjk546
10+
"""
11+
12+
import json
13+
import os
14+
15+
from client import SunmiAppStoreClient
16+
17+
client = SunmiAppStoreClient(
18+
app_id=os.environ["SUNMI_APP_ID"],
19+
app_key=os.environ["SUNMI_APP_KEY"],
20+
)
21+
22+
response = client.post("/v2/appstore/appstore/app/getAuditResult", {
23+
"package_name_list": [
24+
"com.example.yourapp",
25+
],
26+
"pond_type": 0, # 0: public store, 1: private store
27+
})
28+
29+
print(json.dumps(response, indent=4, ensure_ascii=False))

0 commit comments

Comments
 (0)