Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions appstore/01_get_classify_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Get App Category List

Retrieve the list of supported app categories for use when creating an app.

API: POST /v2/appstore/appstore/app/getClassifyList
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmimeghjk546
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmimeghjk546
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

response = client.post("/v2/appstore/appstore/app/getClassifyList", {
"lan_type": 1, # 1: Chinese, 2: English
})

print(json.dumps(response, indent=4, ensure_ascii=False))
23 changes: 23 additions & 0 deletions appstore/02_get_terminal_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Get Terminal List

Retrieve the list of supported device terminal models for use when creating or updating an app.

API: POST /v2/appstore/appstore/app/getTerminalList
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmifeghjk535
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmifeghjk535
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

response = client.post("/v2/appstore/appstore/app/getTerminalList", {})

print(json.dumps(response, indent=4, ensure_ascii=False))
23 changes: 23 additions & 0 deletions appstore/03_get_language_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Get Language List

Retrieve the list of country language codes for configuring multilingual app names and descriptions.

API: POST /v2/appstore/appstore/app/getLanguageList
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmideghjk524
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmideghjk524
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

response = client.post("/v2/appstore/appstore/app/getLanguageList", {})

print(json.dumps(response, indent=4, ensure_ascii=False))
32 changes: 32 additions & 0 deletions appstore/04_upload_apk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Upload APK

Upload an APK file to obtain a resource UUID, which is required for creating
or upgrading an app.

API: POST /v2/midplat/filecore/file/uploadApk
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmireghjk568
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmireghjk568
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

file_path = "your_app.apk"

params = {
"md5": SunmiAppStoreClient.calculate_md5(file_path),
"file_type_key": "appstore_apk",
}

response = client.upload("/v2/midplat/filecore/file/uploadApk", file_path, params)

print(json.dumps(response, indent=4, ensure_ascii=False))
print("apk_uuid =", response.get("data", {}).get("uuid", ""))
37 changes: 37 additions & 0 deletions appstore/05_upload_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
Upload Image

Upload an image file (icon, vertical screenshot, or horizontal screenshot) to
obtain a resource UUID, which is required for creating or updating an app.

API: POST /v2/midplat/filecore/file/uploadImage
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmizeghjk557
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmizeghjk557

file_type_key options:
appstore_icon - App icon
appstore_vscreenshot - Vertical screenshot
appstore_hscreenshot - Horizontal screenshot
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

file_path = "your_image.png"

params = {
"md5": SunmiAppStoreClient.calculate_md5(file_path),
"file_type_key": "appstore_icon", # appstore_icon / appstore_vscreenshot / appstore_hscreenshot
}

response = client.upload("/v2/midplat/filecore/file/uploadImage", file_path, params)

print(json.dumps(response, indent=4, ensure_ascii=False))
print("image_uuid =", response.get("data", {}).get("uuid", ""))
62 changes: 62 additions & 0 deletions appstore/06_create_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
Create App

Create a new app on the Sunmi AppStore. Before calling this API, you need to:
1. Upload the APK -> get apk_uuid (04_upload_apk.py)
2. Upload icon/images -> get icon/image UUIDs (05_upload_image.py)
3. Get category list -> get cf_id (01_get_classify_list.py)
4. Get terminal list -> get terminal names (02_get_terminal_list.py)
5. Get language list -> get lan_id (03_get_language_list.py)

API: POST /v2/appstore/appstore/app/createApp
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmrfeghjk535
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmrfeghjk535
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

response = client.post("/v2/appstore/appstore/app/createApp", {
"app_name": "Your App Name",
"icon_url_uuid": "YOUR_ICON_UUID",
"pic_vertical_screen_uuid": [
"YOUR_SCREENSHOT_UUID_1",
"YOUR_SCREENSHOT_UUID_2",
"YOUR_SCREENSHOT_UUID_3",
],
# "pic_horizontal_screen_uuid": ["YOUR_HSCREENSHOT_UUID"], # optional
"apk_uuid": "YOUR_APK_UUID",
"app_introduction": "A brief description of your app (10-1000 characters).",
"cf_id": "YOUR_CATEGORY_ID", # from Get App Category List API
"terminals": ["P2", "V3"], # from Get Terminal List API
"area": [1, 2, 3], # 1: Mainland China, 2: HK/MO/TW, 3: Overseas
"range": 0, # 0: visible to all, 1: visible to own channel only
"deployment_type": 1, # 1: full deployment, 2: gray deployment
"language": [ # multilingual app names (optional)
{"lan_id": "YOUR_LAN_ID", "name": "App Name in English"},
],
"language_introduction": [ # multilingual descriptions (optional)
{"lan_id": "YOUR_LAN_ID", "introduction": "App description in English"},
],
"remarks": "Remarks for the reviewer (10-200 characters).",
# "notify_url": "https://example.com/your-callback", # optional audit result callback URL
"pond_type": 0, # 0: public store, 1: private store

# --- Gray deployment params (only when deployment_type=2) ---
# "gray_msn_list": ["MSN1", "MSN2"],
# "gray_version": 0, # 0: default gray, 2: percentage-based gray
# "gray_ppm": 10000, # gray ratio, 10000 = 1% (only when gray_version=2)
# "gray_entity_id_list": ["entity1"],
# "gray_start_time": 1700000000, # unix timestamp
# "gray_time_zone": "Asia/Shanghai",
# "deploy_location_id_list": ["CN"],
})

print(json.dumps(response, indent=4, ensure_ascii=False))
26 changes: 26 additions & 0 deletions appstore/07_get_app_detail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Get App Detail

Query the basic detail configuration of an app by its package name.

API: POST /v2/appstore/appstore/app/getAppDetail
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmrzeghjk557
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmrzeghjk557
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

response = client.post("/v2/appstore/appstore/app/getAppDetail", {
"package_name": "com.example.yourapp",
"pond_type": 0, # 0: public store, 1: private store
})

print(json.dumps(response, indent=4, ensure_ascii=False))
45 changes: 45 additions & 0 deletions appstore/08_update_app_detail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
Update App Detail

Update basic information of an existing app such as introduction, screenshots,
compatible terminals, and distribution regions. Changes require a new review.

API: POST /v2/appstore/appstore/app/updateAppDetail
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmiqeghjk513
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmiqeghjk513
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

response = client.post("/v2/appstore/appstore/app/updateAppDetail", {
"package_name": "com.example.yourapp",
"language": [
{"lan_id": "YOUR_LAN_ID", "name": "Updated App Name"},
],
"app_introduction": "Updated app description (10-1000 characters).",
"language_introduction": [
{"lan_id": "YOUR_LAN_ID", "introduction": "Updated description in English"},
],
"terminals": ["P2", "V3"],
"pic_vertical_screen_uuid": [
"YOUR_SCREENSHOT_UUID_1",
"YOUR_SCREENSHOT_UUID_2",
"YOUR_SCREENSHOT_UUID_3",
],
# "pic_horizontal_screen_uuid": ["YOUR_HSCREENSHOT_UUID"],
"area": [1, 2, 3],
"range": 0,
"icon_url_uuid": "YOUR_ICON_UUID",
# "notify_url": "https://example.com/your-callback",
"pond_type": 0,
})

print(json.dumps(response, indent=4, ensure_ascii=False))
41 changes: 41 additions & 0 deletions appstore/09_upgrade_app_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
Upgrade App Version

Upgrade the version of an audited app. Supports both full and gray deployment.
Before calling this API, upload the new APK via the Upload APK API first.

API: POST /v2/appstore/appstore/app/upgradeAppVersion
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmiceghjk502
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmiceghjk502
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

response = client.post("/v2/appstore/appstore/app/upgradeAppVersion", {
"package_name": "com.example.yourapp",
"remarks": "Remarks for the reviewer (10-200 characters).",
"update_content": "What's new in this version (3-2500 characters).",
"update_flag": 1, # 1: full release, 2: gray release
"apk_uuid": "YOUR_APK_UUID", # UUID from Upload APK API
# "notify_url": "https://example.com/your-callback",
"pond_type": 0, # 0: public store, 1: private store

# --- Gray deployment params (only when update_flag=2) ---
# "gray_msn_list": ["MSN1", "MSN2"],
# "gray_version": 0,
# "gray_ppm": 10000,
# "gray_entity_id_list": ["entity1"],
# "gray_start_time": 1700000000,
# "gray_time_zone": "Asia/Shanghai",
# "deploy_location_id_list": ["CN"],
})

print(json.dumps(response, indent=4, ensure_ascii=False))
29 changes: 29 additions & 0 deletions appstore/10_get_audit_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Get Audit Result

Batch query the audit status and results for app creation, version upgrade,
or detail modification. Supports up to 100 package names per request.

API: POST /v2/appstore/appstore/app/getAuditResult
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmrmeghjk546
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmrmeghjk546
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

response = client.post("/v2/appstore/appstore/app/getAuditResult", {
"package_name_list": [
"com.example.yourapp",
],
"pond_type": 0, # 0: public store, 1: private store
})

print(json.dumps(response, indent=4, ensure_ascii=False))
30 changes: 30 additions & 0 deletions appstore/11_get_app_newest_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Get App Newest Version Information

Query the latest formal and gray version data of an app. Supports fetching
historical version information with pagination.

API: POST /v2/appstore/appstore/app/getAppNewestVersionInfo
Doc (zh-CN): https://developer.sunmi.com/docs/zh-CN/cdixeghjk491/xmrreghjk568
Doc (en-US): https://developer.sunmi.com/docs/en-US/cdixeghjk491/xmrreghjk568
"""

import json
import os

from client import SunmiAppStoreClient

client = SunmiAppStoreClient(
app_id=os.environ["SUNMI_APP_ID"],
app_key=os.environ["SUNMI_APP_KEY"],
)

response = client.post("/v2/appstore/appstore/app/getAppNewestVersionInfo", {
"package_name": "com.example.yourapp",
"pond_type": 0, # 0: public store, 1: private store
"get_extend_version_info": True, # whether to include historical version info
"page_num": 1,
"page_size": 10,
})

print(json.dumps(response, indent=4, ensure_ascii=False))
Loading