All Products
Search
Document Center

Mobile Platform as a Service:Custom API

Last Updated:Mar 10, 2025

If the existing Mini program APIs cannot meet your requirements, you can extend customize APIs by yourself.

Custom APIs

Call API in the Mini program

Use the following method in the Mini program to call a customized API:

my.call(API, param, callback)

In which:

  • API: the name of the custom API.

  • param: the parameters that are used to call the API.

  • callback: the callback function that is executed by the API.

Take calling the rpc method as an example, the code sample is as follows:

    my.call('rpc', {
      operationType: 'com.test.mb1001',
      requestData: [{
        tranCode: 'MB1001',
        customerType: 0,
        customerId: 0,
        UnitType: '7A238BD3-A90B-4458-885E-129230BCF7F1',
        sessionId: 'zzzzzzzzzzzzzzzz',
        serverIP: 'zzzzzzzzzzzzzzzz',
        mobileNo: username,
        password,
        optionFlag: 3,
      }]
    }, (res) => {
        // do your business here.
    })

To understand the similarities and differences between Mini program calls and HTML5 calls, see the Call the RPC API topic of the HTML5 container document.

Unregister custom event

If you no longer need a custom event, see Unregister custom event.