citram_api.api.lines package

Submodules

citram_api.api.lines.lines module

citram_api.api.lines.lines.get_incidents_affectations(mode_cod, cod_line)

Returns incidents happening at the specified line.

Example: get_incidents_affectations(TransportModes.METRO.value, create_line_cod(TransportModes.METRO.value, 10))

Parameters:
  • mode_cod (int) – Id of a public transport. Use constants.TransportModes to easily select transport modes ids.
  • cod_line (str) – Line id. Use utils.create_line_cod to create this id easily.
Return dict:

The current incidents going on in that line.

citram_api.api.lines.lines.get_line_info(cod_line)

Returns line information from the line id specified.

Example:

get_line_info(create_line_cod(TransportModes.METRO.value, 10))
Parameters:cod_line (str) – Line id. Use utils.create_line_cod to create this id easily.
Returns:Info of the line id specified. The returned dictionary look likes the following example:
{
    'lines': {
        'LineInformation': {
            'codLine': '4__10___',
            'shortDescription': '10',
            'description': 'Hospital del Norte-Puerta del Sur',
            'codMode': '4',
            'codMunicipalities': {
                'string': ['4278', '4279', '4350', '4401']
            },
            'itinerary': {
                'Itinerary': [{
                    'codItinerary': '4__10____1__IT_1',
                    'name': 'Hospital del Norte - Puerta del Sur',
                    'direction': 1,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/metrokmz/M4_L10a_S1_TRAMO.kmz#http://www.citram.es:8080/kml/itinerarios/20160601_1704/metrokmz/M4_L10b_S1_TRAMO.kmz',
                    'stops': {
                        'StopInformation': [{
                            'codStop': '4_284',
                            'shortCodStop': '',
                            'codMode': '4',
                            'name': 'HOSPITAL INFANTA SOFÍA',
                            'address': 'Paseo  Europa SN ',
                            'postCode': '',
                            'codMunicipality': '4401',
                            'coordinates': {
                                'longitude': -3.61145,
                                'latitude': 40.55977
                            },
                            'lines': {
                                'Line': {
                                    'codLine': '4__10___',
                                    'shortDescription': '10',
                                    'description': 'Hospital del Norte-Puerta del Sur',
                                    'codMode': '4',
                                    'updateDate': '2019-03-22T17:21:37+01:00',
                                    'updateKmlDate': '2016-06-01T17:04:00+02:00',
                                    'nightService': 0,
                                    'active': True,
                                    'shortItinerary': {},
                                    'companyCode': ''
                                }
                            },
                            'access': 0,
                            'park': 0,
                            'nightLinesService': 0
                        },
                        ...
            },
            'updateDate': '2019-03-22T17:21:37+01:00',
            'updateKmlDate': '2016-06-01T17:04:00+02:00',
            'nightService': 0,
            'lineTimePlanning': {
                'codLine': '4__10___',
                'codItinerary': '',
                'type': '',
                'startService': '',
                'endService': '',
                'updateDate': '0001-01-01T00:00:00'
            }
        }
    }
}
citram_api.api.lines.lines.get_line_location(mode_cod, cod_itinerary, cod_line, cod_stop, direction)

It returns the location of that line at the moment the request is performed. (i.e. Location of a bus of that line right now).

Example:

line = get_line_info(create_line_cod(TransportModes.METRO.value, 10))['lines']['LineInformation']
get_line_location(int(line['codMode']),
                  line['itinerary']['Itinerary'][0]['codItinerary'],
                  line['codLine'],
                  line['itinerary']['Itinerary'][0]['stops']['StopInformation'][0]['codStop'],
                  line['itinerary']['Itinerary'][0]['direction'])
Parameters:
  • mode_cod (int) – Id of a public transport. Use constants.TransportModes to easily select transport modes ids.
  • cod_itinerary (int) – Itinerary of that line.
  • cod_line (str) – Line id. Use utils.create_line_cod to create this id easily.
  • cod_stop (str) – Stop id. In this case this is needed as a formality. Any stop of that line gives the same result.
  • direction (int) – Direction of a itinerary.
Returns:

citram_api.api.lines.lines.get_lines_by_line_code(cod_line)

Returns the line specified. This method results in a brief description of the line.

Example:

get_lines_by_line_code(create_line_cod(TransportModes.METRO.value, 10))
Parameters:cod_line (str) – Line id. Use utils.create_line_cod to create this id easily.
Returns:The line of the line id specified. The returned dictionary look likes the following example:
{
    'lines': {
        'Line': {
            'codLine': '4__10___',
            'shortDescription': '10',
            'description': 'Hospital del Norte-Puerta del Sur',
            'codMode': '4',
            'updateDate': '2019-03-22T17:21:37+01:00',
            'updateKmlDate': '2016-06-01T17:04:00+02:00',
            'nightService': 0,
            'active': True,
            'shortItinerary': {
                'Itinerary': [{
                    'codItinerary': '4__10____1__IT_1',
                    'name': 'Hospital del Norte - Puerta del Sur',
                    'direction': 1,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/metrokmz/M4_L10a_S1_TRAMO.kmz#http://www.citram.es:8080/kml/itinerarios/20160601_1704/metrokmz/M4_L10b_S1_TRAMO.kmz',
                    'stops': {}
                }, {
                    'codItinerary': '4__10____2__IT_1',
                    'name': 'Puerta del Sur - Hospital del Norte',
                    'direction': 2,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/metrokmz/M4_L10a_S2_TRAMO.kmz#http://www.citram.es:8080/kml/itinerarios/20160601_1704/metrokmz/M4_L10b_S2_TRAMO.kmz',
                    'stops': {}
                }]
            },
            'URLLine': 'http://www.crtm.es/tu-transporte-publico/metro/lineas/4__10___.aspx',
            'colorLine': '#005AA9',
            'text_colorLine': '#FFFFFF',
            'companyCode': '200'
        }
    }
}
citram_api.api.lines.lines.get_lines_by_mode(mode_cod)

Get transport lines of a transport mode given a transport mode id.

You can use constants.TransportModes to get the available transport modes ids.

Example:

get_lines_by_mode(TransportModes.CERCANIAS.value)
Parameters:mode_cod (int) – Id of a public transport. Use constants.TransportModes to easily select transport modes ids.
Return dict:Lines of the transport specified. The returned dictionary look likes the following example:
{
    'lines': {
        'Line': [{
            'codLine': '5__C1___',
            'shortDescription': 'C1',
            'description': 'P.Pío-Atocha-Recoletos-Chamartín-Aeropuerto T4',
            'codMode': '5',
            'updateDate': '2019-11-19T14:30:28+01:00',
            'updateKmlDate': '2019-11-19T14:25:06+01:00',
            'nightService': 0,
            'active': True,
            'shortItinerary': {
                'Itinerary': [{
                    'codItinerary': '5__C1____1__IT_1',
                    'name': 'P.Pío-Atocha-Recoletos-Chamartín-Aeropuerto T4',
                    'direction': 1,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20191119_1425/cercaniaskmz/M5_LC-1_S1_TRAMO.kmz',
                    'stops': {}
                }, {
                    'codItinerary': '5__C1____2__IT_1',
                    'name': 'Aeropuerto T4-Chamartín-Recoletos-Atocha-P.Pío',
                    'direction': 2,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20191119_1425/cercaniaskmz/M5_LC-1_S2_TRAMO.kmz',
                    'stops': {}
                }]
            },
            'URLLine': 'http://www.crtm.es/tu-transporte-publico/cercanias-renfe/lineas/5__1___.aspx',
            'colorLine': '#4FB0E5',
            'text_colorLine': '#FFFFFF',
            'companyCode': '301'
        },
        ...
        ]
    }
}
citram_api.api.lines.lines.get_lines_by_municipality(cod_municipality, cod_mode=None)

Get transport lines of a transport mode given a municipality id.

You can use constants.Municipalities to get the available municipalities ids.

Example:

get_lines_by_municipality(Municipalities.FUENLABRADA.value)
Parameters:
  • cod_municipality (int) – Id of a municipality. Use constants.Municipalities to easily select transport modes ids.
  • cod_mode (int) – If specified, the results will be filtered, returning only lines of that transport mode. Optional, default: None (No transport mode filtering).
Return dict:

Lines of the municipality specified. The returned dictionary look likes the following example:

{
    'lines': {
        'Line': [{
            'codLine': '4__12___',
            'shortDescription': '12',
            'description': 'MetroSur',
            'codMode': '4',
            'updateDate': '2019-03-22T17:21:37+01:00',
            'updateKmlDate': '2016-06-01T17:04:00+02:00',
            'nightService': 0,
            'active': True,
            'shortItinerary': {
                'Itinerary': [{
                    'codItinerary': '4__12____1__IT_1',
                    'name': 'METROSUR (ANDEN-1)',
                    'direction': 1,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/metrokmz/M4_L12-1_S1_TRAMO.kmz',
                    'stops': {}
                }, {
                    'codItinerary': '4__12____2__IT_1',
                    'name': 'METROSUR (ANDEN-2)',
                    'direction': 2,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/metrokmz/M4_L12-2_S1_TRAMO.kmz',
                    'stops': {}
                }]
            },
            'URLLine': 'http://www.crtm.es/tu-transporte-publico/metro/lineas/4__12___.aspx',
            'colorLine': '#A49800',
            'text_colorLine': '#FFFFFF',
            'companyCode': '200'
        }, {
            'codLine': '5__C5___',
            'shortDescription': 'C5',
            'description': 'Móstoles-El Soto-Atocha-Fuenlabrada-Humanes',
            'codMode': '5',
            'updateDate': '2019-11-19T14:30:28+01:00',
            'updateKmlDate': '2019-11-19T14:25:06+01:00',
            'nightService': 0,
            'active': True,
            'shortItinerary': {
                'Itinerary': [{
                    'codItinerary': '5__C5____1__IT_1',
                    'name': 'Móstoles El Soto-Atocha-Fuenlabrada-Humanes',
                    'direction': 1,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20191119_1425/cercaniaskmz/M5_LC-5_S1_TRAMO.kmz',
                    'stops': {}
                }, {
                    'codItinerary': '5__C5____2__IT_1',
                    'name': 'Humanes-Fuenlabrada-Atocha-Móstoles El Soto',
                    'direction': 2,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20191119_1425/cercaniaskmz/M5_LC-5_S2_TRAMO.kmz',
                    'stops': {}
                }]
            },
            'URLLine': 'http://www.crtm.es/tu-transporte-publico/cercanias-renfe/lineas/5__5___.aspx',
            'colorLine': '#F9BA13',
            'text_colorLine': '#FFFFFF',
            'companyCode': '301'
        }, {
            'codLine': '8__455___',
            'shortDescription': '455',
            'description': '455-PINTO - GETAFE',
            'codMode': '8',
            'updateDate': '2018-05-10T15:25:50+02:00',
            'updateKmlDate': '2016-06-01T17:04:00+02:00',
            'nightService': 0,
            'active': True,
            'shortItinerary': {
                'Itinerary': [{
                    'codItinerary': '8__455____1_-_IT_1',
                    'name': '455 GETAFE',
                    'direction': 1,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/interurbanoskmz/M8_L455_S1_obs[-]_TRAMO.kmz',
                    'stops': {}
                }, {
                    'codItinerary': '8__455____1_a._IT_2',
                    'name': '455 GETAFE',
                    'direction': 1,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/interurbanoskmz/M8_L455_S1_obs[a.]_TRAMO.kmz',
                    'stops': {}
                }, {
                    'codItinerary': '8__455____1_am_IT_2',
                    'name': 'Hasta ambulatorio de Getafe',
                    'direction': 1,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/interurbanoskmz/M8_L455_S1_obs[am]_TRAMO.kmz',
                    'stops': {}
                }, {
                    'codItinerary': '8__455____1_h._IT_2',
                    'name': 'Hasta/desde hospital de Getafe',
                    'direction': 1,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/interurbanoskmz/M8_L455_S1_obs[h.]_TRAMO.kmz',
                    'stops': {}
                }, {
                    'codItinerary': '8__455____2_h._IT_2',
                    'name': 'Hasta/desde hospital de Getafe',
                    'direction': 2,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/interurbanoskmz/M8_L455_S2_obs[h.]_TRAMO.kmz',
                    'stops': {}
                }, {
                    'codItinerary': '8__455____2_jc_IT_2',
                    'name': 'Desde Avda. Juan de la Cierva, 28',
                    'direction': 2,
                    'kml': 'http://www.citram.es:8080/kml/itinerarios/20160601_1704/interurbanoskmz/M8_L455_S2_obs[jc]_TRAMO.kmz',
                    'stops': {}
                }]
            },
            'URLLine': 'http://www.crtm.es/tu-transporte-publico/autobuses-interurbanos/lineas/8__455___.aspx',
            'colorLine': '#8EBF42',
            'text_colorLine': '#FFFFFF',
            'companyCode': '078'
        },
        ...
        ]
    }
}
citram_api.api.lines.lines.get_lines_timeplanning(cod_line)

Timeplanning of the specified line id.

Example:

get_lines_timeplanning(create_line_cod(TransportModes.METRO.value, 10))
Parameters:cod_line (str) – Line id. Use utils.create_line_cod to create this id easily.
Returns:Timeplanning of the line id specified.

Module contents