Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Live Flight Tracking API | Built with Node.js and Express

License

NotificationsYou must be signed in to change notification settings

thomasmercuriot/node-flight-radar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkedinMade with Node.jsLast CommitGitHub contributorsmaintained - noPRs Welcome

Flight Tracking API

Introduction

Welcome to my first personal coding project !✈️ This API is designed to retrieve live flight tracking data and serve it to aReact front-end with the goal of building a functional clone of one of my favorite apps :FlightRadar24. I've always been passionate about aviation, so creating my own flight tracking app from scratch has been an exciting challenge and a fantastic learning experience. You can check out the React front-end repositoryhere.

I started this project to teach myself the basics ofNode.js andExpress.js, and it’s been a rewarding journey — combining my passion for aviation with learning to code ! Although I’m not planning to actively maintain this repository for now, I’m very open to feedback1 and contributions — I'd love to hear from others and continue improving this project as I grow as a developer. With time and experience, I hope to revisit this project and turn this into a polished flight tracking app I can use while plane spotting2 !

Thanks for checking out my project, and happy coding ! 🚀

Getting Started

If you'd like to use this project yourself or contribute by suggesting new features, feel free to clone or fork the repository and submit a pull request. Here's how to get started :

Cloning the Project

  1. Clone the repository

To create a local copy of this project on your machine, run the following command in your terminal :

git clone git@github.com:thomasmercuriot/node-flight-radar.git
  1. Navigate to the project directory
cd node-flight-radar
  1. Install the dependencies

Make sure you haveNode.js installed. Then, install the required dependencies by running :

npm install
  1. Start the Server

Run the following command to start the Node.js server :

npm start

Your API should now be running locally ! 🎉

Forking the Project

If you'd like to make your own changes to the project, you can fork the repository :

  1. Fork this repository

Click on theFork button at the top right of this repository to create a copy under your own GitHub account.

  1. Clone your forked repository

Use the following command to clone the forked repo to your local machine :

git clone git@github.com:thomasmercuriot/node-flight-radar.git
  1. Follow the same steps as above to install dependencies and run the project.

Submitting a Pull Request (PR)

If you want to contribute by suggesting a feature or fixing a bug, here's how you can submit a pull request (PR) :

  1. Create a new branch

It's a good practice to create a new branch for each feature or bug fix :

git checkout -b feature-or-fix-name
  1. Make your changes

Develop your feature or fix and commit the changes.

git add .git commit -m "Describe the feature or fix here"
  1. Push to your forked repository
git push origin feature-or-fix-name
  1. Open a pull request

Go to the original repository on GitHub and click theNew Pull Request button. Select your branch and submit your PR with a brief description of the changes.

I'll review your submission as soon as possible. Thanks in advance for contributing ! 🚀

Environment Variables

Environment variableDefault value
PORT8000

API Endpoints

GET /api

Retrieves live airspace data for a specified geographic area using theOpenSky Network REST API, which collects data from the ADS-B3 Exchange. The data is filtered to include only the relevant information needed for this project. The geographic area is defined by box coordinates, which are passed as query parameters from the front-end.

ParametersTypeDescriptionExample
laminFloatMinimum Latitude (Box Coordinates)48.6278
lominFloatMinimum Longitude (Box Coordinates)2.2547
lamaxFloatMaximum Latitude (Box Coordinates)49.3854
lomaxFloatMaximum Longitude (Box Coordinates)2.8453

Expected Output :

GET /api?lamin=48.6278&lomin=2.2547&lamax=49.3854&lomax=2.8453
[{"icao24":"39de47","callsign":"TVF81BW","last_contact":1729521120,"longitude":2.782,"latitude":48.7072,"baro_altitude":1958.34,"velocity":146.03,"true_track":42.29,"vertical_rate":-8.45,"geo_altitude":2110.74,"squawk":"1465"},{    ...}]

Where each object represents a flight currently in the specified geographic area.

IndexPropertyTypeDescription
0icao24StringUnique ICAO 24-bit address of the transponder in hex string representation
1callsignStringCallsign of the vehicle (8 chars)
2last_contactIntegerUnix timestamp (seconds) for the last update
3longitudeFloatWGS-84 longitude in decimal degrees
4latitudeFloatWGS-84 latitude in decimal degrees
5baro_altitudeFloatBarometric altitude in meters
6velocityFloatVelocity over ground in m/s
7true_trackFloatTrue track in decimal degrees clockwise from north (north=0°)
8vertical_rateFloatVertical rate in m/s
9geo_altitudeFloatGeometric altitude in meters
10squawkStringThe transponder code

GET /api/registration

Converts a given ICAO 24-bit address and returns the corresponding aircraft registration. The registration number is scraped from theRadarBox website usingAxios andCheerio.

Warning

Web scraping is generally not recommended for several reasons :

  1. Legal and Ethical Concerns : Many websites have terms of service that explicitly prohibit scraping, and scraping without permission can violate these terms, leading to potential legal action.
  2. Server Load : Scraping can place a significant load on a website's server, potentially disrupting service for other users or even leading to IP bans if the site detects excessive requests.
  3. Data Integrity : Websites can change their structure or data format at any time, which may break your scraping logic and lead to inaccurate or incomplete data.

This code is intended for educational purposes only, as part of a personal project to practice and improve programming skills. This application is not intended for public use. If you plan to scrape data for more than personal use, it's highly recommended to seek permission from the website owner or use official APIs if available.

ParametersTypeDescriptionExample
icao24StringICAO 24-bit address3949EE

Expected Output :

GET /api/registration/3949EE
{"registration":"F-GSPO"}
IndexPropertyTypeDescription
0registrationStringCorresponding aircraft registration for a given ICAO 24-bit address

GET /api/photo

Returns a high-definition image URL of an aircraft based on its registration number, along with detailed information about the photo and the airframe. The program selects a random photo from the available images for the given registration onAirHistory.net, ensuring a more engaging experience for users who may track the same aircraft multiple times.

ParametersTypeDescriptionExample
registrationStringSelected aircraft's registrationF-GSPO

Expected Output :

GET /api/photo/F-GSPO
{"photo":{"photoUrl":"https://www.airhistory.net/photos/0413575.jpg","photoData":{"registration":"F-GSPO","aircraftType":"Boeing 777-228/ER","locationAirport":"Paris - Charles de Gaulle (LFPG / CDG)","locationCountry":"France","date":"25 March 2011","photographer":"Freek Blokzijl"}}}
https://www.airhistory.net/photos/0413575.jpg

F-GSPO

F-GSPO - Photo by Freek Blokzijl

IndexPropertyTypeDescription
0photoUrlStringURL of the aircraft photo
1photoDataObjectContains detailed information about the aircraft and the photo
1.1registrationStringAircraft registration number
1.2aircraftTypeStringAircraft model and type
1.3locationAirportStringThe name and code of the airport where the photo was taken
1.4locationCountryStringCountry where the photo was taken
1.5dateStringDate the photo was taken
1.6photographerStringName of the photographer who took the photo

In certain cases, the output may also include the following data :

IndexPropertyTypeDescription
1.7alternateRegistrationStringPrevious known registration for the same airframe
1.8aircraftLiveryStringSpecial aircraft livery

GET /api/aircraft

Returns detailed live flight-tracking data for a given registration as well as information about the aircraft and its recent flight history. The relevant data is scraped from theRadarBox website usingAxios andCheerio.

ParametersTypeDescriptionExample
registrationStringSelected aircraft's registrationF-GSPO

Expected Output :

GET /api/aircraft/F-GSPO
{"registration":"F-GSPO","data":{"overview":{"registration":"F-GSPO","callsign":"AF201 / AFR201","airline":"Air France","duration":"12h32m","distance":"8191 km","operationDays":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},"origin":{"city":"Beijing","code":"(PEK / ZBAA)","airport":"Beijing Capital International Airport"},"destination":{"city":"Paris","code":"(CDG / LFPG)","airport":"Paris - Charles de Gaulle International Airport"},"departure":{"date":"Monday, October 21 2024","scheduled":"23:00","departed":"23:32","timezone":"China Standard Time (UTC+08:00)","terminal":"2","gate":"14","status":"Delayed"},"arrival":{"date":"Tuesday, October 22 2024","scheduled":"05:55","estimated":"05:32","timezone":"Central European Summer Time (UTC+02:00)","terminal":"2E","gate":"-","status":"On time"},"progress":{"percentage":41,"status":"landing in 7h 59m"},"aircraft":{"type":"Boeing 777-228ER","transponder":"3949EE","serial":"30614/320"},"thisFlight":{"flightNumber":"AF201"},"otherFlights":[{"date":"2024 21 Oct","callsign":"AF201","airlineLogo":"https://cdn.radarbox.com/airlines/sq/AFR.png","origin":"Beijing (PEK/ZBAA)","scheduledDeparture":"23:00 CST","actualDeparture":"23:32 CST","destination":"Paris (CDG/LFPG)","scheduledArrival":"05:55 CEST","delay":"On time","status":"Est. Arrival 05:32 CEST","duration":"12h32m"},{"date":"2024 20 Oct","callsign":"AF202","airlineLogo":"https://cdn.radarbox.com/airlines/sq/AFR.png","origin":"Paris (CDG/LFPG)","scheduledDeparture":"22:00 CEST","actualDeparture":"22:13 CEST","destination":"Beijing (PEK/ZBAA)","scheduledArrival":"15:25 CST","delay":"On time","status":"Landed 15:22 CST","duration":"10h43m"},{                ...}]}}
IndexPropertyTypeDescription
0registrationStringAircraft registration number
1dataObjectMain container for the flight data
1.1data.overviewObjectGeneral overview of the current flight
1.1.1data.overview.registrationStringAircraft registration number
1.1.2data.overview.callsignStringCurrent flight callsign
1.1.3data.overview.airlineStringAirline name
1.1.4data.overview.durationStringAverage current flight duration in hours and minutes
1.1.5data.overview.distanceStringAverage current flight distance covered in kilometers
1.1.6data.overview.operationDaysArray[String]Days of the week when the current flight operates
1.2data.originObjectDetails of the current flight departure location
1.2.1data.origin.cityStringCurrent flight departure city
1.2.2data.origin.codeStringCurrent flight departure airport ICAO/IATA code
1.2.3data.origin.airportStringFull name of the current flight departure airport
1.3data.destinationObjectDetails of the current flight arrival location
1.3.1data.destination.cityStringCurrent flight arrival city
1.3.2data.destination.codeStringCurrent flight arrival airport ICAO/IATA code
1.3.3data.destination.airportStringFull name of the current flight arrival airport
1.4data.departureObjectInformation about the current flight departure
1.4.1data.departure.dateStringCurrent flight scheduled departure date
1.4.2data.departure.scheduledStringCurrent flight scheduled departure time
1.4.3data.departure.departedStringCurrent flight actual departure time
1.4.4data.departure.timezoneStringCurrent flight departure timezone and UTC offset
1.4.5data.departure.terminalStringCurrent flight departure terminal
1.4.6data.departure.gateStringCurrent flight departure gate
1.4.7data.departure.statusStringCurrent flight departure status (e.g. On Time, Delayed, Cancelled)
1.5data.arrivalObjectInformation about the current flight arrival
1.5.1data.arrival.dateStringCurrent flight scheduled arrival date
1.5.2data.arrival.scheduledStringCurrent flight scheduled arrival time
1.5.3data.arrival.estimatedStringCurrent flight estimated arrival time
1.5.4data.arrival.timezoneStringCurrent flight arrival timezone and UTC offset
1.5.5data.arrival.terminalStringCurrent flight arrival terminal
1.5.6data.arrival.gateStringCurrent flight arrival gate
1.5.7data.arrival.statusStringCurrent flight arrival status (e.g. On Time, Delayed, Cancelled)
1.6data.progressObjectCurrent flight progress
1.6.1data.progress.percentageIntegerPercentage of the current flight completed
1.6.2data.progress.statusStringStatus of the current flight progress (e.g. landing in 7h 59m)
1.7data.aircraftObjectDetails about the aircraft
1.7.1data.aircraft.typeStringAircraft type
1.7.2data.aircraft.transponderStringAircraft’s ICAO 24-bit transponder code
1.7.3data.aircraft.serialStringSerial number of the aircraft
1.8data.thisFlightObjectDetails specific to the current flight
1.8.1data.thisFlight.flightNumberStringCurrent flight number
1.9data.otherFlightsArray[Object]Aircraft flight history
1.9.1data.otherFlights[].dateStringDate of the flight
1.9.2data.otherFlights[].callsignStringCallsign for the flight
1.9.3data.otherFlights[].airlineLogoStringURL to the airline logo
1.9.4data.otherFlights[].originStringOrigin city and airport code
1.9.5data.otherFlights[].scheduledDepartureStringScheduled departure time with timezone
1.9.6data.otherFlights[].actualDepartureStringActual departure time with timezone
1.9.7data.otherFlights[].destinationStringDestination city and airport code
1.9.8data.otherFlights[].scheduledArrivalStringScheduled arrival time with timezone
1.9.9data.otherFlights[].delayStringDelay status
1.9.10data.otherFlights[].statusStringStatus of the flight (e.g. Landed)
1.9.11data.otherFlights[].durationStringFlight duration

GET /api/flights

Returns the recent flight history for a given callsign/flight number. The relevant data is scraped from theRadarBox website usingAxios andCheerio.

ParametersTypeDescriptionExample
callsignStringSelected flight's callsignAF201

Expected Output :

GET /api/flights/AF201
{"flightHistoryData":[{"date":"2024 23 Oct","callsign":"AF201","origin":"Beijing (PEK/ZBAA)","scheduledDeparture":"23:00 CST","actualDeparture":"","destination":"Paris (CDG/LFPG)","scheduledArrival":"05:55 CEST","aircraftType":"B772","delay":"On time","status":"Scheduled","duration":"12h55m"},{"date":"2024 21 Oct","callsign":"AF201","origin":"Beijing (PEK/ZBAA)","scheduledDeparture":"23:00 CST","actualDeparture":"23:32 CST","destination":"Paris (CDG/LFPG)","scheduledArrival":"05:55 CEST","aircraftType":"B772 (F-GSPO)","delay":"On time","status":"Est. Arrival 05:34 CEST","duration":"12h34m"},{"date":"2024 20 Oct","callsign":"AF201","origin":"Beijing (PEK/ZBAA)","scheduledDeparture":"23:00 CST","actualDeparture":"23:15 CST","destination":"Paris (CDG/LFPG)","scheduledArrival":"05:55 CEST","aircraftType":"B772 (F-GSPJ)","delay":"On time","status":"Landed 06:03 CEST","duration":"12h28m"},{            ...}]}

This example includes data for flights in the past, present, and upcoming schedules.

IndexPropertyTypeDescription
0flightHistoryDataArray[Object]List of historical flight data entries (Past, Present, and Future)
0.1flightHistoryData[].dateStringDate of the flight
0.2flightHistoryData[].callsignStringSelected flight's callsign
0.3flightHistoryData[].originStringFlight origin city and airport ICAO/IATA code
0.4flightHistoryData[].scheduledDepartureStringFlight scheduled departure time and local time zone
0.5flightHistoryData[].actualDepartureStringFlight actual departure time and local time zone
0.6flightHistoryData[].destinationStringFlight destination city and airport ICAO/IATA code
0.7flightHistoryData[].scheduledArrivalStringFlight scheduled arrival time and local time zone
0.8flightHistoryData[].aircraftTypeStringFlight aircraft type and registration
0.9flightHistoryData[].delayStringFlight delay status
0.10flightHistoryData[].statusStringFlight status (e.g. Scheduled, Est. Arrival, Landed)
0.11flightHistoryData[].durationStringTotal flight duration

License

This project is licensed under theMIT License.

Footnotes

  1. Feel free to connect with me onLinkedIn and share your feedback.

  2. Wikipedia : Aircraft Spotting

  3. Wikipedia : Automatic Dependant Surveillance Broadcast (ADS-B)

About

Live Flight Tracking API | Built with Node.js and Express

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp