1# @system.battery (Battery Information)
2
3The **battery** module allows you to query the charging status and remaining power of a device.
4
5>  **NOTE**
6>  - 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).
7>  - 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.
8
9
10## Modules to Import
11
12
13```js
14import {Battery, BatteryResponse } from '@kit.BasicServicesKit';
15```
16
17
18## Battery.getStatus
19
20getStatus(options?: GetStatusOptions): void;
21
22Obtains the current charging state and battery level.
23
24**System capability**: SystemCapability.PowerManager.BatteryManager.Lite
25
26**Parameters**
27
28| Name| Type| Mandatory| Description|
29| -------- | -------- | -------- | -------- |
30| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result. This parameter is optional and is left blank by default.|
31
32**Example**
33
34```js
35Battery.getStatus({
36    success: (data: BatteryResponse) => {
37        console.log('success get battery level:' + data.level);
38    },
39    fail: (data: string, code: number) => {
40        console.error('fail to get battery level code:' + code + ', data: ' + data);
41    }
42});
43```
44
45## GetStatusOptions
46
47Object that contains the API calling result.
48
49**System capability**: SystemCapability.PowerManager.BatteryManager.Lite
50
51| Name  | Type                                               | Mandatory| Description                                                        |
52| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
53| success  | (data: [BatteryResponse](#batteryresponse)) => void | No  | Called when an API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.|
54| 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.      |
55| complete | () => void                                          | No  | Called when an API call is complete.                                    |
56
57## BatteryResponse
58
59Defines a response that returns the charging status and remaining power of the device.
60
61**System capability**: SystemCapability.PowerManager.BatteryManager.Lite
62
63| Name| Type| Readable| Writable| Description|
64| -------- | -------- | -------- | -------- | -------- |
65| charging | boolean | Yes| No| Whether the battery is being charged.|
66| level | number | Yes| No| Current battery level, which ranges from **0.00** to **1.00**.|
67