@iamliubo, Thanks for reply!
By using this code, I was able to get the API Key:
import deviceCfg
akey=deviceCfg.get_apikey()
BTW, the MAC address can be obtained with the following code:
macaddr=wifiCfg.wlan_sta.config('mac')
macaddr='{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}'.format(*macaddr)
Thank you!