Friendly Public Transport Format (FPTF)

Most types used in pyHaFAS are specified in the Friendly Public Transport Format. With this specification, we build python classes in the module pyhafas.types.fptf. You can find the reference for those classes below.

class pyhafas.types.fptf.FPTFObject[source]

Bases: object

class pyhafas.types.fptf.Journey(id, date=None, duration=None, legs=None)[source]

Bases: pyhafas.types.fptf.FPTFObject

FPTF Journey object

A journey is a computed set of directions to get from A to B at a specific time. It would typically be the result of a route planning algorithm.

Variables
  • id (str) – ID of the Journey

  • date (Optional[datetime.date]) – Starting date of the journey (maybe None)

  • duration (Optional[datetime.timedelta]) – Duration of the complete journey (maybe None)

  • legs (Optional[List[Leg]]) – Longitude coordinate of the Station (maybe None)

class pyhafas.types.fptf.Leg(id, origin, destination, departure, arrival, mode=<Mode.TRAIN>, name=None, cancelled=False, distance=None, departure_delay=None, departure_platform=None, arrival_delay=None, arrival_platform=None, stopovers=None, remarks=None)[source]

Bases: pyhafas.types.fptf.FPTFObject

FPTF Leg object

A leg or also named trip is most times part of a journey and defines a journey with only one specific vehicle from A to B.

Variables
  • id (str) – ID of the Leg

  • origin (Station) – FPTF Station object of the origin station

  • destination (Station) – FPTF Station object of the destination station

  • departure (datetime.datetime) – Planned Date and Time of the departure

  • arrival (datetime.datetime) – Planned Date and Time of the arrival

  • mode (Mode) – Type of transport vehicle - Must be a part of the FPTF Mode enum. Defaults to Mode.TRAIN

  • name (Optional[str]) – Name of the trip (e.g. ICE 123) (maybe None)

  • cancelled (bool) – Whether the trip is completely cancelled (not only some stops)

  • distance (Optional[int]) – Distance of the walk trip in metres. Only set if mode is Mode.WALKING otherwise None

  • departureDelay (Optional[datetime.timedelta]) – Delay at the departure station (maybe None)

  • departurePlatform (Optional[str]) – Real-time platform at the departure station (maybe None)

  • arrivalDelay (Optional[datetime.timedelta]) – Delay at the arrival station (maybe None)

  • arrivalPlatform (Optional[str]) – Real-time platform at the arrival station (maybe None)

  • stopovers (Optional[List[Stopover]]) – List of FPTF Stopover objects (maybe None)

  • remarks (List[Remark]) – (optional) List of remarks

class pyhafas.types.fptf.Mode(value)[source]

Bases: enum.Enum

FPTF Mode object

The mode of a Leg specifies the general type of transport vehicle (it can also be a walking leg)

AIRCRAFT = 'aircraft'
BICYCLE = 'bicycle'
BUS = 'bus'
CAR = 'car'
GONDOLA = 'gondola'
TAXI = 'taxi'
TRAIN = 'train'
WALKING = 'walking'
WATERCRAFT = 'watercraft'
class pyhafas.types.fptf.Remark(remark_type=None, code=None, subject=None, text=None, priority=None, trip_id=None)[source]

Bases: pyhafas.types.fptf.FPTFObject

A remark is a textual comment/information, usually added to a Stopover or Leg

Variables
  • remark_type (Optional[str]) – Type/Category of the remark. May have a different meaning depending on the network

  • code (Optional[str]) – Code of the remark. May have a different meaning depending on the network

  • subject (Optional[str]) – Subject of the remark

  • text (Optional[str]) – Actual content of the remark

  • priority (Optional[int]) – Priority of the remark, higher is better

  • trip_id (Optional[str]) – ID to a Trip added to this remark (e.g. a replacement train)

class pyhafas.types.fptf.Station(id, lid=None, name=None, latitude=None, longitude=None)[source]

Bases: pyhafas.types.fptf.FPTFObject

FPTF Station object

A station is a point where vehicles stop. It may be a larger building or just a small stop without special infrastructure.

Variables
  • id (str) – ID of the Station. Typically a number but as a string

  • lid (Optional[str]) – Location ID of the Station (maybe None). Long-form, containing multiple fields

  • name (Optional[str]) – Name of the Station (maybe None)

  • latitude (Optional[float]) – Latitude coordinate of the Station (maybe None)

  • longitude (Optional[float]) – Longitude coordinate of the Station (maybe None)

class pyhafas.types.fptf.StationBoardLeg(id, name, direction, station, date_time, cancelled, delay=None, platform=None)[source]

Bases: pyhafas.types.fptf.FPTFObject

StationBoardLeg object

Returned at Station Board-Requests. This requests do not have enough information for a FPTF Leg object. With the ID a trip request can be made to get detailed information about the trip

Variables
  • id (str) – ID of the Leg

  • name (str) – Name of the trip (e.g. ICE 123)

  • direction (str) – Direction text of the trip (e.g. Berlin Central Station)

  • station (Station) – FPTF Station object of the departing/arriving station

  • date_time (datetime.datetime) – Planned Date and Time of the departure/arrival

  • cancelled (bool) – Whether the stop or trip cancelled

  • delay (Optional[datetime.timedelta]) – Delay at the departure station (maybe None)

  • platform (Optional[str]) – Real-time platform at the station (maybe None)

class pyhafas.types.fptf.Stopover(stop, cancelled=False, arrival=None, arrival_delay=None, arrival_platform=None, departure=None, departure_delay=None, departure_platform=None, remarks=None)[source]

Bases: pyhafas.types.fptf.FPTFObject

FPTF Stopover object

A stopover represents a vehicle stopping at a stop/station at a specific time.

Variables
  • stop (Station) – Station where the vehicle is stopping

  • cancelled (bool) – Whether the stop is cancelled

  • arrival (Optional[datetime.datetime]) – Planned arrival date and time at the station (maybe None)

  • arrivalDelay (Optional[datetime.timedelta]) – Arrival delay at the station (maybe None)

  • arrivalPlatform (Optional[str]) – Real-time arrival platform at the station (maybe None)

  • departure (Optional[datetime.datetime]) – Planned departure date and time at the station (maybe None)

  • departureDelay (Optional[datetime.timedelta]) – Departure delay at the station (maybe None)

  • departurePlatform (Optional[str]) – Real-time departure platform at the station (maybe None)

  • remarks (List[Remark]) – (optional) List of remarks