What is PyVatsim?
PyVatsim is a Python library to interact with data from Vatsim's live datafeed, currently located at: http://data.vatsim.net/. It implements Python objects to access the underlying Vatsim data in a Pythonic way, and also parses certain data into developer friendly formats (e.g., timestamp strings into Python datetime objects).
Because Vatsim's datafeed is updated every ~15 seconds, Py-API supports configurable caching of data from the datafeed so that each access method does not fetch the datafeed (although a "force update" override exists if needed).
Status
This project is in alpha state. It currently offers full functionality to access the Vatsim live data (with time-based caching support), but further work is needed in the areas of: documentation, error handling, caching, configurability, testing.
Installation
The easiest way to install is via pip.
pip install pyvatsim
Alternatively, you can use the pyvatsim folder or liveapi.py as a package or single-file module, respectively. Make sure you have the necessary 3rd-party libraries installed with pip (at the moment, only requests is required).
How to Develop
Clone the repo and create a new Python virtual environment using requirements.txt, which should look something like:
git clone https://github.com/kengreim/PyVatsim.git
cd pyvatsim
python3 -m venv venv
./venv/Scripts/Activate
pip install -r requirements.txt
Full Documentation
TBD
Known Issues and Noteworthy Considerations
TBD
Examples
Create API object
Use default caching periods (60 seconds for METARs and 15 seconds for network data)
import pyvatsim
api = pyvatsim.VatsimLiveAPI()
Create API object with different cache TTLs
Configurable with the DATA_TTL and METAR_TTL arguments, which speciy how long network data and METAR data should be cached (in seconds), respectively
import pyvatsim
# 1 min network data cache and 5 min METAR cache
api = pyvatsim.VatsimLiveAPI(DATA_TTL=60, METAR_TTL=300)
Retrieve all pilots or controllers and iterate through them
pilots() returns a dictionary of Pilot instances with each Pilot.cid as the dictionary key
controllers() returns a dictionary of Controller instances with each Controller.cid as the dictionary key
p = api.pilots()
for cid, pilot in p.items():
# Do something here
c = api.controllers()
for cid, controller in c.items():
# Do something here
Retrieve a list of pilots or controllers based on multiple CIDs
cids argument expects either a single integer or a list of integers.
pilots(cid) returns a dictionary of Pilot instances based on exact CID matches, or None if no matches are found
controllers(cid) returns a dictionary of Controller instances based on exact CID matches, or None if no matches are found
p = api.pilots(cids=[123456, 234567, 345678])
for cid, pilot in p.items():
# Do something here
c = api.controllers(cids=[123456, 234567, 345678])
for cid, controller in c.items():
# Do something here
Retrieve a list of pilots or controllers based on one or more string regular expressions
callsigns argument expects either a single string or a list of strings. callsigns argument will be ignored if cids argument is provided, as in the example above.
pilots(callsigns) will evaluate each string as a Python regular expression and return a dictionary of Pilot instances where the Pilot's callsign matches one of the given callsign regular expressions (using re.search), or None if no matches are found
controllers(callsigns) will evaluate each string as a Python regular expression and return a dictionary of Controller instances where the Controller's callsign matches one of the given callsign regular expressions (using re.search), or None if no matches are found
p = api.pilots(callsigns=['UAL123', 'UAL', 'SWA'])
for cid, pilot in p.items():
# Do something here
# Note that last item uses regex to match OAK_CTR, OAK_41_CTR, OAK_44_CTR, etc. but not OAK_GND
c = api.controllers(callsigns=['SFO', 'SJC', 'OAK.*_CTR'])
for cid, controller in c.items():
# Do something here
Retrieve a single pilot or controller by Vatsim CID or callsign
cid argument expects an integer. callsign argument expects a string. . If both cid and callsign arguments are provided, only cid will be used.
pilot() returns a single Pilot instance based on exact CID or callsign string match (both are unique on the Vatsim network for Pilots) or None
controller() returns a single Controller instance based on exact CID or callsign string match (both are unique on the Vatsim network for Controllers) or None
p1 = api.pilot(cid=123456)
p2 = api.pilot(callsign='UAL123')
c1 = api.controller(cid=123456)
c2 = api.controller(callsign='SFO_TWR')
Retrieve all METARs
m = api.metars()
for field, metar in m.items():
# Do something
Retrieve a subset of METARs
m = api.metars(['KSFO', 'KLAX', 'KSJC'])
for field, metar in m.items():
# Do something
Retrieve a single METAR
m = api.metar('KSFO')
Access information about a pilot and their flightplan
p = api.pilots()
for cid, pilot in p.items():
if pilot.flight_plan is not None:
print('%s departed from %s and is going to %s at current altitude %i' % (pilot.callsign, pilot.flight_plan.departure, pilot.flight_plan.arrival, pilot.altitude))
else:
print('%s is at current altitude %i with no flight plan' % (pilot.callsign, pilot.altitude))
Get information about a controller
c = api.controllers()
for cid, controller in c.items():
print('%s controlling position %s on %s' % (controller.name, controller.callsign, controller.frequency))
Todo
TBD
License
Vatsim Py-API is licensed under the MIT License.
Metadata
Release files for pyvatsim 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyvatsim-0.1.2.tar.gz | 11.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyvatsim-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.3 kB
Release files / pyvatsim-0.1.2.tar.gz
| Download URL | pyvatsim-0.1.2.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
852c2a9f4ec3a32640a8f6763eb1f1fa4378201757ee6f97b0ff770aeee4d14c
|
|
BLAKE2b-256 checksum How to use checksums |
bcabf08a7c876b61538af6dc3f04bc8672f27d821c7502b23c445ca1ca2ac0e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Release files / pyvatsim-0.1.2-py3-none-any.whl
| Download URL | pyvatsim-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be7f62b35998cad50a18aa6c6bac06bcdc0dc6e1e60155521d8a54bb03eab435
|
|
BLAKE2b-256 checksum How to use checksums |
b077957d27d5b6a9b82add92cf43062cdb5bb8b8b96916415680fcba9a78e94d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for pyvatsim 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.