Overview
FlightsApiService is a core Angular service that handles all HTTP communication with the Air Tracker backend API. It provides methods to fetch live flight data and aircraft photos using Angular’s HttpClient.
This service is provided at the root level and automatically injected into other services like FlightsStoreService.
Location
Methods
getLiveFlights()
Fetches current live flight data from the backend API.Returns an Observable that emits flight data including:
time: Unix timestamp of the responseflights: Array of flight objects with position, velocity, and metadatacacheAgeMs: Age of cached data in millisecondspollingIntervalMs: Recommended polling intervalnextUpdateInMs: Time until next data update
Unix timestamp of the response
Array of flight objects containing position, velocity, and aircraft metadata
Age of the cached data in milliseconds
Recommended polling interval in milliseconds
Time until next data update in milliseconds
GET /flights/live
Usage Example:
getPhotosByIcao24()
Fetches aircraft photos for a specific aircraft identified by its ICAO 24-bit address.The ICAO 24-bit address (unique aircraft identifier) to fetch photos for
Returns an Observable that emits aircraft photo data including:
thumbnailUrl: URL to thumbnail imagelargeUrl: URL to full-size imagelink: Link to photo source pagephotographer: Name of the photographerattribution: Attribution text
GET /aircraft-photos/{icao24}
Usage Example:
Real-World Usage
Fromflights-shell.component.ts:109-131, here’s how the service is used in production:
Dependencies
The service automatically injects:HttpClient- For making HTTP requestsApiConfigService- For retrieving the base API URL
See Also
- FlightsStoreService - State management that uses this API service
- Flight Data Model - Structure of flight data returned by the API
