# 資料異動 (https://nolantw.github.io/tdx/reference/changes/)

## `Changes`

### `bus_stops`

```python
def bus_stops(
    city: City | str,
    *,
    start: date | None = None,
    end: date | None = None,
    cache_ttl: float | None = None,
) -> Difference
```

比對縣市的公車站牌。

### `bus_routes`

```python
def bus_routes(
    city: City | str,
    *,
    start: date | None = None,
    end: date | None = None,
    cache_ttl: float | None = None,
) -> Difference
```

比對縣市的公車路線。

### `railway_lines`

```python
def railway_lines(
    *,
    start: date | None = None,
    end: date | None = None,
    cache_ttl: float | None = None,
) -> Difference
```

比對臺鐵路線。

### `railway_stations`

```python
def railway_stations(
    *,
    start: date | None = None,
    end: date | None = None,
    cache_ttl: float | None = None,
) -> Difference
```

比對臺鐵車站。

### `high_speed_stations`

```python
def high_speed_stations(
    *,
    start: date | None = None,
    end: date | None = None,
    cache_ttl: float | None = None,
) -> Difference
```

比對高鐵車站。

### `bus_stop_history`

```python
def bus_stop_history(
    city: City | str,
    stop_id: str,
    start: date,
    end: date,
    *,
    cache_ttl: float | None = None,
) -> Records[Revision]
```

列出公車站牌的異動歷程，適用臺北市與新北市。

### `bus_route_history`

```python
def bus_route_history(
    city: City | str,
    route_id: str,
    start: date,
    end: date,
    *,
    cache_ttl: float | None = None,
) -> Records[Revision]
```

列出公車路線的異動歷程，適用臺北市與新北市。

## `Change`

```python
class Change(BaseModel):
    keys: tuple[str, ...]
    type: Literal['A', 'M', 'D']
    before: JsonValue
    after: JsonValue
```

新增、修改或刪除的一筆資料，保留 TDX 原本的內容。

## `Difference`

```python
class Difference(BaseModel):
    dataset: str
    key_fields: tuple[str, ...]
    previous_version: str | None
    current_version: str | None
    changes: tuple[Change, ...]
```

資料的兩個版本之間的差異。

## `Revision`

```python
class Revision(BaseModel):
    start: date
    end: date
    data_hash: str | None
    record: JsonValue
```

一筆資料在一段期間內的內容，保留 TDX 原本的格式。