Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
liveflight/airplaneslive.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
20 lines (13 sloc)
398 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from pprint import pprint | |
def get_plane_data(icao_code): | |
base_url = "https://api.airplanes.live/v2/" | |
api_url = "icao/" | |
url = f"{base_url}{api_url}{icao_code}" | |
# Make the request | |
req = requests.get(url) | |
jsondata = req.json() # Return JSON data from response | |
flight = jsondata["ac"][0] | |
pprint(flight) | |
return flight | |
get_plane_data("4BAA84") |