Skip to content

1.1 Open Interfaces ​

Unless otherwise noted, the following APIs support Promise-style calls: resolve when result is 'SUCCESS', otherwise reject.

Exceptions: mos.isMosEnv is a synchronous read-only property; mos.registerHandler registers a callback. Neither follows the Promise convention above.

1.1.1 Check MOS Environment ​

SDK version: 1.1.10

API: mos.isMosEnv

Synchronous read-only property that returns a boolean. No await needed.

Description ​

Synchronously checks whether the current page is in the MOS bridge environment (App / PC shell / Web), used to decide if native capabilities can be called.

Supported Web host domains:

DomainDescription
https://mp.mos.me/Mini-App Web host
https://chat.mos.me/Chat Web host
  • true: Current page is inside MOS App / PC shell / Web (mp.mos.me / chat.mos.me); native APIs are available
  • false: Regular browser

Note

mos.isMosEnv only answers whether you are in a MOS environment — it does not distinguish client vs Web. To tell them apart, use mos.getAppBaseInfo's platform: 'WEB' means Web; other values ('IOS' / 'ANDROID' / 'WINDOWS' / 'MAC' / 'LINUX') mean client.

js
if (!mos.isMosEnv) {
  // Regular browser
  console.log('Not in MOS environment')
} else {
  // Inside MOS environment, native APIs are available
  const info = await mos.getAppBaseInfo()
  if (info.platform === 'WEB') {
    // Web (mp.mos.me / chat.mos.me)
  } else {
    // Client (App / PC shell)
  }
}

1.1.2 Login ​

SDK version: 1.1.0

API: mos.login(appKey)

Supports Promise-style invocation.

Parameters ​

PropertyTypeRequiredDescription
appKeystringtrueMini-App appKey

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
codestringlogin credential

1.1.3 Share Text ​

SDK version: 1.1.0

API: mos.shareToApp(content)

Supports Promise-style invocation. Share text through mos.

Parameters ​

PropertyTypeRequiredDescription
contentstringtrueText content to be shared out

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure

1.1.4 Get User Information ​

SDK version: 1.1.0

API: mos.getUserInfo(Object object)

Supports Promise-style invocation. Silently granting authorization will not cause an authorization window to pop up.

Parameters ​

[Object object] ​

PropertyTypeRequiredDescriptionLeast version
authorizedDescstringtruePurpose of Obtaining Authorization Information
closeOnClickOverlaystringfalseWhether to close the pop-up window after clicking the mask layer, 0: do not close, 1: close1.1.2

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure | CANCEL': user cancel
authorizednumber0: Not Authorized | 1: Authorized | 2: No Corresponding Information
firstNamestringSurname
lastNamestringGiven Name
headPortraitstringAvatar URL
descriptorstringProfile Bio

1.1.5 Get User Mobile/Email Information ​

SDK version: 1.1.0

API: mos.getUserContactInfo(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeRequiredDescriptionLeast version
authorizedDescstringtruePurpose of Obtaining Authorization Information
closeOnClickOverlaystringfalseWhether to close the pop-up window after clicking the mask layer, 0: do not close, 1: close1.1.2

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure | CANCEL': user cancel
authorizednumber0: Not Authorized | 1: Authorized | 2: No Corresponding Information
dialCodestringArea code
phonestringMobile Number
emailstringEmail address

1.1.6 Get User Unique Signature ​

SDK version: 1.1.0

API: mos.getSign()

Supports Promise-style invocation. urpose of Obtaining User Signature to verify whether MOS has switched user accounts.

Parameters ​

None

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
signstringSignature

1.1.7 Get Current Language ​

SDK version: 1.1.0

API: mos.getLanguage()

Supports Promise-style invocation.

Parameters ​

None

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
langstringLanguage, e.g. en-US

TIP

lang Field Description:

  • MosApp supports the following language types:
    • zh-CN - 简体中文
    • en-US - English
    • km-KH - ភាសាខ្មែរ
    • ja-JP - 日本語
    • vi-VN - Tiếng Việt
    • zh-HK - 繁體中文(香港)
    • zh-TW - 繁體中文(臺灣)
    • th-TH - ภาษาไทย
    • ms-MY - Bahasa Melayu
    • ko-KR - 한국어
    • id-ID - Bahasa Indonesia
    • lo-LA - ລາວ
    • hi-IN - हिन्दी

1.1.8 Invoke Payment ​

SDK version: 1.1.0

API: mos.pay(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeRequiredDescription
amountstringtrueAmount
currencystringtrueCurrency USD: US Dollar
appKeystringtrueMini-App appKey
prepayIdstringtrueOrder Prepayment ID

Response ​

PropertyTypeDescription
resultstringSUCCESS: Payment succeeded | PAYING: Payment in progress | CANCEL: User canceled
datastringThe data field (containing server response) is only provided when payment result is SUCCESS.

Note

SUCCESS (succeeded) and PAYING (in progress) are not final payment results. Actively query the order status via the backend open API /open-apis/mp/v1/pay/orderQuery to confirm the final result.

1.1.9 Get Window Information ​

SDK version: 1.1.0

API: mos.getWindowInfo()

Supports Promise-style invocation.

Parameters ​

None

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
statusBarHeightnumberStatus Bar Height

1.1.10 Get Device Information ​

SDK version: 1.1.0

API: mos.getAppBaseInfo()

Supports Promise-style invocation.

Parameters ​

None

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
platformstringAPP Platform, 'IOS' | 'ANDROID' | 'WINDOWS' | 'MAC' | 'LINUX' | 'WEB'
SDKVersionstringsupported mos-js version, e.g: 1.1.0
languagestringAPP language, e.g: 'en-US'
versionstringAPP version, e.g: '1.1.0'
deviceIdstringdevice id
brandstringdevice brand
systemstringsystem version

1.1.11 Share Mini-App Page ​

SDK version: 1.1.0

API: mos.shareMiniApp(Object object)

Supports Promise-style invocation.

Compatibility only

This API is kept for backward compatibility only. Migrate to mos.registerHandler (action: 'moreButton') as soon as possible so share parameters are set when the user taps More, with optional success / fail / complete callbacks.

Sets share parameters for the top-right More button. The call also syncs into the current page's moreButton registration: even without a separate registerHandler call, the App can pull the same parameters when the user taps More (equivalent to registering data only, with no result callbacks). Existing pages that only call this API can keep working temporarily, but new pages should use registerHandler directly.

If used together with registerHandler, the data from the later call wins. See 1.1.12.

Parameters ​

[Object object] ​

See Appendix: Share Parameters.

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
shareLinkstringcurrent page link, e.g. https://mp.mos.me/mp/<miniapp_id>?query=xxxxx

1.1.12 Register More Button Callback ​

SDK version: 1.1.10

API: mos.registerHandler(Object object)

Registers More-button share config for the App to pull (recommended — prefer this API): when the user taps More, the App reads the current page's data as share parameters; after handling, it may invoke success / fail / complete.

Registration is scoped per page; page switches are managed by the SDK. If custom share content is not needed, you do not have to register — the App falls back to default sharing. mos.shareMiniApp is compatibility-only: calling it alone also registers this page's moreButton (same as providing data only, with no result callbacks). Migrate to this API as soon as possible.

When used together with shareMiniApp:

OrderBehavior
registerHandler first, then shareMiniAppUpdates share data only; keeps existing success / fail / complete, etc.
shareMiniApp first, then registerHandlerFully replaces this page's moreButton (this API wins)
Conflicting dataThe later write wins

Parameters ​

[Object object] ​

PropertyTypeRequiredDescription
actionstringtrueFixed value: moreButton
dataobjectfalseShare content for this tap; see Appendix: Share Parameters
successfunctionfalseSuccess callback; res.data is the share link for this tap
failfunctionfalseFailure callback
completefunctionfalseComplete callback (called on both success and failure)
callbackIdstring | nullfalsePass null explicitly when success / fail / complete are not needed
js
mos.registerHandler({
  action: 'moreButton',
  data: {
    query: { path: '/profile' },
    shareDisabled: '0',
    desc: 'Page description',
    imageUrl: '',
    screenShotDisabled: '0',
  },
  success(res) {
    // res.data is the share link for this tap
    console.log('success', res.data)
  },
  fail(error) {
    console.log('fail', error)
  },
  complete(res) {
    console.log('complete', res)
  },
})

1.1.13 Share Mini-App Page Data, Notify Mobile to Open Forwarding Page ​

SDK version: 1.1.0

API: mos.shareMiniAppData(Object object)

Supports Promise-style invocation.

Opens the forward-to-chat UI. Affects only this proactive share, and does not change the share content of the top-right More button.

Parameters ​

[Object object] ​

See Appendix: Share Parameters.

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
shareLinkstringcurrent page link, e.g. https://mp.mos.me/mp/<miniapp_id>?query=xxxxx

Appendix: Share Parameters ​

Shared object (not an API)

This section is not a standalone API. It defines the share parameter object reused by the share-related APIs above. When an API says “see Share Parameters”, it links here.

This object is used by:

Fields ​

PropertyTypeRequiredDescription
querystring | objectNoLaunch parameters. See query field description below
shareDisabledstringNoDisable sharing: 1 disabled | 0 enabled
descstringNoPage description, usually the current page title
imageUrlstringNoImage URL shown on the Mini-App message card; HTTPS recommended
screenShotDisabledstringNoDisable screenshot for the Mini-App message card image: 1 disable | 0 auto screenshot

query Field Description ​

TIP

Query Field Description:

  • If query is an object type and has an ogLang property, the page will prioritize using this property value as the language when parsing og tags. The values for ogLang are:
    • zh-CN - 简体中文
    • en-US - English
    • km-KH - ភាសាខ្មែរ
    • ja-JP - 日本語
    • vi-VN - Tiếng Việt
    • zh-HK - 繁體中文(香港)
    • zh-TW - 繁體中文(臺灣)
    • th-TH - ภาษาไทย
    • ms-MY - Bahasa Melayu
    • ko-KR - 한국어
    • id-ID - Bahasa Indonesia
    • lo-LA - ລາວ
    • hi-IN - हिन्दी
  • If you want to make your sharing link more attractive, you can tell applications that support OG tags (such as Telegram, Facebook, Twitter, etc.) to customize OG tags to determine the title, description, image, and redirect address of the link, so that users can more easily understand the content of the micro application when sharing.
    Query supports setting four main attributes to customize shared content:
  • ogTitle : Custom title displayed at the top of the sharing card, corresponding to the og: title tag
  • ogDesc : Share description, displayed in the middle of the share card, corresponding to the og: description tag
  • ogImg : Share images, preview images displayed on the card, corresponding to the og: image tag
  • ogURL : Share the redirect address, the link that the user clicks on after sharing the card, corresponding to the og: URL tag

Image display rules:

  • If imageUrl is provided, it takes precedence.
  • If imageUrl is empty:
    • screenShotDisabled=1 Show default image (no screenshot)
    • screenShotDisabled=0 Use system auto-screenshot

1.1.14 Get Launch Parameters ​

SDK version: 1.1.0

API: mos.getLaunchOptions()

Supports Promise-style invocation. Retrieve the Mini-App's launch query parameters, e.g., https://mp.mos.me/mp/<miniapp_id>?query=<query>.

Parameters ​

None

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
querystring | objectLaunch parameters

1.1.15 Add Tracking Event ​

SDK version: 1.1.1

API: mos.addTrackingEvent(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeRequiredDescription
namestringtrueEvent name
datastringfalseJSON string data

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure

1.1.16 Open Native Customer Service Chat Interface ​

SDK version: 1.1.3

API: mos.folderLinkClick(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeRequiredDescription
linkstringtrueCustomer service link, e.g.: https://mos.me/xxxxyyyyzzz
queryobjectfalseSupports parameters such as customer source and context. See query parameter description below

query Parameter Description ​

PropertyTypeRequiredDescription
sourcestringfalseCustomer source identifier, used for data analysis and channel tracking
isMsgCardnumberfalseContext enable flag. Required when using context, fixed value is 1
titlestringfalseMessage title. Required when using context
descstringfalseDetailed description, supplementing the topic
coverstringfalseCover image URL, HTTPS recommended
linkUrlstringfalseDetail page URL, opened when clicked
pricestringfalseProduct current price
linePricestringfalseProduct original/strikethrough price, used for price comparison

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure

SDK version: 1.1.4

API: mos.getShortLink(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeRequiredDescription
linkstringtrueLong link
showLoadingstringfalseWhether to show loading, 1: show | 0: hide, default 1

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
messagestringError message
datastringShort link

1.1.18 Open MiniApp ​

SDK version: 1.1.6

API: mos.openMiniApp(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeRequiredDefault ValueDescription
miniAppIdStringtrueMiniApp ID
namestringfalseMiniApp Name
headPortraitstringfalseMiniApp HeadPortrait
querystring | objectfalseLaunch Parameters

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure

SDK version: 1.1.7

API: mos.openInternalLink(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeRequiredDescription
linkstringtrueInternal link, e.g.: https://mos.me/xxxxyyyyzzz

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
messagestringError message

SDK version: 1.1.12

API: mos.openLink(Object object)

Supports Promise-style invocation. Opens the link in the system default browser instead of inside the app.

Parameters ​

[Object object] ​

PropertyTypeRequiredDescription
linkstringtruehttp / https link, e.g.: https://www.example.com

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
messagestringError message

1.2 Device ​

1.2.1 scanCode ​

SDK version: 1.1.0

API: mos.scanCode()

Supports Promise-style invocation.

Parameters ​

None

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure | CANCEL': user cancel
codestringqrCode value

1.2.2 Make Phone Call ​

SDK version: 1.1.0

API: mos.makePhoneCall(phoneNumber)

Supports Promise-style invocation.

Parameters ​

PropertyTypeRequiredDescription
phoneNumberstringtruePhone number

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure

1.2.3 Set Status bar ​

SDK version: 1.1.0

API: mos.setStatusbar(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeRequiredDescription
showstring11: show | 0: hide
stylestringdarkStatus bar font style dark: dark | light: light

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure

1.2.4 Disable Vertical Swipes ​

SDK version: 1.1.11

API: mos.disableVerticalSwipes()

Supports Promise-style invocation.

Disables the pull-down dismiss gesture for a half-screen Mini-App. Takes effect only in half-screen mode.

Note

In games, canvas drag, or custom pull-down panels, page content often does not scroll (scrollY stays at 0), so a downward swipe is easily treated by the client as collapsing the half-screen. Call this API to disable the gesture in such cases.

Parameters ​

None

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure

1.2.5 Enable Vertical Swipes ​

SDK version: 1.1.11

API: mos.enableVerticalSwipes()

Supports Promise-style invocation.

Enables the pull-down dismiss gesture for a half-screen Mini-App (enabled by default; opposite of mos.disableVerticalSwipes). Takes effect only in half-screen mode.

When enabled, the client negotiates the gesture natively: it checks the H5 scroll position first, then decides who owns the gesture (not handled by frontend JS).

ScenarioGesture ownerBehavior
Page not at top (scrollY > 0), user swipes downH5 pageOnly the page or inner scroll container scrolls; half-screen does not collapse
Already at top (scrollY = 0), user keeps swiping downHalf-screen containerTriggers half-screen collapse

Parameters ​

None

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure

1.3 Location ​

1.3.1 Get Location ​

SDK version: 1.1.3

API: mos.getLocation(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeDefaultRequiredDescription
isHighAccuracystring0falseEnable high-accuracy positioning, 1: enable | 0: disable
highAccuracyExpireTimestring30000falseHigh-accuracy positioning timeout (ms). Returns highest accuracy within specified time. Values above 3000ms are required for high-accuracy positioning to take effect

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
latitudestringLatitude, range -90~90, negative for south
longitudestringLongitude, range -180~180, negative for west
addressstringAddress information
speedstringSpeed in m/s
accuracystringPosition accuracy indicating proximity to real location (e.g., 10 means 10m difference from real location, smaller is more accurate)
altitudestringAltitude in meters
verticalAccuracystringVertical accuracy in meters
horizontalAccuracystringHorizontal accuracy in meters (Android cannot get this, returns 0)

TIP

When high-accuracy positioning is enabled, setting highAccuracyExpireTime too low may cause location acquisition to fail.

1.4 Files ​

1.4.1 Download Network File ​

SDK version: 1.1.3

API: mos.downNetFile(Object object)

Supports Promise-style invocation. If the file is an image or video, it will be saved to the photo album.

Parameters ​

[Object object] ​

PropertyTypeDefaultRequiredDescription
fileUrlstringtrueFile online URL, starting with https or http
fileNamestringfalseFile name without extension. If empty, automatically gets the name from the file URL
fileExtstringfalseFile type (e.g., txt, png). If empty, automatically determines from file URL
showLoadingstring1falseWhether to show loading, 1: show | 0: hide
showMsgstring1falseWhether to show success/failure message, 1: show | 0: hide

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
messagestringError message
datastringSaved file path

1.4.2 Download Local File ​

SDK version: 1.1.3

API: mos.downLocalFile(Object object)

Supports Promise-style invocation. If the file is an image or video, it will be saved to the photo album.

Parameters ​

[Object object] ​

PropertyTypeDefaultRequiredDescription
filefiletrueFile object
fileNamestringfalseFile name without extension. If empty, automatically gets the name from the file object
fileExtstringfalseFile type (e.g., txt, png). If empty, automatically determines from file object
showLoadingstring1falseWhether to show loading, 1: show | 0: hide
showMsgstring1falseWhether to show success/failure message, 1: show | 0: hide

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
messagestringError message
datastringSaved file path

1.5 Data Cache ​

1.5.1 Set Local Cache ​

SDK version: 1.1.8

API: mos.setStorage(Object object)

Supports Promise-style invocation. Stores data in local cache specified by key. Overwrites the original content of the key. Unless the user manually deletes the data, the data will remain available. The maximum data size per key is 100KB, and the total data size limit is 1MB.

Parameters ​

[Object object] ​

PropertyTypeDefaultRequiredDescription
appDataKeystringtrueStorage key, 1-500 characters
appDataValueanyfalseStorage data, maximum size is 100KB, data is encrypted and stored, encrypted data is 1.4 times larger than the original data, and the original data should not exceed 70KB, supports string, number, boolean, object, array

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
messagestringError message

1.5.2 Get Local Cache ​

SDK version: 1.1.8

API: mos.getStorage(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeDefaultRequiredDescription
appDataKeystringtrueStorage key, 1-500 characters

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
messagestringError message
datastringStored data

1.5.3 Remove Local Cache ​

SDK version: 1.1.8

API: mos.removeStorage(Object object)

Supports Promise-style invocation.

Parameters ​

[Object object] ​

PropertyTypeDefaultRequiredDescription
appDataKeystringtrueStorage key, 1-500 characters

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
messagestringError message

1.5.4 Clear Local Cache ​

SDK version: 1.1.8

API: mos.clearStorage()

Supports Promise-style invocation.

Parameters ​

None

Response ​

PropertyTypeDescription
resultstring'SUCCESS': Success | 'FAILURE': Failure
messagestringError message