Package tflwrapper

Expand source code
from .accidentStats import accidentStats
from .airQuality import airQuality
from .bikePoint import bikePoint
from .crowding import crowding
from .disruptions import disruptions
from .line import line
from .mode import mode
from .occupancy import occupancy
from .road import road
from .stopPoint import stopPoint
from .tfl import tflAPI
from .trackerNet import trackerNet
from .travelTimes import travelTimes

__all__ = [
    'accidentStats',
    'airQuality',
    'bikePoint',
    'crowding',
    'disruptions',
    'line',
    'mode',
    'occupancy',
    'road',
    'stopPoint',
    'tflAPI',
    'trackerNet',
    'travelTimes'
]

Sub-modules

tflwrapper.tfl

Classes

class accidentStats (app_key)

Accident from Unified API

Expand source code
class accidentStats(tflAPI):
    """Accident from Unified API"""

    def getAllByYear(self, year: int):
        """
        Gets all accident details for accidents occuring in the specified year

        Args:
            year: The year for which to filter the accidents on.
            year: The year for which to filter the accidents on.
        """
        return super(accidentStats, self).sendRequestUnified(
            f"/AccidentStats/{year}", {}
        )

Ancestors

Methods

def getAllByYear(self, year: int)

Gets all accident details for accidents occuring in the specified year

Args

year
The year for which to filter the accidents on.
year
The year for which to filter the accidents on.
Expand source code
def getAllByYear(self, year: int):
    """
    Gets all accident details for accidents occuring in the specified year

    Args:
        year: The year for which to filter the accidents on.
        year: The year for which to filter the accidents on.
    """
    return super(accidentStats, self).sendRequestUnified(
        f"/AccidentStats/{year}", {}
    )

Inherited members

class airQuality (app_key)

Air Quality from the TFL Unified API

Expand source code
class airQuality(tflAPI):
    """Air Quality from the TFL Unified API"""

    def getAirQuality(self):
        """
        Get all current and future air quality forecast
        """
        return super(airQuality, self).sendRequestUnified(
            f"/AirQuality", {}
        )

Ancestors

Methods

def getAirQuality(self)

Get all current and future air quality forecast

Expand source code
def getAirQuality(self):
    """
    Get all current and future air quality forecast
    """
    return super(airQuality, self).sendRequestUnified(
        f"/AirQuality", {}
    )

Inherited members

class bikePoint (app_key)

Bike point from Unified API

Expand source code
class bikePoint(tflAPI):
    """Bike point from Unified API"""

    def getAll(self):
        """Gets all bike point locations"""
        return super(bikePoint, self).sendRequestUnified(
            "/BikePoint", {}
        )

    def getByID(self, ID):
        """
        Gets the bike point by the given id

        Args:
            ID: The ID of the bike point
        """
        return super(bikePoint, self).sendRequestUnified(
            f"/BikePoint/{ID}", {}
        )

    def getByName(self, name):
        """
        Search for bike points by their name

        Args:
            name: The name of the bike point
        """
        return super(bikePoint, self).sendRequestUnified(
            f"/BikePoint/Search", {'query': name}
        )

Ancestors

Methods

def getAll(self)

Gets all bike point locations

Expand source code
def getAll(self):
    """Gets all bike point locations"""
    return super(bikePoint, self).sendRequestUnified(
        "/BikePoint", {}
    )
def getByID(self, ID)

Gets the bike point by the given id

Args

ID
The ID of the bike point
Expand source code
def getByID(self, ID):
    """
    Gets the bike point by the given id

    Args:
        ID: The ID of the bike point
    """
    return super(bikePoint, self).sendRequestUnified(
        f"/BikePoint/{ID}", {}
    )
def getByName(self, name)

Search for bike points by their name

Args

name
The name of the bike point
Expand source code
def getByName(self, name):
    """
    Search for bike points by their name

    Args:
        name: The name of the bike point
    """
    return super(bikePoint, self).sendRequestUnified(
        f"/BikePoint/Search", {'query': name}
    )

Inherited members

class crowding (app_key)

Crowding from Unified API

Expand source code
class crowding(tflAPI):
    """Crowding from Unified API"""

    def getAllByNaptan(self, id):
        """
        Get crowding information for Naptan

        Args:
            id: NaPTAN ID of the stop (eg. 940GZZLUASL)
        """
        return super(crowding, self).sendRequestUnified(
            f"/Crowding/{id}", {}
        )

    def getByNaptanDay(self, id, day):
        """
        Get crowding information for Naptan for a specified day of week

        Args:
            id: NaPTAN ID of the stop (eg. 940GZZLUASL)
            day: The day of which you would like data to return (eg. MON, TUE)
        """
        return super(crowding, self).sendRequestUnified(
            f"/Crowding/{id}/{day}", {}
        )

    def getLiveByNaptan(self, id):
        """
        Get crowding information for Naptan for a specified day of week

        Args:
            id: NaPTAN ID of the stop (eg. 940GZZLUASL)
        """
        return super(crowding, self).sendRequestUnified(
            f"/Crowding/{id}/Live", {}
        )

Ancestors

Methods

def getAllByNaptan(self, id)

Get crowding information for Naptan

Args

id
NaPTAN ID of the stop (eg. 940GZZLUASL)
Expand source code
def getAllByNaptan(self, id):
    """
    Get crowding information for Naptan

    Args:
        id: NaPTAN ID of the stop (eg. 940GZZLUASL)
    """
    return super(crowding, self).sendRequestUnified(
        f"/Crowding/{id}", {}
    )
def getByNaptanDay(self, id, day)

Get crowding information for Naptan for a specified day of week

Args

id
NaPTAN ID of the stop (eg. 940GZZLUASL)
day
The day of which you would like data to return (eg. MON, TUE)
Expand source code
def getByNaptanDay(self, id, day):
    """
    Get crowding information for Naptan for a specified day of week

    Args:
        id: NaPTAN ID of the stop (eg. 940GZZLUASL)
        day: The day of which you would like data to return (eg. MON, TUE)
    """
    return super(crowding, self).sendRequestUnified(
        f"/Crowding/{id}/{day}", {}
    )
def getLiveByNaptan(self, id)

Get crowding information for Naptan for a specified day of week

Args

id
NaPTAN ID of the stop (eg. 940GZZLUASL)
Expand source code
def getLiveByNaptan(self, id):
    """
    Get crowding information for Naptan for a specified day of week

    Args:
        id: NaPTAN ID of the stop (eg. 940GZZLUASL)
    """
    return super(crowding, self).sendRequestUnified(
        f"/Crowding/{id}/Live", {}
    )

Inherited members

class disruptions (app_key)

Disruptions from Unified API

Expand source code
class disruptions(tflAPI):
    """Disruptions from Unified API"""

    def getAllLifts(self):
        """
        List of all currently disrupted lift routes, refreshed every 1 minute
        """
        return super(disruptions, self).sendRequestUnified(
            f"/Disruptions/Lifts", {}
        )

Ancestors

Methods

def getAllLifts(self)

List of all currently disrupted lift routes, refreshed every 1 minute

Expand source code
def getAllLifts(self):
    """
    List of all currently disrupted lift routes, refreshed every 1 minute
    """
    return super(disruptions, self).sendRequestUnified(
        f"/Disruptions/Lifts", {}
    )

Inherited members

class line (app_key)

Line from Unified API

Expand source code
class line(tflAPI):
    """Line from Unified API"""

    def getModes(self):
        """Gets a list of valid modes"""
        return super(line, self).sendRequestUnified(
            "/Line/Meta/Modes", {}
        )

    def getSeverityCodes(self):
        """Gets a list of valid severity codes"""
        return super(line, self).sendRequestUnified(
            "/Line/Meta/Severity", {}
        )

    def getDisruptionCategories(self):
        """Gets a list of valid disruption categories"""
        return super(line, self).sendRequestUnified(
            "/Line/Meta/DisruptionCatergories", {}
        )

    def getServiceTypes(self):
        """Gets a list of valid service types"""
        return super(line, self).sendRequestUnified(
            "/Line/Meta/ServiceTypes", {}
        )

    def getAllStopPoints(self, line):
        """
        Gets a list of the stations that serve the given line id

        Args:
            line: The line id e.g. victoria, circle, N133        
        """
        return super(line, self).sendRequestUnified(
            F"/Line/{line}/StopPoints", {}
        )
    

    def getAllByModes(self, modes):
        """
        Gets lines that serve the given modes
        
        Args:
            modes: A list of modes e.g. tube, tram
        """
        return super(line, self).sendRequestUnified(
            f"/Line/Mode/{self.arrayToCSV(modes)}", {}
        )

    def getStatusByLine(self, lines, detail = False, startDate = None, endDate = None):
        """
        Gets the line status of for given line ids e.g Minor Delays

        Args:
            lines: A list of line ids e.g. ['victoria', 'circle']
            detail: Include details of the disruptions that are causing the line status including the affected stops and routes
        """
        if startDate == None or endDate == None:
            return super(line, self).sendRequestUnified(
                f"/Line/{self.arrayToCSV(lines)}/Status", { detail }
            )
        else:
            return super(line, self).sendRequestUnified(
                f"/Line/{self.arrayToCSV(lines)}/Status/{self.getRFC3339(startDate)}/to/{self.getRFC3339(endDate)}", { detail }
            )

    def getStatusByModes(self, modes, detail = False, severityLevel = ""):
        """
        Gets the line status of for all lines for the given modes

        Args:
            modes: A list of modes e.g. tube, tram
            detail: Include details of the disruptions that are causing the line status including the affected stops and routes
            severityLevel: A list of severity codes to filter on. Supported values: Minor, Major, Severe
        """
        return super(line, self).sendRequestUnified(
            f"/Line/Mode/{self.arrayToCSV(modes)}/Status", { detail, severityLevel }
        )

    def getTimetableFromTo(self, _line, _from, _to):
        """
        Gets the timetable for a specified station on the give line with specified destination
        
        Args:
            _line: The line id e.g. victoria, circle, N133
            _from: The station id e.g. 940GZZLUASL
            _to: The destination station id e.g. 940GZZLUASL
        """
        return super(line, self).sendRequestUnified(
            f"/Line/{_line}/Timetable/{_from}/to/{_to}"
        )

    def getTimetableFromStation(self, _line, NaPTANID, direction):
        """
        Gets the inbound timetable for a specified station on the give line

        Args:
            _line: The line id e.g. victoria, circle, N133
            NaPTANID: The station id e.g. 940GZZLUASL
            direction: The direction of the timetable. Supported values: inbound, outbound. Defaulted to 'outbound' if not specified
        """
        return super(line, self).sendRequestUnified(
            f"/Line/{_line}/Timetable/{NaPTANID}",
            {'direction': direction}
        )

    def getArrivalsByNaptan(self, lineids, naptan, destinationStationId, direction = "all"):
        """
        Gets the arrivals for a given station on the give line

        Args:
            lineids: A list of line ids e.g. ['victoria', 'circle']
            naptan: The station id e.g. 940GZZLUASL
            destinationStationId: The destination station id e.g. 940GZZLUASL
            direction: The direction of the timetable. Supported values: inbound, outbound. Defaulted to 'all' if not specified
        """
        return super(line, self).sendRequestUnified(
            f"/Line/{self.arrayToCSV(lineids)}/Arrivals/{naptan}", {'direction': direction, 'destinationStationId': destinationStationId }
        )

    def getAllValidRoutes(self, serviceTypes):
        """
        Get all valid routes for all lines, including the name and id of the originating and terminating stops for each route.

        Args:
            serviceTypes: A list of service types e.g. 'tube, 'tram'. Supported values: Regular, Night. Defaulted to 'Regular' if not specified
        """
        return super(line, self).sendRequestUnified(
            f"/Line/Route", {
                'serviceTypes': serviceTypes}
        )

    def getStatusByID(self, lineids, detail: bool):
        """
        Gets the line status of for all lines for the given modes

        Args:
            lineids: A list of line ids e.g. ['victoria', 'circle']
            detail: Include details of the disruptions that are causing the line status including the affected stops and routes
        """
        return super(line, self).sendRequestUnified(
            f"/Line/Mode/{self.arrayToCSV(lineids)}/Status", {'detail': detail}
        )

    def getRouteByIDs(self, lineids, serviceTypes):
        """
        Get all valid routes for given line ids, including the name and id of the originating and terminating stops for each route
        Args:
            lineids: A list of line ids e.g. ['victoria', 'circle']
            serviceTypes: A list of service types e.g. 'tube, 'tram'. Supported values: Regular, Night. Defaulted to 'Regular' if not specified
        """
        return super(line, self).sendRequestUnified(
            f"/Line/{self.arrayToCSV(lineids)}/Route", {
                'serviceTypes': serviceTypes}
        )

Ancestors

Methods

def getAllByModes(self, modes)

Gets lines that serve the given modes

Args

modes
A list of modes e.g. tube, tram
Expand source code
def getAllByModes(self, modes):
    """
    Gets lines that serve the given modes
    
    Args:
        modes: A list of modes e.g. tube, tram
    """
    return super(line, self).sendRequestUnified(
        f"/Line/Mode/{self.arrayToCSV(modes)}", {}
    )
def getAllStopPoints(self, line)

Gets a list of the stations that serve the given line id

Args

line
The line id e.g. victoria, circle, N133
Expand source code
def getAllStopPoints(self, line):
    """
    Gets a list of the stations that serve the given line id

    Args:
        line: The line id e.g. victoria, circle, N133        
    """
    return super(line, self).sendRequestUnified(
        F"/Line/{line}/StopPoints", {}
    )
def getAllValidRoutes(self, serviceTypes)

Get all valid routes for all lines, including the name and id of the originating and terminating stops for each route.

Args

serviceTypes
A list of service types e.g. 'tube, 'tram'. Supported values: Regular, Night. Defaulted to 'Regular' if not specified
Expand source code
def getAllValidRoutes(self, serviceTypes):
    """
    Get all valid routes for all lines, including the name and id of the originating and terminating stops for each route.

    Args:
        serviceTypes: A list of service types e.g. 'tube, 'tram'. Supported values: Regular, Night. Defaulted to 'Regular' if not specified
    """
    return super(line, self).sendRequestUnified(
        f"/Line/Route", {
            'serviceTypes': serviceTypes}
    )
def getArrivalsByNaptan(self, lineids, naptan, destinationStationId, direction='all')

Gets the arrivals for a given station on the give line

Args

lineids
A list of line ids e.g. ['victoria', 'circle']
naptan
The station id e.g. 940GZZLUASL
destinationStationId
The destination station id e.g. 940GZZLUASL
direction
The direction of the timetable. Supported values: inbound, outbound. Defaulted to 'all' if not specified
Expand source code
def getArrivalsByNaptan(self, lineids, naptan, destinationStationId, direction = "all"):
    """
    Gets the arrivals for a given station on the give line

    Args:
        lineids: A list of line ids e.g. ['victoria', 'circle']
        naptan: The station id e.g. 940GZZLUASL
        destinationStationId: The destination station id e.g. 940GZZLUASL
        direction: The direction of the timetable. Supported values: inbound, outbound. Defaulted to 'all' if not specified
    """
    return super(line, self).sendRequestUnified(
        f"/Line/{self.arrayToCSV(lineids)}/Arrivals/{naptan}", {'direction': direction, 'destinationStationId': destinationStationId }
    )
def getDisruptionCategories(self)

Gets a list of valid disruption categories

Expand source code
def getDisruptionCategories(self):
    """Gets a list of valid disruption categories"""
    return super(line, self).sendRequestUnified(
        "/Line/Meta/DisruptionCatergories", {}
    )
def getModes(self)

Gets a list of valid modes

Expand source code
def getModes(self):
    """Gets a list of valid modes"""
    return super(line, self).sendRequestUnified(
        "/Line/Meta/Modes", {}
    )
def getRouteByIDs(self, lineids, serviceTypes)

Get all valid routes for given line ids, including the name and id of the originating and terminating stops for each route

Args

lineids
A list of line ids e.g. ['victoria', 'circle']
serviceTypes
A list of service types e.g. 'tube, 'tram'. Supported values: Regular, Night. Defaulted to 'Regular' if not specified
Expand source code
def getRouteByIDs(self, lineids, serviceTypes):
    """
    Get all valid routes for given line ids, including the name and id of the originating and terminating stops for each route
    Args:
        lineids: A list of line ids e.g. ['victoria', 'circle']
        serviceTypes: A list of service types e.g. 'tube, 'tram'. Supported values: Regular, Night. Defaulted to 'Regular' if not specified
    """
    return super(line, self).sendRequestUnified(
        f"/Line/{self.arrayToCSV(lineids)}/Route", {
            'serviceTypes': serviceTypes}
    )
def getServiceTypes(self)

Gets a list of valid service types

Expand source code
def getServiceTypes(self):
    """Gets a list of valid service types"""
    return super(line, self).sendRequestUnified(
        "/Line/Meta/ServiceTypes", {}
    )
def getSeverityCodes(self)

Gets a list of valid severity codes

Expand source code
def getSeverityCodes(self):
    """Gets a list of valid severity codes"""
    return super(line, self).sendRequestUnified(
        "/Line/Meta/Severity", {}
    )
def getStatusByID(self, lineids, detail: bool)

Gets the line status of for all lines for the given modes

Args

lineids
A list of line ids e.g. ['victoria', 'circle']
detail
Include details of the disruptions that are causing the line status including the affected stops and routes
Expand source code
def getStatusByID(self, lineids, detail: bool):
    """
    Gets the line status of for all lines for the given modes

    Args:
        lineids: A list of line ids e.g. ['victoria', 'circle']
        detail: Include details of the disruptions that are causing the line status including the affected stops and routes
    """
    return super(line, self).sendRequestUnified(
        f"/Line/Mode/{self.arrayToCSV(lineids)}/Status", {'detail': detail}
    )
def getStatusByLine(self, lines, detail=False, startDate=None, endDate=None)

Gets the line status of for given line ids e.g Minor Delays

Args

lines
A list of line ids e.g. ['victoria', 'circle']
detail
Include details of the disruptions that are causing the line status including the affected stops and routes
Expand source code
def getStatusByLine(self, lines, detail = False, startDate = None, endDate = None):
    """
    Gets the line status of for given line ids e.g Minor Delays

    Args:
        lines: A list of line ids e.g. ['victoria', 'circle']
        detail: Include details of the disruptions that are causing the line status including the affected stops and routes
    """
    if startDate == None or endDate == None:
        return super(line, self).sendRequestUnified(
            f"/Line/{self.arrayToCSV(lines)}/Status", { detail }
        )
    else:
        return super(line, self).sendRequestUnified(
            f"/Line/{self.arrayToCSV(lines)}/Status/{self.getRFC3339(startDate)}/to/{self.getRFC3339(endDate)}", { detail }
        )
def getStatusByModes(self, modes, detail=False, severityLevel='')

Gets the line status of for all lines for the given modes

Args

modes
A list of modes e.g. tube, tram
detail
Include details of the disruptions that are causing the line status including the affected stops and routes
severityLevel
A list of severity codes to filter on. Supported values: Minor, Major, Severe
Expand source code
def getStatusByModes(self, modes, detail = False, severityLevel = ""):
    """
    Gets the line status of for all lines for the given modes

    Args:
        modes: A list of modes e.g. tube, tram
        detail: Include details of the disruptions that are causing the line status including the affected stops and routes
        severityLevel: A list of severity codes to filter on. Supported values: Minor, Major, Severe
    """
    return super(line, self).sendRequestUnified(
        f"/Line/Mode/{self.arrayToCSV(modes)}/Status", { detail, severityLevel }
    )
def getTimetableFromStation(self, _line, NaPTANID, direction)

Gets the inbound timetable for a specified station on the give line

Args

_line
The line id e.g. victoria, circle, N133
NaPTANID
The station id e.g. 940GZZLUASL
direction
The direction of the timetable. Supported values: inbound, outbound. Defaulted to 'outbound' if not specified
Expand source code
def getTimetableFromStation(self, _line, NaPTANID, direction):
    """
    Gets the inbound timetable for a specified station on the give line

    Args:
        _line: The line id e.g. victoria, circle, N133
        NaPTANID: The station id e.g. 940GZZLUASL
        direction: The direction of the timetable. Supported values: inbound, outbound. Defaulted to 'outbound' if not specified
    """
    return super(line, self).sendRequestUnified(
        f"/Line/{_line}/Timetable/{NaPTANID}",
        {'direction': direction}
    )
def getTimetableFromTo(self, _line, _from, _to)

Gets the timetable for a specified station on the give line with specified destination

Args

_line
The line id e.g. victoria, circle, N133
_from
The station id e.g. 940GZZLUASL
_to
The destination station id e.g. 940GZZLUASL
Expand source code
def getTimetableFromTo(self, _line, _from, _to):
    """
    Gets the timetable for a specified station on the give line with specified destination
    
    Args:
        _line: The line id e.g. victoria, circle, N133
        _from: The station id e.g. 940GZZLUASL
        _to: The destination station id e.g. 940GZZLUASL
    """
    return super(line, self).sendRequestUnified(
        f"/Line/{_line}/Timetable/{_from}/to/{_to}"
    )

Inherited members

class mode (app_key)

Mode API, /mode

Expand source code
class mode(tflAPI):
    """Mode API, /mode"""

    def getActiveServiceTypes(self):
        """Returns the service type active for a mode, currently only supports tube"""

        return super(mode, self).sendRequestUnified(
            "/Mode/ActiveServiceTypes", {}
        )

    def getAllArrivalPredictions(self, modes: str, count: str):
        """
        Returns arrival predictions for all stops

        Args:
            modes: The modes for which to return predictions e.g. tube, dlr
            count: The number of predictions to return, -1 to return all available
        """

        return super(mode, self).sendRequestUnified(
            f"/Mode/{modes}/Arrivals", {'count': count}
        )

Ancestors

Methods

def getActiveServiceTypes(self)

Returns the service type active for a mode, currently only supports tube

Expand source code
def getActiveServiceTypes(self):
    """Returns the service type active for a mode, currently only supports tube"""

    return super(mode, self).sendRequestUnified(
        "/Mode/ActiveServiceTypes", {}
    )
def getAllArrivalPredictions(self, modes: str, count: str)

Returns arrival predictions for all stops

Args

modes
The modes for which to return predictions e.g. tube, dlr
count
The number of predictions to return, -1 to return all available
Expand source code
def getAllArrivalPredictions(self, modes: str, count: str):
    """
    Returns arrival predictions for all stops

    Args:
        modes: The modes for which to return predictions e.g. tube, dlr
        count: The number of predictions to return, -1 to return all available
    """

    return super(mode, self).sendRequestUnified(
        f"/Mode/{modes}/Arrivals", {'count': count}
    )

Inherited members

class occupancy (app_key)

Occupancy from Unified API

Expand source code
class occupancy(tflAPI):
    """Occupancy from Unified API"""

    def getBikePointByIDs(self, ids):
        """
        Gets the occupancy data for bike points

        Args:
            ids: List of bike point IDs (Eg. ['BikePoints_208', 'BikePoints_209'])
        """
        return super(occupancy, self).sendRequestUnified(
            f"/Occupancy/BikePoints/{self.arrayToCSV(ids)}", {}
        )

    def getCarParkByID(self, id):
        """
        Gets the occupancy for a car park with a given id

        Args:
            id: Car park ID (Eg. 'CarParks_800468')
        """
        
        return super(occupancy, self).sendRequestUnified(
            f"/Occupancy/CarPark/{id}", {}
        )

    def getChargeConnectorByID(self, id):
        """
        Gets the occupancy for a charge connectors with a given id

        Args:
            id: Charge connector ID (Eg. 'ChargePointESB-UT06NW-1')
        """
        
        return super(occupancy, self).sendRequestUnified(
            f"/Occupancy/ChargeConnector/{id}", {}
        )

    def getAllCarParks(self):
        """Gets the occupancy for all car parks that have occupancy data"""
        
        return super(occupancy, self).sendRequestUnified(
            f"/Occupancy/CarPark", {}
        )

    def getAllChargeConnectors(self):
        """Gets the occupancy for all charge connectors"""
        
        return super(occupancy, self).sendRequestUnified(
            f"/Occupancy/ChargeConnector", {}
        )

Ancestors

Methods

def getAllCarParks(self)

Gets the occupancy for all car parks that have occupancy data

Expand source code
def getAllCarParks(self):
    """Gets the occupancy for all car parks that have occupancy data"""
    
    return super(occupancy, self).sendRequestUnified(
        f"/Occupancy/CarPark", {}
    )
def getAllChargeConnectors(self)

Gets the occupancy for all charge connectors

Expand source code
def getAllChargeConnectors(self):
    """Gets the occupancy for all charge connectors"""
    
    return super(occupancy, self).sendRequestUnified(
        f"/Occupancy/ChargeConnector", {}
    )
def getBikePointByIDs(self, ids)

Gets the occupancy data for bike points

Args

ids
List of bike point IDs (Eg. ['BikePoints_208', 'BikePoints_209'])
Expand source code
def getBikePointByIDs(self, ids):
    """
    Gets the occupancy data for bike points

    Args:
        ids: List of bike point IDs (Eg. ['BikePoints_208', 'BikePoints_209'])
    """
    return super(occupancy, self).sendRequestUnified(
        f"/Occupancy/BikePoints/{self.arrayToCSV(ids)}", {}
    )
def getCarParkByID(self, id)

Gets the occupancy for a car park with a given id

Args

id
Car park ID (Eg. 'CarParks_800468')
Expand source code
def getCarParkByID(self, id):
    """
    Gets the occupancy for a car park with a given id

    Args:
        id: Car park ID (Eg. 'CarParks_800468')
    """
    
    return super(occupancy, self).sendRequestUnified(
        f"/Occupancy/CarPark/{id}", {}
    )
def getChargeConnectorByID(self, id)

Gets the occupancy for a charge connectors with a given id

Args

id
Charge connector ID (Eg. 'ChargePointESB-UT06NW-1')
Expand source code
def getChargeConnectorByID(self, id):
    """
    Gets the occupancy for a charge connectors with a given id

    Args:
        id: Charge connector ID (Eg. 'ChargePointESB-UT06NW-1')
    """
    
    return super(occupancy, self).sendRequestUnified(
        f"/Occupancy/ChargeConnector/{id}", {}
    )

Inherited members

class road (app_key)

Road from Unified API

Expand source code
class road(tflAPI):
    """Road from Unified API"""

    def getCategories(self):
        """Gets a list of valid RoadDisruption categories"""
        
        return super(road, self).sendRequestUnified(
            '/Road/Meta/Categories',
            {}
        )

    def getSeverities(self):
        """Gets a list of valid RoadDisruption severity codes"""

        return super(road, self).sendRequestUnified(
            '/Road/Meta/Severities',
            {}
        )

    def getAll(self):
        """Get all roads managed by TfL"""

        return super(road, self).sendRequestUnified(
            '/Road', {}
        )

    def getByID(self, ids):
        """
        Get the road with the specified ID (Eg. A1)
        Args:
            ids: ID(s) of the road(s). Eg. ['A1']
        """

        return super(road, self).sendRequestUnified(
            f'/Road/{self.arrayToCSV(ids)}', {}
        )

    def getStatusByID(self, ids, startDate, endDate):
        """
        Gets the specified roads with the status aggregated over the date range specified, or now until the end of today if no dates are passed.
        Args:
            ids: ID(s) of the road(s). Eg. ['A1']
            startDate: Optional, the start time to filter on
            endDate: Optional, the end time to filter on
        """

        return super(road, self).sendRequestUnified(
            f'/Road/{self.arrayToCSV(ids)}', {'startDate': self.getRFC3339(
                startDate), 'endDate': self.getRFC3339(endDate)}
        )

    def getAllStreetDisruption(self, startDate, endDate):
        """
        Gets a list of disrupted streets

        Args:
            startDate: Optional, the start time to filter on
            endDate: Optional, the end time to filter on
        """
        return super(road, self).sendRequestUnified(
            '/Road/all/Street/Disruption',
            {'startDate': self.getRFC3339(
                startDate), 'endDate': self.getRFC3339(endDate)}
        )

    def getAllDisruptionsByID(self, ids, stripContent: bool = False):
        """
        Gets a list of disrupted streets

        Args:
            ids: ID(s) of the road(s). Eg. ['A1']
            stripContent: Optional, if true, the content of the disruption will be stripped from the response
        """
        return super(road, self).sendRequestUnified(
            f'/Road/all/Disruption/{self.arrayToCSV(ids)}',
            {'stripContent': stripContent}
        )

Ancestors

Methods

def getAll(self)

Get all roads managed by TfL

Expand source code
def getAll(self):
    """Get all roads managed by TfL"""

    return super(road, self).sendRequestUnified(
        '/Road', {}
    )
def getAllDisruptionsByID(self, ids, stripContent: bool = False)

Gets a list of disrupted streets

Args

ids
ID(s) of the road(s). Eg. ['A1']
stripContent
Optional, if true, the content of the disruption will be stripped from the response
Expand source code
def getAllDisruptionsByID(self, ids, stripContent: bool = False):
    """
    Gets a list of disrupted streets

    Args:
        ids: ID(s) of the road(s). Eg. ['A1']
        stripContent: Optional, if true, the content of the disruption will be stripped from the response
    """
    return super(road, self).sendRequestUnified(
        f'/Road/all/Disruption/{self.arrayToCSV(ids)}',
        {'stripContent': stripContent}
    )
def getAllStreetDisruption(self, startDate, endDate)

Gets a list of disrupted streets

Args

startDate
Optional, the start time to filter on
endDate
Optional, the end time to filter on
Expand source code
def getAllStreetDisruption(self, startDate, endDate):
    """
    Gets a list of disrupted streets

    Args:
        startDate: Optional, the start time to filter on
        endDate: Optional, the end time to filter on
    """
    return super(road, self).sendRequestUnified(
        '/Road/all/Street/Disruption',
        {'startDate': self.getRFC3339(
            startDate), 'endDate': self.getRFC3339(endDate)}
    )
def getByID(self, ids)

Get the road with the specified ID (Eg. A1)

Args

ids
ID(s) of the road(s). Eg. ['A1']
Expand source code
def getByID(self, ids):
    """
    Get the road with the specified ID (Eg. A1)
    Args:
        ids: ID(s) of the road(s). Eg. ['A1']
    """

    return super(road, self).sendRequestUnified(
        f'/Road/{self.arrayToCSV(ids)}', {}
    )
def getCategories(self)

Gets a list of valid RoadDisruption categories

Expand source code
def getCategories(self):
    """Gets a list of valid RoadDisruption categories"""
    
    return super(road, self).sendRequestUnified(
        '/Road/Meta/Categories',
        {}
    )
def getSeverities(self)

Gets a list of valid RoadDisruption severity codes

Expand source code
def getSeverities(self):
    """Gets a list of valid RoadDisruption severity codes"""

    return super(road, self).sendRequestUnified(
        '/Road/Meta/Severities',
        {}
    )
def getStatusByID(self, ids, startDate, endDate)

Gets the specified roads with the status aggregated over the date range specified, or now until the end of today if no dates are passed.

Args

ids
ID(s) of the road(s). Eg. ['A1']
startDate
Optional, the start time to filter on
endDate
Optional, the end time to filter on
Expand source code
def getStatusByID(self, ids, startDate, endDate):
    """
    Gets the specified roads with the status aggregated over the date range specified, or now until the end of today if no dates are passed.
    Args:
        ids: ID(s) of the road(s). Eg. ['A1']
        startDate: Optional, the start time to filter on
        endDate: Optional, the end time to filter on
    """

    return super(road, self).sendRequestUnified(
        f'/Road/{self.arrayToCSV(ids)}', {'startDate': self.getRFC3339(
            startDate), 'endDate': self.getRFC3339(endDate)}
    )

Inherited members

class stopPoint (app_key)

Stop Point from Unified API

Expand source code
class stopPoint(tflAPI):
    """Stop Point from Unified API"""

    def getCategories(self):
        """Gets the list of available StopPoint additional information categories"""
        return super(stopPoint, self).sendRequestUnified(
            "/StopPoint/Meta/Categories", {}
        )

    def getTypes(self):
        """Gets the list of available StopPoint types"""

        return super(stopPoint, self).sendRequestUnified(
            "/StopPoint/Meta/StopTypes", {}
        )

    def getModes(self):
        """Gets the list of available StopPoint modes"""

        return super(stopPoint, self).sendRequestUnified(
            "/StopPoint/Meta/Modes", {}
        )

    def getByIDs(self, ids, includeCrowdingData: bool):
        """
        Gets a list of StopPoints corresponding to the given list of stop ids

        Args:
            ids: A list of StopPoint ids (station naptan code e.g. 940GZZLUAS)
            includeCrowdingData: Specify true to return crowding data (static) for each stop point
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/{','.join(ids)}", {includeCrowdingData}
        )

    def getAllByStopType(self, array):
        """
        Gets all stop points of a given type

        Args:
            array: An array of stop point types e.g. ['NaptanPublicBusCoachTram']
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/{super(stopPoint, self).arrayToCSV(array)}", {}
        )

    def getServiceTypesByID(self, stopPointID: str, lineIds, modes):
        """
        Gets the service types for a given Stop Point

        Args:
            stopPointID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
            lineIds: A list of Line ids (e.g. victoria)
            modes: An array of modes e.g. ['tube', 'dlr']
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/ServiceTypes",
            {"id": stopPointID, "lineIds": lineIds, "modes": modes},
        )

    def search(self, name: str, modes):
        """
        Search StopPoints by their common name. Will not return a valid NaPTAN for HUB

        Args:
            name: The name of station to search for
            modes: An array of modes e.g. ['tube', 'dlr']
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/Search/${name}",
            {"modes": super(stopPoint, self).arrayToCSV(modes)},
        )

    def getStationArrivals(self, naptanID: str):
        """
        Get all service arrivals

        Args:
            naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/{naptanID}/Arrivals", {}
        )

    # def getArrivalsDepartures(self, naptanID: str, lineIds):
    #     """
    #     Get all service arrivals and departures

    #     :param naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
    #     :param lineIds: List of line ids e.g. ['tflwrapper-rail', 'london-overground', 'thameslink']
    #     """

    #     return super(stopPoint, self).sendRequestUnified(
    #         f"StopPoint/${naptanID}/ArrivalsDepartures", {lineIds}
    #     )

    def getDisruptionsByID(
        self,
        ids,
        getFamily: bool,
        includeRouteBlockedStops: bool,
        flattenResponse: bool,
    ):
        """
        Gets all disruptions for the specified StopPointId, plus disruptions for any child Naptan records it may have

        Args:
            ids: A list of StopPoint ids (station naptan code e.g. 940GZZLUAS)
            getFamily: Specify true to return disruptions for entire family, or false to return disruptions for just this stop point. Defaults to false.
            includeRouteBlockedStops: Specify true to return disruptions for route blocked stops, or false to return disruptions for all stops. Defaults to false.
            flattenResponse: Specify true to return a flattened response, or false to return a nested response. Defaults to false.
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/{super(stopPoint, self).arrayToCSV(ids)}/Disruption",
            {getFamily, includeRouteBlockedStops, flattenResponse},
        )

    def getDisruptionsByMode(self, modes, includeRouteBlockedStops: bool):
        """
        Gets a distinct list of disrupted stop points for the given modes

        Args:
            modes: An array of modes e.g. ['tube', 'dlr']
            includeRouteBlockedStops: Specify true to return disruptions for route blocked stops, or false to return disruptions for all stops. Defaults to false.
        """
        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/Mode/{super(stopPoint, self).arrayToCSV(modes)}/Disruption",
            {includeRouteBlockedStops},
        )

    def getReachableStationsByID(self, naptanID: str, lineID: str, serviceTypes=None):
        """
        Gets Stop points that are reachable from a station/line combination

        Args:
            naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
            lineID: A Line id (e.g. victoria)
            serviceTypes: An array of service types. Supported values: Regular, Night. Defaults to Regular.
        """

        if serviceTypes is None:
            serviceTypes = ["Regular"]
        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/{naptanID}/CanReachOnLine/{lineID}",
            {"serviceTypes": super(stopPoint, self).arrayToCSV(serviceTypes)},
        )

    def getRouteSectionByID(self, naptanID: str, serviceTypes):
        """
        Get the route sections for all the lines that service the given stop point id#

        Args:
            naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
            serviceTypes: An array of service types. Supported values: Regular, Night.
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/{naptanID}/Route",
            {"serviceTypes": super(stopPoint, self).arrayToCSV(serviceTypes)},
        )

    def getInRadius(
        self,
        stopTypes,
        radius: int,
        useStopPointHierarchy: bool,
        modes,
        categories,
        returnLines: bool,
        latitude: int,
        longitude: int,
    ):
        """
        Gets a list of StopPoints within {radius} by the specified criteria

        Args:
            stopTypes: An array of stop point types e.g. ['NaptanPublicBusCoachTram']
            radius: The radius in metres. Defaults to 200.
            useStopPointHierarchy: Specify true to return stop points in the hierarchy, or false to return stop points at the specified radius. Defaults to false.
            modes: An array of modes e.g. ['tube', 'dlr']
            categories: An array of categories e.g. ['tram', 'bus']
            returnLines: Specify true to return the lines that service the stop point, or false to return the stop point itself. Defaults to false.
            latitude: The latitude of the location to search from.
            longitude: The longitude of the location to search from.
        """

        return super(stopPoint, self).sendRequestUnified(
            "/StopPoint",
            {
                "stopTypes": super(stopPoint, self).arrayToCSV(stopTypes),
                "radius": radius,
                "useStopPointHierarchy": useStopPointHierarchy,
                "modes": super(stopPoint, self).arrayToCSV(modes),
                "categories": super(stopPoint, self).arrayToCSV(categories),
                "returnLines": returnLines,
                "latitude": latitude,
                "longitude": longitude,
            },
        )

    def getBySMSCode(self, smsID: str, output: str):
        """
        Gets a StopPoint for a given sms code
        
        Args:
            smsID: A 5-digit sms code e.g. 73241, 50435, 5633.
            output: If set to "web", a 302 redirect to relevant website bus stop page is returned. All other values are ignored.
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/Sms/{smsID}", {output}
        )

    def getTaxiRanksByID(self, naptanID: str):
        """
        Gets a list of taxi ranks corresponding to the given stop point id

        Args:
            naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/{naptanID}/TaxiRanks", {}
        )

    def getCarParksByID(self, naptanID: str):
        """
        Get car parks corresponding to the given stop point id

        Args:
            naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
        """

        return super(stopPoint, self).sendRequestUnified(
            f"/StopPoint/{naptanID}/CarParks", {}
        )

Ancestors

Methods

def getAllByStopType(self, array)

Gets all stop points of a given type

Args

array
An array of stop point types e.g. ['NaptanPublicBusCoachTram']
Expand source code
def getAllByStopType(self, array):
    """
    Gets all stop points of a given type

    Args:
        array: An array of stop point types e.g. ['NaptanPublicBusCoachTram']
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/{super(stopPoint, self).arrayToCSV(array)}", {}
    )
def getByIDs(self, ids, includeCrowdingData: bool)

Gets a list of StopPoints corresponding to the given list of stop ids

Args

ids
A list of StopPoint ids (station naptan code e.g. 940GZZLUAS)
includeCrowdingData
Specify true to return crowding data (static) for each stop point
Expand source code
def getByIDs(self, ids, includeCrowdingData: bool):
    """
    Gets a list of StopPoints corresponding to the given list of stop ids

    Args:
        ids: A list of StopPoint ids (station naptan code e.g. 940GZZLUAS)
        includeCrowdingData: Specify true to return crowding data (static) for each stop point
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/{','.join(ids)}", {includeCrowdingData}
    )
def getBySMSCode(self, smsID: str, output: str)

Gets a StopPoint for a given sms code

Args

smsID
A 5-digit sms code e.g. 73241, 50435, 5633.
output
If set to "web", a 302 redirect to relevant website bus stop page is returned. All other values are ignored.
Expand source code
def getBySMSCode(self, smsID: str, output: str):
    """
    Gets a StopPoint for a given sms code
    
    Args:
        smsID: A 5-digit sms code e.g. 73241, 50435, 5633.
        output: If set to "web", a 302 redirect to relevant website bus stop page is returned. All other values are ignored.
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/Sms/{smsID}", {output}
    )
def getCarParksByID(self, naptanID: str)

Get car parks corresponding to the given stop point id

Args

naptanID
A StopPoint id (station naptan code e.g. 940GZZLUAS)
Expand source code
def getCarParksByID(self, naptanID: str):
    """
    Get car parks corresponding to the given stop point id

    Args:
        naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/{naptanID}/CarParks", {}
    )
def getCategories(self)

Gets the list of available StopPoint additional information categories

Expand source code
def getCategories(self):
    """Gets the list of available StopPoint additional information categories"""
    return super(stopPoint, self).sendRequestUnified(
        "/StopPoint/Meta/Categories", {}
    )
def getDisruptionsByID(self, ids, getFamily: bool, includeRouteBlockedStops: bool, flattenResponse: bool)

Gets all disruptions for the specified StopPointId, plus disruptions for any child Naptan records it may have

Args

ids
A list of StopPoint ids (station naptan code e.g. 940GZZLUAS)
getFamily
Specify true to return disruptions for entire family, or false to return disruptions for just this stop point. Defaults to false.
includeRouteBlockedStops
Specify true to return disruptions for route blocked stops, or false to return disruptions for all stops. Defaults to false.
flattenResponse
Specify true to return a flattened response, or false to return a nested response. Defaults to false.
Expand source code
def getDisruptionsByID(
    self,
    ids,
    getFamily: bool,
    includeRouteBlockedStops: bool,
    flattenResponse: bool,
):
    """
    Gets all disruptions for the specified StopPointId, plus disruptions for any child Naptan records it may have

    Args:
        ids: A list of StopPoint ids (station naptan code e.g. 940GZZLUAS)
        getFamily: Specify true to return disruptions for entire family, or false to return disruptions for just this stop point. Defaults to false.
        includeRouteBlockedStops: Specify true to return disruptions for route blocked stops, or false to return disruptions for all stops. Defaults to false.
        flattenResponse: Specify true to return a flattened response, or false to return a nested response. Defaults to false.
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/{super(stopPoint, self).arrayToCSV(ids)}/Disruption",
        {getFamily, includeRouteBlockedStops, flattenResponse},
    )
def getDisruptionsByMode(self, modes, includeRouteBlockedStops: bool)

Gets a distinct list of disrupted stop points for the given modes

Args

modes
An array of modes e.g. ['tube', 'dlr']
includeRouteBlockedStops
Specify true to return disruptions for route blocked stops, or false to return disruptions for all stops. Defaults to false.
Expand source code
def getDisruptionsByMode(self, modes, includeRouteBlockedStops: bool):
    """
    Gets a distinct list of disrupted stop points for the given modes

    Args:
        modes: An array of modes e.g. ['tube', 'dlr']
        includeRouteBlockedStops: Specify true to return disruptions for route blocked stops, or false to return disruptions for all stops. Defaults to false.
    """
    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/Mode/{super(stopPoint, self).arrayToCSV(modes)}/Disruption",
        {includeRouteBlockedStops},
    )
def getInRadius(self, stopTypes, radius: int, useStopPointHierarchy: bool, modes, categories, returnLines: bool, latitude: int, longitude: int)

Gets a list of StopPoints within {radius} by the specified criteria

Args

stopTypes
An array of stop point types e.g. ['NaptanPublicBusCoachTram']
radius
The radius in metres. Defaults to 200.
useStopPointHierarchy
Specify true to return stop points in the hierarchy, or false to return stop points at the specified radius. Defaults to false.
modes
An array of modes e.g. ['tube', 'dlr']
categories
An array of categories e.g. ['tram', 'bus']
returnLines
Specify true to return the lines that service the stop point, or false to return the stop point itself. Defaults to false.
latitude
The latitude of the location to search from.
longitude
The longitude of the location to search from.
Expand source code
def getInRadius(
    self,
    stopTypes,
    radius: int,
    useStopPointHierarchy: bool,
    modes,
    categories,
    returnLines: bool,
    latitude: int,
    longitude: int,
):
    """
    Gets a list of StopPoints within {radius} by the specified criteria

    Args:
        stopTypes: An array of stop point types e.g. ['NaptanPublicBusCoachTram']
        radius: The radius in metres. Defaults to 200.
        useStopPointHierarchy: Specify true to return stop points in the hierarchy, or false to return stop points at the specified radius. Defaults to false.
        modes: An array of modes e.g. ['tube', 'dlr']
        categories: An array of categories e.g. ['tram', 'bus']
        returnLines: Specify true to return the lines that service the stop point, or false to return the stop point itself. Defaults to false.
        latitude: The latitude of the location to search from.
        longitude: The longitude of the location to search from.
    """

    return super(stopPoint, self).sendRequestUnified(
        "/StopPoint",
        {
            "stopTypes": super(stopPoint, self).arrayToCSV(stopTypes),
            "radius": radius,
            "useStopPointHierarchy": useStopPointHierarchy,
            "modes": super(stopPoint, self).arrayToCSV(modes),
            "categories": super(stopPoint, self).arrayToCSV(categories),
            "returnLines": returnLines,
            "latitude": latitude,
            "longitude": longitude,
        },
    )
def getModes(self)

Gets the list of available StopPoint modes

Expand source code
def getModes(self):
    """Gets the list of available StopPoint modes"""

    return super(stopPoint, self).sendRequestUnified(
        "/StopPoint/Meta/Modes", {}
    )
def getReachableStationsByID(self, naptanID: str, lineID: str, serviceTypes=None)

Gets Stop points that are reachable from a station/line combination

Args

naptanID
A StopPoint id (station naptan code e.g. 940GZZLUAS)
lineID
A Line id (e.g. victoria)
serviceTypes
An array of service types. Supported values: Regular, Night. Defaults to Regular.
Expand source code
def getReachableStationsByID(self, naptanID: str, lineID: str, serviceTypes=None):
    """
    Gets Stop points that are reachable from a station/line combination

    Args:
        naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
        lineID: A Line id (e.g. victoria)
        serviceTypes: An array of service types. Supported values: Regular, Night. Defaults to Regular.
    """

    if serviceTypes is None:
        serviceTypes = ["Regular"]
    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/{naptanID}/CanReachOnLine/{lineID}",
        {"serviceTypes": super(stopPoint, self).arrayToCSV(serviceTypes)},
    )
def getRouteSectionByID(self, naptanID: str, serviceTypes)

Get the route sections for all the lines that service the given stop point id#

Args

naptanID
A StopPoint id (station naptan code e.g. 940GZZLUAS)
serviceTypes
An array of service types. Supported values: Regular, Night.
Expand source code
def getRouteSectionByID(self, naptanID: str, serviceTypes):
    """
    Get the route sections for all the lines that service the given stop point id#

    Args:
        naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
        serviceTypes: An array of service types. Supported values: Regular, Night.
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/{naptanID}/Route",
        {"serviceTypes": super(stopPoint, self).arrayToCSV(serviceTypes)},
    )
def getServiceTypesByID(self, stopPointID: str, lineIds, modes)

Gets the service types for a given Stop Point

Args

stopPointID
A StopPoint id (station naptan code e.g. 940GZZLUAS)
lineIds
A list of Line ids (e.g. victoria)
modes
An array of modes e.g. ['tube', 'dlr']
Expand source code
def getServiceTypesByID(self, stopPointID: str, lineIds, modes):
    """
    Gets the service types for a given Stop Point

    Args:
        stopPointID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
        lineIds: A list of Line ids (e.g. victoria)
        modes: An array of modes e.g. ['tube', 'dlr']
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/ServiceTypes",
        {"id": stopPointID, "lineIds": lineIds, "modes": modes},
    )
def getStationArrivals(self, naptanID: str)

Get all service arrivals

Args

naptanID
A StopPoint id (station naptan code e.g. 940GZZLUAS)
Expand source code
def getStationArrivals(self, naptanID: str):
    """
    Get all service arrivals

    Args:
        naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/{naptanID}/Arrivals", {}
    )
def getTaxiRanksByID(self, naptanID: str)

Gets a list of taxi ranks corresponding to the given stop point id

Args

naptanID
A StopPoint id (station naptan code e.g. 940GZZLUAS)
Expand source code
def getTaxiRanksByID(self, naptanID: str):
    """
    Gets a list of taxi ranks corresponding to the given stop point id

    Args:
        naptanID: A StopPoint id (station naptan code e.g. 940GZZLUAS)
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/{naptanID}/TaxiRanks", {}
    )
def getTypes(self)

Gets the list of available StopPoint types

Expand source code
def getTypes(self):
    """Gets the list of available StopPoint types"""

    return super(stopPoint, self).sendRequestUnified(
        "/StopPoint/Meta/StopTypes", {}
    )
def search(self, name: str, modes)

Search StopPoints by their common name. Will not return a valid NaPTAN for HUB

Args

name
The name of station to search for
modes
An array of modes e.g. ['tube', 'dlr']
Expand source code
def search(self, name: str, modes):
    """
    Search StopPoints by their common name. Will not return a valid NaPTAN for HUB

    Args:
        name: The name of station to search for
        modes: An array of modes e.g. ['tube', 'dlr']
    """

    return super(stopPoint, self).sendRequestUnified(
        f"/StopPoint/Search/${name}",
        {"modes": super(stopPoint, self).arrayToCSV(modes)},
    )

Inherited members

class tflAPI (app_key)

TFL API

Expand source code
class tflAPI(object):
    """TFL API"""

    def __init__(self, app_key):
        self.app_key = app_key

    def sendRequestUnified(self, uri: str, params):
        """
        Send a HTTP GET request to the TFL Unified API using your API Key

        :param uri: The url which will be prepended to unifiedAPI
        :param params: An object containg any extra parameters
        :returns: API Data from TfL Unified API
        """
        fullURL = f"https://api.tfl.gov.uk:443{uri}?{urllib.parse.urlencode({'app_key': self.app_key})}"

        # If params is specified then convert it to a url encoded string
        if params:
            fullURL += f"&{urllib.parse.urlencode(params)}"

        # Send the request
        resource = urllib.request.urlopen(fullURL)
        
        return json.loads(
            resource.read().decode(resource.headers.get_content_charset())
        )

    @staticmethod
    def sendRequestTrackerNet(uri: str):
        """
        Send a HTTP GET request to the TrackerNet API

        :param uri: The url which will be prepended to trackerNetAPI
        :returns: API Data from TfL Unified API
        """

        data = urllib.request.urlopen(
            f"http://cloud.tfl.gov.uk/TrackerNet{uri}").read()

    @staticmethod
    def arrayToCSV(array):
        """
        Convert array to a comma-separated string

        :param array: Array to convert to a comma-separated string
        :returns: A comma-separated string
        """
        return ",".join(array)

    @staticmethod
    def getRFC3339(date_object):
        """
        Convert date object to RFC3339 standard

        :param date_object: A date object to convert to RFC3339 standard
        :returns: A RFC3339 formatted string
        """
        return date_object.isoformat("T") + "Z"

Subclasses

  • tflwrapper.accidentStats.accidentStats
  • tflwrapper.airQuality.airQuality
  • tflwrapper.bikePoint.bikePoint
  • tflwrapper.crowding.crowding
  • tflwrapper.disruptions.disruptions
  • tflwrapper.line.line
  • tflwrapper.mode.mode
  • tflwrapper.occupancy.occupancy
  • tflwrapper.road.road
  • tflwrapper.stopPoint.stopPoint
  • tflwrapper.trackerNet.trackerNet
  • tflwrapper.travelTimes.travelTimes

Static methods

def arrayToCSV(array)

Convert array to a comma-separated string

:param array: Array to convert to a comma-separated string :returns: A comma-separated string

Expand source code
@staticmethod
def arrayToCSV(array):
    """
    Convert array to a comma-separated string

    :param array: Array to convert to a comma-separated string
    :returns: A comma-separated string
    """
    return ",".join(array)
def getRFC3339(date_object)

Convert date object to RFC3339 standard

:param date_object: A date object to convert to RFC3339 standard :returns: A RFC3339 formatted string

Expand source code
@staticmethod
def getRFC3339(date_object):
    """
    Convert date object to RFC3339 standard

    :param date_object: A date object to convert to RFC3339 standard
    :returns: A RFC3339 formatted string
    """
    return date_object.isoformat("T") + "Z"
def sendRequestTrackerNet(uri: str)

Send a HTTP GET request to the TrackerNet API

:param uri: The url which will be prepended to trackerNetAPI :returns: API Data from TfL Unified API

Expand source code
@staticmethod
def sendRequestTrackerNet(uri: str):
    """
    Send a HTTP GET request to the TrackerNet API

    :param uri: The url which will be prepended to trackerNetAPI
    :returns: API Data from TfL Unified API
    """

    data = urllib.request.urlopen(
        f"http://cloud.tfl.gov.uk/TrackerNet{uri}").read()

Methods

def sendRequestUnified(self, uri: str, params)

Send a HTTP GET request to the TFL Unified API using your API Key

:param uri: The url which will be prepended to unifiedAPI :param params: An object containg any extra parameters :returns: API Data from TfL Unified API

Expand source code
def sendRequestUnified(self, uri: str, params):
    """
    Send a HTTP GET request to the TFL Unified API using your API Key

    :param uri: The url which will be prepended to unifiedAPI
    :param params: An object containg any extra parameters
    :returns: API Data from TfL Unified API
    """
    fullURL = f"https://api.tfl.gov.uk:443{uri}?{urllib.parse.urlencode({'app_key': self.app_key})}"

    # If params is specified then convert it to a url encoded string
    if params:
        fullURL += f"&{urllib.parse.urlencode(params)}"

    # Send the request
    resource = urllib.request.urlopen(fullURL)
    
    return json.loads(
        resource.read().decode(resource.headers.get_content_charset())
    )
class trackerNet (app_key)

TrackerNet API

Expand source code
class trackerNet(tflAPI):
    """TrackerNet API"""

    def getPredictionSummary(self, line: str):
        """
        Get detailed train prediction information for a nominated station on a nominated line within 100 minute range
        
        Args:
            line: The line code for the line (eg. C)
        """

        return super(trackerNet, self).sendRequestTrackerNet(
            f"/PredictionSummary/{line}"
        )

    def getPredictionDetailed(self, line: str, stationCode: str):
        """
        Get detailed train prediction information for a nominated station on a nominated line within 100 minute range
        
        Args:
            line: The line code for the line (eg. C)
            stationCode: The station code for the station (eg. BNK)
        """

        return super(trackerNet, self).sendRequestTrackerNet(
            f"/PredictionDetailed/{line}/{stationCode}"
        )

    def getAllLinesStatus(self, incidentsOnly: bool):
        """
        Get the status of all lines on the network indicating any delays, disruptions or suspensions on the lines.

        Args:
            incidentsOnly: Get line status information for lines with incidents only
        """

        incidentsOnlyCheck = '/IncidentsOnly' if incidentsOnly else ''
        return super(trackerNet, self).sendRequestTrackerNet(
            f"/LineStatus{incidentsOnlyCheck}"
        )

    def getAllStationStatus(self, incidentsOnly: bool):
        """
        Get station status information for all stations

        Args:
            incidentsOnly: Get station status information for stations with incidents only
        """

        incidentsOnlyCheck = '/IncidentsOnly' if incidentsOnly else ''
        return super(trackerNet, self).sendRequestTrackerNet(
            f"/StationStatus{incidentsOnlyCheck}"
        )

Ancestors

Methods

def getAllLinesStatus(self, incidentsOnly: bool)

Get the status of all lines on the network indicating any delays, disruptions or suspensions on the lines.

Args

incidentsOnly
Get line status information for lines with incidents only
Expand source code
def getAllLinesStatus(self, incidentsOnly: bool):
    """
    Get the status of all lines on the network indicating any delays, disruptions or suspensions on the lines.

    Args:
        incidentsOnly: Get line status information for lines with incidents only
    """

    incidentsOnlyCheck = '/IncidentsOnly' if incidentsOnly else ''
    return super(trackerNet, self).sendRequestTrackerNet(
        f"/LineStatus{incidentsOnlyCheck}"
    )
def getAllStationStatus(self, incidentsOnly: bool)

Get station status information for all stations

Args

incidentsOnly
Get station status information for stations with incidents only
Expand source code
def getAllStationStatus(self, incidentsOnly: bool):
    """
    Get station status information for all stations

    Args:
        incidentsOnly: Get station status information for stations with incidents only
    """

    incidentsOnlyCheck = '/IncidentsOnly' if incidentsOnly else ''
    return super(trackerNet, self).sendRequestTrackerNet(
        f"/StationStatus{incidentsOnlyCheck}"
    )
def getPredictionDetailed(self, line: str, stationCode: str)

Get detailed train prediction information for a nominated station on a nominated line within 100 minute range

Args

line
The line code for the line (eg. C)
stationCode
The station code for the station (eg. BNK)
Expand source code
def getPredictionDetailed(self, line: str, stationCode: str):
    """
    Get detailed train prediction information for a nominated station on a nominated line within 100 minute range
    
    Args:
        line: The line code for the line (eg. C)
        stationCode: The station code for the station (eg. BNK)
    """

    return super(trackerNet, self).sendRequestTrackerNet(
        f"/PredictionDetailed/{line}/{stationCode}"
    )
def getPredictionSummary(self, line: str)

Get detailed train prediction information for a nominated station on a nominated line within 100 minute range

Args

line
The line code for the line (eg. C)
Expand source code
def getPredictionSummary(self, line: str):
    """
    Get detailed train prediction information for a nominated station on a nominated line within 100 minute range
    
    Args:
        line: The line code for the line (eg. C)
    """

    return super(trackerNet, self).sendRequestTrackerNet(
        f"/PredictionSummary/{line}"
    )

Inherited members

class travelTimes (app_key)

Travel Times from Unified API

Expand source code
class travelTimes(tflAPI):
    """Travel Times from Unified API"""

    def getOverlay(
        self,
        z,
        pinLat,
        pinLon,
        mapCenterLat,
        mapCenterLon,
        scenarioTitle,
        timeOfDayID,
        modeID,
        width,
        height,
        direction,
        travelTimeInterval
    ):
        """
        Gets the TravelTime overlay

        Args:
            z: The zoom level of the map
            pinLat: The latitude of the pin
            pinLon: The longitude of the pin
            mapCenterLat: The latitude of the map center
            mapCenterLon: The longitude of the map center
            scenarioTitle: The title of the scenario
            timeOfDayID: The time of day ID. Supported values: AM, INTER, PM
            modeID: The mode ID.
            width: The width of the map
            height: The height of the map
            direction: The direction of the travel
            travelTimeInterval: The travel time interval
        """
        return super(travelTimes, self).sendRequestUnified(
            f"/TravelTimes/overlay/{z}/mapcenter/{mapCenterLat}/{mapCenterLon}/pinlocation/{pinLat}/{pinLon}/dimensions/{width}/{height}/", {}
        )

Ancestors

Methods

def getOverlay(self, z, pinLat, pinLon, mapCenterLat, mapCenterLon, scenarioTitle, timeOfDayID, modeID, width, height, direction, travelTimeInterval)

Gets the TravelTime overlay

Args

z
The zoom level of the map
pinLat
The latitude of the pin
pinLon
The longitude of the pin
mapCenterLat
The latitude of the map center
mapCenterLon
The longitude of the map center
scenarioTitle
The title of the scenario
timeOfDayID
The time of day ID. Supported values: AM, INTER, PM
modeID
The mode ID.
width
The width of the map
height
The height of the map
direction
The direction of the travel
travelTimeInterval
The travel time interval
Expand source code
def getOverlay(
    self,
    z,
    pinLat,
    pinLon,
    mapCenterLat,
    mapCenterLon,
    scenarioTitle,
    timeOfDayID,
    modeID,
    width,
    height,
    direction,
    travelTimeInterval
):
    """
    Gets the TravelTime overlay

    Args:
        z: The zoom level of the map
        pinLat: The latitude of the pin
        pinLon: The longitude of the pin
        mapCenterLat: The latitude of the map center
        mapCenterLon: The longitude of the map center
        scenarioTitle: The title of the scenario
        timeOfDayID: The time of day ID. Supported values: AM, INTER, PM
        modeID: The mode ID.
        width: The width of the map
        height: The height of the map
        direction: The direction of the travel
        travelTimeInterval: The travel time interval
    """
    return super(travelTimes, self).sendRequestUnified(
        f"/TravelTimes/overlay/{z}/mapcenter/{mapCenterLat}/{mapCenterLon}/pinlocation/{pinLat}/{pinLon}/dimensions/{width}/{height}/", {}
    )

Inherited members