# 航運 (https://nolantw.github.io/tdx/reference/ship/)

## `Ship`

### `authorities`

```python
def authorities(
    *,
    query: Query[ShipAuthority] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipAuthority]
```

取得航運主管機關。

### `ports`

```python
def ports(
    *,
    query: Query[Port] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[Port]
```

取得港口與座標。

### `operators`

```python
def operators(
    *,
    city: City | str | None = None,
    query: Query[ShipOperator] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipOperator]
```

取得航運業者。

### `vessels`

```python
def vessels(
    *,
    city: City | str | None = None,
    query: Query[Vessel] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[Vessel]
```

取得船舶與載客量。

### `routes`

```python
def routes(
    *,
    city: City | str | None = None,
    route_type: ShipRouteType | None = None,
    query: Query[ShipRoute] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipRoute]
```

取得航線與起訖港口。

### `route_stops`

```python
def route_stops(
    *,
    city: City | str | None = None,
    route_type: ShipRouteType | None = None,
    query: Query[ShipRouteStops] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipRouteStops]
```

取得航線停靠港口的順序。

### `daily_schedules`

```python
def daily_schedules(
    *,
    city: City | str | None = None,
    route_type: ShipRouteType | None = None,
    route_id: str | None = None,
    international: bool = False,
    query: Query[ShipSchedule] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipSchedule]
```

取得當日航班，可使用國際航線資料。

### `recurring_schedules`

```python
def recurring_schedules(
    *,
    city: City | str | None = None,
    route_type: ShipRouteType | None = None,
    route_id: str | None = None,
    international: bool = False,
    query: Query[ShipSchedule] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipSchedule]
```

取得定期航班，可使用國際航線資料。

### `special_schedules`

```python
def special_schedules(
    *,
    city: City | str | None = None,
    route_type: SpecialRouteType | None = None,
    route_id: str | None = None,
    query: Query[ShipSchedule] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipSchedule]
```

依縣市、航線或航線類型取得特殊航班。

### `fares`

```python
def fares(
    *,
    city: City | str | None = None,
    route_type: ShipRouteType | None = None,
    query: Query[ShipRouteFare] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipRouteFare]
```

取得航線票價。

### `live_boards`

```python
def live_boards(
    *,
    city: City | str | None = None,
    query: Query[ShipLiveBoard] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipLiveBoard]
```

取得港口的到離港看板。

### `live_positions`

```python
def live_positions(
    *,
    query: Query[VesselPosition] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[VesselPosition]
```

取得船舶的即時位置。

### `seat_availability`

```python
def seat_availability(
    *,
    query: Query[ShipSeatAvailability] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipSeatAvailability]
```

取得航班的座位狀態。

### `news`

```python
def news(
    *,
    city: City | str | None = None,
    query: Query[ShipNews] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipNews]
```

取得航運最新消息。

### `alerts`

```python
def alerts(
    *,
    city: City | str | None = None,
    query: Query[ShipAlert] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipAlert]
```

取得航運通阻。

### `fares_between`

```python
def fares_between(
    origin_port_id: str,
    destination_port_id: str,
    *,
    query: Query[ShipRouteFare] | QueryParams | None = None,
    limit: int | None = None,
    offset: int = 0,
    cache_ttl: float | None = None,
) -> Records[ShipRouteFare]
```

取得兩個港口間的票價。

## `ShipRouteType`

```python
type ShipRouteType = Literal['Internal', 'OutlyingIslands', 'Bilateral', 'MiniThreeLinks', 'Other']
```

## `SpecialRouteType`

```python
type SpecialRouteType = Literal['Internal', 'Other']
```

## `ShipAuthority`

```python
class ShipAuthority(BaseModel):
    code: str
    name: Name | None
    id: str | None
    phone: str | None
    website: str | None
    oid: str | None
    email: str | None
    address: str | None
    logo_url: str | None
    updated_at: MaybeTimestamp
```

## `ShipOperator`

```python
class ShipOperator(BaseModel):
    id: str
    name: Name | None
    phone: str | None
    email: str | None
    address: str | None
    website: str | None
    fare_url: str | None
    reservation_url: str | None
    reservation_phone: str | None
    logo_url: str | None
    business_adminstration_no: str | None
```

## `ShipPort`

```python
class ShipPort(BaseModel):
    id: str
    name: Name | None
```

## `Port`

```python
class Port(ShipPort):
    code: str | None
    position: MaybePosition
    address: str | None
    phone: str | None
    city: str | None
    city_code: str | None
    country: str | None
    country_code: str | None
    url: str | None
```

## `ShipVessel`

```python
class ShipVessel(BaseModel):
    id: str
    name: Name | None
```

## `Vessel`

```python
class Vessel(ShipVessel):
    mmsi: str | None
    imo: str | None
    number: str | None
    call_sign: str | None
    nationality: str | None
    operator_id: str | None
    tonnage: float | None
    length: float | None
    width: float | None
    passenger_capacity: int | None
    vessel_class: str | None
    draft: float | None
    note: str | None
```

## `ShipRouteReference`

```python
class ShipRouteReference(BaseModel):
    id: str
    name: Name | None
    authority_code: str | None
    updated_at: MaybeTimestamp
    source_updated_at: MaybeTimestamp
```

## `ShipDatePeriod`

```python
class ShipDatePeriod(BaseModel):
    start: str | None
    end: str | None
```

## `ShipRoute`

```python
class ShipRoute(ShipRouteReference):
    service_status: int | None
    suspension: ShipDatePeriod | None
    description: str | None
    operators: tuple[ShipOperator, ...] | None
    start_port_id: str | None
    start_port_name: str | None
    end_port_id: str | None
    end_port_name: str | None
    fare_description: Name | None
    route_type: int | None
    vessels: tuple[ShipVessel, ...] | None
    map_url: str | None
    distance: float | None
    weather_url: str | None
```

## `ShipStop`

```python
class ShipStop(ShipPort):
    sequence: int | None
```

## `ShipStopTime`

```python
class ShipStopTime(ShipStop):
    arrival_time: str | None
    departure_time: str | None
    travel_time: int | None
```

## `ShipRouteStops`

```python
class ShipRouteStops(ShipRouteReference):
    direction: int | None
    operators: tuple[ShipOperator, ...] | None
    stops: tuple[ShipStop, ...] | None
```

## `ShipSpecialDates`

```python
class ShipSpecialDates(BaseModel):
    date: str | None
```

## `ShipSpecialDays`

```python
class ShipSpecialDays(BaseModel):
    dates: ShipSpecialDates | None
    date_period: ShipDatePeriod | None
    status: str | None
    description: str | None
```

## `ShipTimetable`

```python
class ShipTimetable(BaseModel):
    trip_id: str
    stops: tuple[ShipStopTime, ...] | None
    service_days: ServiceDays | None
    special_days: ShipSpecialDays | None
```

## `ShipFrequency`

```python
class ShipFrequency(BaseModel):
    start: str | None
    end: str | None
    minimum_headway: int | None
    maximum_headway: int | None
    peak_flag: str | None
    service_days: ServiceDays | None
    special_days: ShipSpecialDays | None
```

## `ShipSchedule`

```python
class ShipSchedule(ShipRouteReference):
    date: str | None
    effective_date: MaybeDate
    expiry_date: MaybeDate
    direction: int | None
    operator_id: str | None
    timetables: tuple[ShipTimetable, ...] | None
    frequencies: tuple[ShipFrequency, ...] | None
    update_interval: int | None
```

## `ShipFare`

```python
class ShipFare(BaseModel):
    name: str | None
    ticket_type: int | None
    fare_class: int | None
    cabin_class: str | None
    price: int | None
```

## `PortPairFare`

```python
class PortPairFare(BaseModel):
    direction: int | None
    origin: ShipPort | None
    destination: ShipPort | None
    fares: tuple[ShipFare, ...] | None
```

## `ShipRouteFare`

```python
class ShipRouteFare(ShipRouteReference):
    operator_id: str | None
    fare_id: str | None
    port_pairs: tuple[PortPairFare, ...] | None
```

## `ShipNotice`

```python
class ShipNotice(BaseModel):
    title: str | None
    description: str | None
    department: str | None
    starts_at: MaybeTimestamp
    ends_at: MaybeTimestamp
    published_at: MaybeTimestamp
    updated_at: MaybeTimestamp
```

## `ShipNews`

```python
class ShipNews(ShipNotice):
    id: str
    language: str | None
    category: int | None
    operator_id: str | None
    contact_name: str | None
    telephone: str | None
    url: str | None
    attachment_url: str | None
```

## `ShipAlertScope`

```python
class ShipAlertScope(BaseModel):
    operators: tuple[ShipOperator, ...] | None
    ports: tuple[ShipPort, ...] | None
    routes: tuple[ShipRouteReference, ...] | None
```

## `ShipAlert`

```python
class ShipAlert(ShipNotice):
    id: str
    status: int | None
    level: int | None
    cause: str | None
    effect: int | None
    scope: ShipAlertScope | None
    url: str | None
```

## `VesselPosition`

```python
class VesselPosition(ShipVessel):
    mmsi: str | None
    position: MaybePosition
    navigation_status: int | None
    speed: float | None
    course: float | None
    vessel_type: int | None
    observed_at: MaybeTimestamp
```

## `ShipBoardEntry`

```python
class ShipBoardEntry(BaseModel):
    route_id: str | None
    vessel_id: str | None
    vessel_name: Name | None
    cancellation_reason: str | None
    change_notice: str | None
```

## `ShipDeparture`

```python
class ShipDeparture(ShipBoardEntry):
    port_id: str | None
    port_name: Name | None
    scheduled_at: MaybeTimestamp
    actual_at: MaybeTimestamp
    estimated_at: MaybeTimestamp
    remark: str | None
    remark_en: str | None
```

## `ShipArrival`

```python
class ShipArrival(ShipBoardEntry):
    port_id: str | None
    port_name: Name | None
    scheduled_at: MaybeTimestamp
    actual_at: MaybeTimestamp
    estimated_at: MaybeTimestamp
    remark: str | None
    remark_en: str | None
```

## `ShipLiveBoard`

```python
class ShipLiveBoard(BaseModel):
    date: str | None
    port_id: str
    port_name: Name | None
    departures: tuple[ShipDeparture, ...] | None
    arrivals: tuple[ShipArrival, ...] | None
    updated_at: MaybeTimestamp
```

## `ShipCabinSeats`

```python
class ShipCabinSeats(BaseModel):
    cabin_class: str | None
    total: int | None
    booked: int | None
    reserved: int | None
    status: int | None
```

## `ShipSailingSeats`

```python
class ShipSailingSeats(ShipVessel):
    arrival_port_id: str | None
    arrival_port_name: Name | None
    departure_time: MaybeTimestamp
    total: int | None
    booked: int | None
    reserved: int | None
    seat_status: int | None
    ship_status: int | None
    cabins: tuple[ShipCabinSeats, ...] | None
    updated_at: MaybeTimestamp
```

## `ShipSeatAvailability`

```python
class ShipSeatAvailability(ShipRouteReference):
    port_id: str | None
    port_name: Name | None
    sailings: tuple[ShipSailingSeats, ...] | None
    remark: str | None
```