> For the complete documentation index, see [llms.txt](https://liuxingran.gitbook.io/hdu-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liuxingran.gitbook.io/hdu-api/apis/card.md).

# 一卡通 API

此章节是关于一卡通 API 的描述。

## `Card` objects

[`Card`](/hdu-api/apis/card.md#card-objects) 对象提供了一系列一卡通信息 API。

**Constructor**:

*class* hdu\_api.**Card**(*session*)

|    参数   |          type         | required | default |            备注            |
| :-----: | :-------------------: | :------: | :-----: | :----------------------: |
| session | objects `CardSession` |   true   |    无    | 一个已初始化的 `CardSession` 对象 |

**Class methods**:

* *classmethod* Card.**account**(*raw=False, dictionary=DEFAULT\_DICTIONARY*)

    一卡通账户信息。
* *classmethod* Card.**balance**(*raw=False, dictionary=DEFAULT\_DICTIONARY*)

    一卡通余额。
* *classmethod* Card.**consume**(*year, month, raw=False, dictionary=DEFAULT\_DICTIONARY*)

    某年某月一卡通流水。
* *classmethod* Card.**consume\_today**(*raw=False, dictionary=DEFAULT\_DICTIONARY*)

    今日一卡通流水。
* *classmethod* Card.**statistics**(*year, month, raw=False, dictionary=DEFAULT\_DICTIONARY*)

    月交易统计。

参数说明：

* raw - 是否输出为原始格式
* dictionary - raw 为 true 时，使用该字典替换返回数据的 key
* year - 年份，如 2019
* month - 月份，如 1, 3, 4, 12

**Class attributes**:

* Card.session

    `CardSession` 对象。
