WeChat Open Platform

Mini Programs Documentation


The framework provides plenty of native WeChat APIs that can make it easy to call the capabilities provided by WeChat, such as getting user information, local storage and payment functions.


  • The wx.on start API is an API interface that monitors the occurrence of a certain event. It receives a CALLBACK function as a parameter. When this event is triggered, the CALLBACK function will be called.
  • if there is no specific convention, other API interfaces all receive an OBJECT as a parameter.
  • The OBJECT can specify success, fail, or complete when receiving interface call results.
Parameter name Type Required Description
success Function No Callback function for successful interface call
fail Function No Callback function for failed interface call
complete Function No Callback function for interface call results (will be executed if call succeeds or fails)

API lists:

Network API list:

API Description
wx.request Initiates network requests
wx.uploadFile Uploads files
wx.downloadFile Downloads files
wx.connectSocket Creates a WebSocket connection
wx.onSocketOpen Monitors WebSocket opening
wx.onSocketError Monitors WebSocket errors
wx.sendSocketMessage Sends WebSocket messages
wx.onSocketMessage Receives WebSocket messages
wx.closeSocket Closes WebSocket connection
wx.onSocketClose Monitors WebSocket closing

Media API list:

API Description
wx.chooseImage Select an image from an album or take a photo
wx.previewImage Preview an image
wx.startRecord Start recording
wx.stopRecord Stop recording
wx.playVoice Play voice message
wx.pauseVoice Pause voice message
wx.stopVoice Stop playing voice message
wx.getBackgroundAudioPlayerState Gets music playback status
wx.playBackgroundAudio Play music
wx.pauseBackgroundAudio Pause music
wx.seekBackgroundAudio Control progress of music playback
wx.stopBackgroundAudio Stop playing music
wx.onBackgroundAudioPlay Monitors start of music playback
wx.onBackgroundAudioPause Monitors pausing of music
wx.onBackgroundAudioStop Monitors stopping of music
wx.chooseVideo Select a video from an album or record a video

File API list:

API Description
wx.saveFile Saves files
wx.getSavedFileList Gets list of saved files
wx.getSavedFileInfo Gets saved file information
wx.removeSavedFile Deletes saved file information
wx.openDocument Opens documents

Data API list:

API Description
wx.setStorage Sets local data cache
wx.setStorageSync Sets local data cache
wx.getStorage Gets local data cache
wx.getStorageSync Gets local data cache
wx.getStorageInfo Gets information related to local cache
wx.getStorageInfoSync Gets information related to local cache
wx.removeStorage Deletes local cache content
wx.removeStorageSync Deletes local cache content
wx.clearStorage Clears local data cache
wx.clearStorageSync Clears local data cache

Location API list:

API Description
wx.getLocation Get current location
wx.chooseLocation Open map and select location
wx.openLocation Open built-in map
wx.createMapContext Map component control

Device API list:

API Description
wx.getNetworkType Gets network type
wx.onNetworkStatusChange Monitors changes to network status
wx.getSystemInfo Gets system information
wx.getSystemInfoSync Gets system information
wx.onAccelerometerChange Monitors acceleration data
wx.startAccelerometer Starts monitoring acceleration data
wx.stopAccelerometer Stops monitoring acceleration data
wx.onCompassChange Monitors compass data
wx.startCompass Starts monitoring compass data
wx.stopCompass Stops monitoring compass data
wx.setClipboardData Sets clipboard content
wx.getClipboardData Gets clipboard content
wx.makePhoneCall Makes phone calls
wx.scanCode Scans codes

Interface API list:

API Description
wx.showToast Displays prompt box
wx.showLoading Displays loading prompt box
wx.hideToast Hides prompt box
wx.hideLoading Hides prompt box
wx.showModal Displays modal pop-up window
wx.showActionSheet Displays menu list
wx.setNavigationBarTitle Sets current page title
wx.showNavigationBarLoading Displays navigation bar loading animation
wx.hideNavigationBarLoading Hides navigation bar loading animation
wx.navigateTo Opens page in a new window
wx.redirectTo Opens page in original window
wx.switchTab Switches to tab bar page
wx.navigateBack Return to previous page
wx.createAnimation Animation
wx.createContext Creates drawing context
wx.drawCanvas Draw
wx.hideKeyboard Hides keyboard
wx.stopPullDownRefresh Stops pull down refresh animation

Open interfaces:

API Description
wx.login Login
wx.getUserInfo Gets user information
wx.chooseAddress Gets user shipping address
wx.requestPayment Initiates WeChat Pay
wx.addCard Adds cards
wx.openCard Opens cards