pyfl package

Submodules

pyfl.accident module

class Accident[source]

Bases: object

Accident class

get_accident_stats(year)[source]

Returns the accident statistics for a given year

Parameters

kind (str) – Year for the stats to get.

Returns

The stats for that year.

Return type

dict

pyfl.air module

class AirQuality[source]

Bases: object

AirQuality class

get_air_quality()[source]

Returns the current air quality in london

Returns

The air quality in london.

Return type

dict

pyfl.bikePoint module

class bike[source]

Bases: object

bike class

get_all_bike_points()[source]

Returns all the bike points

Returns

all the bike points in london.

Return type

dict

get_bike_point(id)[source]

Returns a specfic bike point

Parameters

id (int) – id of the bike point to get.

Returns

the bike point.

Return type

dict

get_bike_point_by_name(name)[source]

Returns a specfic bike point

Parameters

name (str) – name of the bike point to get.

Returns

the bike point.

Return type

dict

pyfl.cabWise module

class cab[source]

Bases: object

Cab class

get_taxi_information(lat, long, optype='', wheelchair=False, radius=0, name='', maxResults=20, legacyFormat=False, twentyFourSevenOnly=False)[source]

Returns taxi and minicabs contact information

Parameters
  • lat (float) – latitude

  • long (float) – longitude

  • optype (str) – Operator Type e.g Minicab, Executive, Limousine

  • wheelchair (bool) – Wheelchair accessible

  • radius (int) – The radius in metres to search for operators

  • name (str) – The trading name of the operating company

  • maxResults (int) – max results to search for, defualts to 20

  • legacyFormat (bool) – Legacy format [NOT RECOMMENDED], defualts to False

  • twentyFourSevenOnly (bool) – To only search for operators which are 24/7, defualts to False

Returns

The taxi information.

Return type

dict

pyfl.client module

class client(api_key)[source]

Bases: object

Synchronous client class

pyfl.errors module

exception PYFL_Error(message)[source]

Bases: Exception

Base class for all PYFL errors.

exception invalid_api_key(message)[source]

Bases: PYFL_Error

Raised when the API key is invalid.

exception invalid_endpoint(message)[source]

Bases: PYFL_Error

Raised when the endpoint is invalid.

exception invalid_parameter(message)[source]

Bases: PYFL_Error

Raised when the parameter is invalid.

exception invalid_response(message)[source]

Bases: PYFL_Error

Raised when the response is invalid.

pyfl.helper module

class Helper[source]

Bases: object

Utility class to help with developing the library.

victoria = 'victoria'
circle = 'circle'
district = 'district'
HammersmithCity = 'hammersmith-city'
Piccadilly = 'piccadilly'
Metropolitan = 'metropolitan'
Northern = 'northern'
Jubilee = 'jubilee'
Central = 'central'
Bakerloo = 'bakerloo'
WaterlooCity = 'waterloo-city'
DLR = 'dlr'
Overground = 'overground'
TfL_Rail = 'tfl-rail'
LondonOverground = 'london-overground'
static make_raw_api_call(endpoint)[source]

Make a raw API call to the TFL API

Parameters

endpoint (str) – The endpoint to call

Returns

The json response from the API

static parse(json_data)[source]

removes the data from the response

Parameters

json_data (dict) – The json data to parse

Returns

The parsed data

Return type

dict

pyfl.journeys module

class journeys[source]

Bases: object

Journey class

get_available_modes()[source]

Get’s a list of all the available modes of transport

Returns

The available modes of transport.

Return type

dict

perform_journey(fromcoord, tocoord)[source]

” Perform a journey between two points, note: there are many more parameters that need to be added to this function at a later date. Please refer to the docs for more information (https://api.tfl.gov.uk/swagger/ui/index.html?url=/swagger/docs/v1#!/Journey/Journey_JourneyResults).

Parameters
  • fromcoord (str) – The starting location

  • tocoord (str) – The destination

Returns

The journey

Return type

dict

pyfl.mode module

class Mode[source]

Bases: object

Mode class

get_mode()[source]

Returns the service type for a given mode

Returns

The service type for a given mode.

Return type

dict

get_arrival_predictions(mode, count=-1)[source]

Get’s the arrival predictions for all stops of a given mode

Parameters
  • mode (str) – The mode to get the arrival predictions for.

  • count (int) – The number of arrivals to return, defaults to -1 (all)

Returns

The arrival predictions.

Return type

dict

pyfl.occupancy module

class Occupancy[source]

Bases: object

Occupancy class

get_car_park_occupancy(id='')[source]

Returns the current occupancy of a car park

Parameters

id (string) – The id of the car park, defualts to all

Returns

The occupancy of the car park.

Return type

dict

get_charge_point_occupancy(id=[])[source]

Returns the current occupancy of a charge point

Parameters

id (array) – The id of the charge point, defualts to all

Returns

The occupancy of the charge point.

Return type

dict

get_bike_point_occupancy(id)[source]

Returns the current occupancy of a bike point

Parameters

id (list) – The id of the bike point

Returns

The occupancy of the bike point.

Return type

dict

pyfl.place module

class Place[source]

Bases: object

Place class

get_place_catagories()[source]

Get all the place catagories

Returns

The place catagories

Return type

dict

get_place_types()[source]

Get all the place types

Returns

The place types

Return type

dict

get_street(postcode)[source]

Get the street for a given postcode

Parameters

postcode (str) – The postcode to get the street for

Returns

The street

Return type

dict

get_places_by_type(type=[], activeOnly=False)[source]

Get all the places of a given type

Parameters
  • type (list) – The type of place to get

  • activeOnly – Only return active places, defaults to False

Returns

The places

Return type

dict

get_places_by_id(id)[source]

Get a place by it’s id

Parameters

id (str) – The id of the place

Returns

The place

Return type

dict

get_places_by_location(radius, lat, long, type='', catagories=[], includeChildren=False, activeOnly=False, max=20)[source]

Get all the places of a given type within a given radius of a given location

Parameters
  • radius (int) – The radius to search in

  • lat (float) – The latitude of the location

  • long (float) – The longitude of the location

  • type (str) – The type of place to get (optional)

  • catagories (list) – The catagories of place to get (optional)

  • includeChildren (bool) – Include child places, defaults to False

  • activeOnly (bool) – Only return active places, defaults to False

  • max (int) – The maximum number of places to return, defaults to 20

Returns

The places

Return type

dict

get_place_by_type_and_location(type, lat, long)[source]

Get all the places of a given type within a given radius of a given location

Parameters
  • type (list) – The type of place to get

  • lat (float) – The latitude of the location

  • long (float) – The longitude of the location

Returns

The places

Return type

dict

get_place_by_type(name)[source]

Get a place by it’s name

Parameters

name (str) – The name of the place

Returns

The place

Return type

dict

get_place_overlay(z, type, width, height, lat, long)[source]

Get the overlay for a given place

Parameters
  • z (int) – The zoom level

  • type (list) – The type of place to get

  • width (int) – The width of the overlay

  • height (int) – The height of the overlay

  • lat (int) – The latitude of the location

  • long (int) – The longitude of the location

Returns

The overlay

Return type

dict

pyfl.road module

class Road[source]

Bases: object

Road Class

get_road(road_id='')[source]

Gets the road with the given id

Parameters

road_id – The id of the road (optional)

Type

str

Returns

All the roads managed by TFL

Return type

dict

get_road_status(road_id, dataRangeNullableStart, dataRangeNullableEnd)[source]

Gets the status of the road with the given id

Parameters
  • road_id – The id of the road

  • dataRangeNullableStart – The start date (optional)

  • dataRangeNullableEnd – The end date (optional)

Type

str

Type

str

Type

str

Returns

The status of the road

Return type

dict

get_active_disruptions(road_id, stripContent=False, severities='', catagories='', closures=True)[source]

Get’s a list of all the active disruptions, filtered by the road ID

Param

road_id: The id of the road

Type

str

Param

stripContent: Optional, defaults to false. When true, removes every property/node except for id, point, severity, severityDescription, startDate, endDate, corridor details, location, comments and streets

Type

bool

Param

severities: Optional, defaults to empty string. When set, filters the results by severity. Can be comma separated list of severities. (a valid list of severities can be obtained from the road.get_road_disruption_severities() function)

Type

str

Param

catagories: Optional, defaults to empty string. When set, filters the results by category. Can be comma separated list of categories. (a valid list of categories can be obtained from the road.get_road_disruption_catagories() function)

Type

str

Param

closures: Optional, defaults to true. When true, always includes disruptions that have road closures, regardless of the severity filter. When false, the severity filter works as normal.

Type

bool

Returns

A list of all the active disruptions

Return type

dict

get_all_disruptions(startDate='', endDate='')[source]

Gets a list of all the disruptions

Param

startDate: Optional, defaults to empty string. When set, filters the results by start date. Must be in the format YYYY-MM-DD

Type

str

Param

endDate: Optional, defaults to empty string. When set, filters the results by end date. Must be in the format YYYY-MM-DD

Type

str

Returns

A list of all the disruptions

Return type

dict

get_road_disruption_catagories()[source]

Get a list of all the road disruption catagories

Returns

A list of all the road disruption catagories

Return type

dict

get_road_disruption_severities()[source]

Get a list of all the road disruption severities

Returns

A list of all the road disruption severities

Return type

dict

pyfl.search module

class Search[source]

Bases: object

Search class

search(query)[source]

Searches the TFL website for any references of the query, returns 100 results

Parameters

query – The query which to search

Type

str

Returns

Any references of the query

Return type

dict

search_bus_schedule(query)[source]

Searches the TFL website for a bus number

Parameters

query – The query which to search

Type

str

Returns

The schedule of the busses

Return type

dict

search_provider_names()[source]
get_available_search_catagories()[source]

Get’s all the available search cataogries

Returns

All of the available search catagries

Return type

dict

get_all_avaiable_sort_options()[source]

Get’s all the avaiable sorting options

Returns

A list of all the avaialble sorting options

Return type

dict

pyfl.stop module

class Stop[source]

Bases: object

Stop class

get_stop_catagories()[source]

Returns a list of all available stop catagories

Returns

A list of all available stop catagories

Return type

dict

get_stop_types()[source]

Returns a list of all available stop types

Returns

A list of all available stop types

Return type

dict

get_stop_modes()[source]

Returns a list of all available stop modes

Returns

A list of all available stop modes

Return type

dict

get_stop_by_id(stopID, includeCrowding=False)[source]

Returns a stop by its ID

Parameters
  • stopID (str) – A comma-separated list of stop point ids (station naptan code e.g. 940GZZLUASL). Max. approx. 20 ids. You can use /StopPoint/Search/{query} endpoint to find a stop point id from a station name.

  • includeCrowding (bool) – Include the crowding data (static). To Filter further use: /StopPoint/{ids}/Crowding/{line} (optional, default to False)

Returns

The stop

Return type

dict

get_place_by_id(placeID, placeType)[source]

Returns a place by its ID

Parameters
  • placeID (str) – A naptan id for a stop point (station naptan code e.g. 940GZZLUASL).

  • placeType (str) – A comcomma-separated value representing the place types

Returns

The place

Return type

dict

get_crowding_data(placeID, line='', direction='')[source]

Gets all the Crowding data (static) for the StopPointId, plus crowding data for a given line and optionally a particular direction.

Parameters
  • placeID (str) – The Naptan id of the stop

  • line (str) – A particular line e.g. victoria, circle, northern etc. Optionally you can use in helper.victora (optional, default to None)

  • direction (str) – The direction of travel. Can be inbound or outbound. (optional, default to None)

Returns

The crowding data

Return type

dict

get_all_stop_points_by_type(type, page=0)[source]

Returns all stop points of a given type

Parameters
  • type (str) – A comma-separated list of the types to return. Max. approx. 12 types. A list of valid stop types can be obtained from the StopPoint/meta/stoptypes endpoint.

  • page (int) – The page number to return (optional, default to None)

Returns

All stop points of a given type

Return type

dict

get_service_type_of_stoppoint(id, lineID=[], modes=[])[source]

Gets the service types for a given stoppoint

Parameters
  • id (str) – The Naptan id of the stop

  • lineID (array) – A particular line e.g. victoria, circle, northern etc. Optionally you can use in helper.victora (optional, default to None)

  • modes – The modes which the lines are relevant to

Returns

The service types for a given stoppoint

Return type

dict

get_arrival_predictions(stopID)[source]

Gets the list of arrival predictions for the given stop point id

Parameters

stopID (str) – A StopPoint id (station naptan code e.g. 940GZZLUASL, you can use /StopPoint/Search/{query} endpoint to find a stop point id from a station name)

Returns

The list of arrival predictions for the given stop point id

Return type

dict

pyfl.travel module

class Travel[source]

Bases: object

Travel class

get_travel_time_overlay(z, pin_lat, pin_long, mapCenterLat, mapCenterLon, scenarioTitle, timeOfDay, modeID, width, height, direction, travelTime)[source]

Generates a travel time overlay

Parameters
  • z (int) – Zomm level

  • pin_lat (float) – Latitude of the pin

  • pin_long (float) – Longitude of the pin

  • mapCenterLat (float) – Latitude of the map center

  • mapCenterLon (float) – Longitude of the map center

  • scenarioTitle (str) – Title of the scenario

  • timeOfDay (str) – Time of day

  • modeID (str) – Mode ID

  • width (int) – The width of the requested overlay

  • height (int) – The height of the requested overlay

  • direction (str) – Direction of travel (From, To, Average) (optional, default to Average)

  • travelTime (int) – The total minutes between the travel time bands

Returns

The travel time overlay

Return type

dict

compare_travel_time_overlay(z, pin_lat, pin_long, mapCenterLat, mapCenterLon, scenarioTitle, timeOfDay, modeID, width, height, direction, travelTime, compareType, compareValue)[source]

Generates a travel time overlay

Parameters
  • z (int) – Zomm level

  • pin_lat (float) – Latitude of the pin

  • pin_long (float) – Longitude of the pin

  • mapCenterLat (float) – Latitude of the map center

  • mapCenterLon (float) – Longitude of the map center

  • scenarioTitle (str) – Title of the scenario

  • timeOfDay (str) – Time of day

  • modeID (str) – Mode ID

  • width (int) – The width of the requested overlay

  • height (int) – The height of the requested overlay

  • direction (str) – Direction of travel (From, To, Average) (optional, default to Average)

  • travelTime (int) – The total minutes between the travel time bands

  • compareType (str) – The type of comparison (Scenario, TimeOfDay, Mode)

Returns

The travel time overlay

Return type

dict

pyfl.tube module

class LU[source]

Bases: object

Line class

get_line_status(line)[source]

Returns the status of a line

Parameters

kind (str) – Status of the line to get.

Returns

The line status.

Return type

dict

pyfl.vehicle module

class Vehicle[source]

Bases: object

Vehicle class

get_vehicle_arrival(registration)[source]

Returns the predicted arrival of a vehicle with the given registration

Parameters

kind (list of strings) – The registration of the vehicle to gt

Returns

The predicted arrival time of the vehicle with that registration

Return type

dict

Module contents