Api for MetroValencia.
Project description
MetroValencia
Python module that retrieves MetroValencia stations details and train's times for a given station.
Data from Portal de datos abiertos del Ayuntamiento de València and Geoportal València.
Usage
Retrieve information about upcoming train arrivals at a specific station:
import metrovalencia
# get upcoming arrivals for stop 15
response = metrovalencia.get_arrivals(15)
print(response)
Output:
[
{'line': 3, 'destination': 'Aeroport', 'arrival_time': 108},
{'line': 5, 'destination': 'Marítim', 'arrival_time': 108},
{'line': 5, 'destination': 'Marítim', 'arrival_time': 131},
{'line': 3, 'destination': 'Aeroport', 'arrival_time': 159},
{'line': 7, 'destination': 'Torrent Avinguda', 'arrival_time': 228},
{'line': 7, 'destination': 'Torrent Avinguda', 'arrival_time': 258},
{'line': 3, 'destination': 'Rafelbunyol', 'arrival_time': 468},
{'line': 3, 'destination': 'Rafelbunyol', 'arrival_time': 474},
{'line': 9, 'destination': 'Av. del Cid', 'arrival_time': 528},
{'line': 3, 'destination': 'Av. del Cid', 'arrival_time': 569}
]
Retrieve information about train stations:
import metrovalencia
# get list of stations
response = metrovalencia.get_stations()
print(response)
Output:
[
{'id': 95, 'name': 'Marxalenes', 'lines': [4], 'location': [39.48797229915813, -0.3838368950525468]},
{'id': 55, 'name': 'Empalme', 'lines': [1, 2, 4], 'location': [39.499576608331175, -0.40210834198203727]},
...
{'id': 101, 'name': 'La Granja', 'lines': [4], 'location': [39.50403217479327, -0.4124779998061252]},
{'id': 102, 'name': 'Sant Joan', 'lines': [4], 'location': [39.50529102481966, -0.41632398912246604]}
]
Retrieve information about closest stations to given coordinates:
import metrovalencia
# get closest station to coordinates
response = metrovalencia.get_closest_stations([39.467520, -0.377058], n=2)
print(response)
Output:
[
{'id': 16, 'name': 'Xàtiva', 'lines': [3, 5, 9], 'location': [39.46718601400712, -0.377375006091083]},
{'id': 190, 'name': 'Alacant', 'lines': [10], 'location': [39.46472103939357, -0.37747700051225186]}
]
cli
The repo also includes a python cli with a working example
$ metrovalencia_cli -h
usage: MetroValencia [-h] [-l] [-c coordinates] [stationid]
This is a cli for using MetroValencia python API
positional arguments:
stationid Id of the station to retrieve times
options:
-h, --help show this help message and exit
-l List stations
-c coordinates Show closest station to coordinates in format latitude,longitude
$ metrovalencia_cli -l
Marxalenes (95)
Lines: [4]
Location: [39.48797229915813, -0.3838368950525468]
Empalme (55)
Lines: [1, 2, 4]
Location: [39.499576608331175, -0.40210834198203727]
...
Sant joan (102)
Lines: [4]
Location: [39.50529102481966, -0.41632398912246604]
Alacant (190)
Lines: [10]
Location: [39.46472103939357, -0.37747700051225186]
$ metrovalencia_cli 117
Quart de poblet (117)
Lines: [3, 5, 9]
Location: [39.48108677099763, -0.44188055413458743]
Upcoming trains:
3 - Aeroport - 00:09
3 - Aeroport - 00:22
3 - Aeroport - 03:09
5 - Marítim - 03:09
5 - Marítim - 03:23
3 - Aeroport - 03:26
3 - Rafelbunyol - 04:09
3 - Rafelbunyol - 04:26
3 - Rafelbunyol - 09:09
3 - Rafelbunyol - 09:13
$ metrovalencia_cli -c 39.467520,-0.377058
Xàtiva (16)
Lines: [3, 5, 9]
Entrances: [[39.46749135269451, -0.3759854820376232], [39.46783056273336, -0.3776404255345655], [39.467335133630534, -0.3767647684800705], [39.4672294497781, -0.37632536078820306]]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
MetroValencia-1.2.0.tar.gz
(18.2 kB
view details)
Built Distribution
File details
Details for the file MetroValencia-1.2.0.tar.gz
.
File metadata
- Download URL: MetroValencia-1.2.0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c7db0a2bf06630f5d53ea8a233dc660d429afbaa10f3e02d10cd51c56960757 |
|
MD5 | 90e72f41e11e0ada388602f6849a12c7 |
|
BLAKE2b-256 | f8a3fbec5ee2ff4af0bf46e20e710125a91f5e74573ce7b94f3cf3f7ab3762db |
File details
Details for the file MetroValencia-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: MetroValencia-1.2.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d7d6d9c894234846c8cc954e08533892fd0fdcfbdb47363e64eb063c4539287 |
|
MD5 | 0c2b5c80647470f5ce1e006a4d6ea920 |
|
BLAKE2b-256 | 7af7758d26124be56dcc74b826b42e0a343768c7f11fe4a621e9de606a63f8a9 |