1e41f4b71Sopenharmony_ci# @system.battery (Battery Information) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **battery** module allows you to query the charging status and remaining power of a device. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.batteryInfo`](js-apis-battery-info.md). 7e41f4b71Sopenharmony_ci> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## Modules to Import 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```js 14e41f4b71Sopenharmony_ciimport {Battery, BatteryResponse } from '@kit.BasicServicesKit'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci## Battery.getStatus 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_cigetStatus(options?: GetStatusOptions): void; 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ciObtains the current charging state and battery level. 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.BatteryManager.Lite 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci**Parameters** 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 29e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 30e41f4b71Sopenharmony_ci| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result. This parameter is optional and is left blank by default.| 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci**Example** 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci```js 35e41f4b71Sopenharmony_ciBattery.getStatus({ 36e41f4b71Sopenharmony_ci success: (data: BatteryResponse) => { 37e41f4b71Sopenharmony_ci console.log('success get battery level:' + data.level); 38e41f4b71Sopenharmony_ci }, 39e41f4b71Sopenharmony_ci fail: (data: string, code: number) => { 40e41f4b71Sopenharmony_ci console.error('fail to get battery level code:' + code + ', data: ' + data); 41e41f4b71Sopenharmony_ci } 42e41f4b71Sopenharmony_ci}); 43e41f4b71Sopenharmony_ci``` 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci## GetStatusOptions 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ciObject that contains the API calling result. 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.BatteryManager.Lite 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 52e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | 53e41f4b71Sopenharmony_ci| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| 54e41f4b71Sopenharmony_ci| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | 55e41f4b71Sopenharmony_ci| complete | () => void | No | Called when an API call is complete. | 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci## BatteryResponse 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ciDefines a response that returns the charging status and remaining power of the device. 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci**System capability**: SystemCapability.PowerManager.BatteryManager.Lite 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci| Name| Type| Readable| Writable| Description| 64e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 65e41f4b71Sopenharmony_ci| charging | boolean | Yes| No| Whether the battery is being charged.| 66e41f4b71Sopenharmony_ci| level | number | Yes| No| Current battery level, which ranges from **0.00** to **1.00**.| 67