flight_radar 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/ruby.yml +3 -2
- data/.rubocop.yml +3 -15
- data/.yardopts +1 -0
- data/CHANGELOG.md +34 -0
- data/Gemfile +9 -1
- data/README.md +258 -120
- data/Rakefile +3 -3
- data/flight_radar.gemspec +22 -18
- data/lib/flight_radar/core.rb +40 -35
- data/lib/flight_radar/flight.rb +109 -73
- data/lib/flight_radar/request.rb +80 -38
- data/lib/flight_radar/version.rb +5 -0
- data/lib/flight_radar.rb +115 -39
- metadata +21 -50
data/lib/flight_radar.rb
CHANGED
|
@@ -1,89 +1,165 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
3
|
+
require_relative 'flight_radar/version'
|
|
4
|
+
require_relative 'flight_radar/core'
|
|
5
|
+
require_relative 'flight_radar/request'
|
|
6
|
+
require_relative 'flight_radar/flight'
|
|
6
7
|
|
|
7
8
|
# FlightRadar module for sending requests to FlightRadar24 API
|
|
8
9
|
module FlightRadar
|
|
9
|
-
VERSION = "0.2.0"
|
|
10
|
-
|
|
11
10
|
module_function
|
|
12
11
|
|
|
12
|
+
# Default configuration parameters for FlightRadar requests.
|
|
13
13
|
@config = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
faa: '1',
|
|
15
|
+
satellite: '1',
|
|
16
|
+
mlat: '1',
|
|
17
|
+
flarm: '1',
|
|
18
|
+
adsb: '1',
|
|
19
|
+
gnd: '1',
|
|
20
|
+
air: '1',
|
|
21
|
+
vehicles: '1',
|
|
22
|
+
estimated: '1',
|
|
23
|
+
maxage: '14400',
|
|
24
|
+
gliders: '1',
|
|
25
|
+
stats: '1',
|
|
26
|
+
limit: '5000'
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
# Retrieves a list of airlines.
|
|
30
|
+
#
|
|
31
|
+
# @return [Array] An array containing information about airlines.
|
|
29
32
|
def airlines
|
|
30
33
|
request = Request.new(Core::AIRLINES_DATA_URL, Core::JSON_HEADERS)
|
|
31
|
-
request.content[
|
|
34
|
+
request.content['rows']
|
|
32
35
|
end
|
|
33
36
|
|
|
37
|
+
# Retrieves airline logos based on IATA and ICAO codes.
|
|
38
|
+
#
|
|
39
|
+
# @param iata [String] The IATA code of the airline.
|
|
40
|
+
# @param icao [String] The ICAO code of the airline.
|
|
41
|
+
# @return [Array] An array containing URLs of airline logos.
|
|
34
42
|
def airline_logo(iata, icao)
|
|
35
43
|
first_logo_url = "#{Core::AIRLINE_LOGO_URL}#{iata}_#{icao}.png"
|
|
36
44
|
second_logo_url = "#{Core::ALTERNATIVE_AIRLINE_LOGO_URL}#{icao}_logo0.png"
|
|
37
45
|
|
|
38
|
-
#
|
|
46
|
+
# Check the availability of logos and return URLs.
|
|
39
47
|
result = []
|
|
40
48
|
first_request = Request.new(first_logo_url, Core::IMAGE_HEADERS)
|
|
41
49
|
second_request = Request.new(second_logo_url, Core::IMAGE_HEADERS)
|
|
42
|
-
result << first_logo_url if first_request.
|
|
43
|
-
result << second_logo_url if second_request.
|
|
44
|
-
|
|
50
|
+
result << first_logo_url if first_request.success?
|
|
51
|
+
result << second_logo_url if second_request.success?
|
|
52
|
+
result
|
|
45
53
|
end
|
|
46
54
|
|
|
55
|
+
# Retrieves traffic statistics for a specific airport.
|
|
56
|
+
#
|
|
57
|
+
# @param code [String] The code of the airport.
|
|
58
|
+
# @return [Hash] A hash containing traffic statistics for the specified airport.
|
|
47
59
|
def airport(code)
|
|
48
|
-
|
|
60
|
+
url = "#{Core::DATA_LIVE_BASE_URL}/airports/traffic-stats/?airport=#{code}"
|
|
61
|
+
request = Request.new(url, Core::JSON_HEADERS)
|
|
62
|
+
request.content
|
|
49
63
|
end
|
|
50
64
|
|
|
65
|
+
# Retrieves a list of airports.
|
|
66
|
+
#
|
|
67
|
+
# @return [Array] An array containing information about airports.
|
|
51
68
|
def airports
|
|
52
69
|
request = Request.new(Core::AIRPORTS_DATA_URL, Core::JSON_HEADERS)
|
|
53
|
-
request.content[
|
|
70
|
+
request.content['rows']
|
|
54
71
|
end
|
|
55
72
|
|
|
73
|
+
# Converts zone information into bounds string.
|
|
74
|
+
#
|
|
75
|
+
# @param zone [Hash] A hash containing zone information.
|
|
76
|
+
# @return [String] A string containing bounds information.
|
|
56
77
|
def bounds(zone)
|
|
57
|
-
"#{zone[
|
|
78
|
+
"#{zone['tl_y']},#{zone['br_y']},#{zone['tl_x']},#{zone['br_x']}"
|
|
58
79
|
end
|
|
59
80
|
|
|
81
|
+
# Retrieves the URL of a country flag based on the country name.
|
|
82
|
+
#
|
|
83
|
+
# @param country [String] The name of the country.
|
|
84
|
+
# @return [String] The URL of the country flag.
|
|
60
85
|
def country_flag(country)
|
|
61
|
-
"#{Core::COUNTRY_FLAG_URL}#{country.downcase.gsub(
|
|
86
|
+
"#{Core::COUNTRY_FLAG_URL}#{country.downcase.gsub(' ', '-')}.gif"
|
|
62
87
|
end
|
|
63
88
|
|
|
89
|
+
# Retrieves detailed information about a specific flight.
|
|
90
|
+
#
|
|
91
|
+
# @param flight_id [String] The ID of the flight.
|
|
92
|
+
# @return [Hash] A hash containing detailed information about the specified flight.
|
|
64
93
|
def flight_details(flight_id)
|
|
65
94
|
HTTParty.get("https://data-live.flightradar24.com/clickhandler/?flight=#{flight_id}").parsed_response
|
|
66
95
|
end
|
|
67
96
|
|
|
97
|
+
# Retrieves a list of flights based on specified parameters.
|
|
98
|
+
#
|
|
99
|
+
# @param params [Hash] (optional) Parameters for filtering flights.
|
|
100
|
+
# @return [Array] An array containing Flight objects.
|
|
68
101
|
def flights(params = {})
|
|
69
|
-
request_params = @config
|
|
102
|
+
request_params = @config.dup
|
|
70
103
|
request_params[:airline] = params[:airline] if params[:airline]
|
|
71
|
-
request_params[:bounds] = params[:bounds]
|
|
104
|
+
request_params[:bounds] = params[:bounds]&.gsub(',', '%2C')
|
|
105
|
+
|
|
106
|
+
response = Request.new(Core::REAL_TIME_FLIGHT_TRACKER_DATA_URL, Core::JSON_HEADERS, request_params).content
|
|
72
107
|
|
|
73
|
-
request = Request.new(Core::REAL_TIME_FLIGHT_TRACKER_DATA_URL, Core::JSON_HEADERS, request_params)
|
|
74
|
-
response = request.content
|
|
75
108
|
%w[full_count version stats].each { |k| response.delete(k) }
|
|
76
|
-
|
|
77
|
-
response.
|
|
78
|
-
flights.append(Flight.new(flight_id, flight_details))
|
|
79
|
-
end
|
|
80
|
-
flights
|
|
109
|
+
|
|
110
|
+
response.map { |flight_id, flight_details| Flight.new(flight_id, flight_details) }
|
|
81
111
|
end
|
|
82
112
|
|
|
113
|
+
# Retrieves information about flight tracking zones.
|
|
114
|
+
#
|
|
115
|
+
# @return [Hash] A hash containing information about flight tracking zones.
|
|
83
116
|
def zones
|
|
84
117
|
request = Request.new(Core::ZONES_DATA_URL, Core::JSON_HEADERS)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
118
|
+
content = request.content
|
|
119
|
+
content.delete('version')
|
|
120
|
+
content
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Searches for flights, airports, and airlines.
|
|
124
|
+
#
|
|
125
|
+
# @param query [String] The search query (e.g., flight number, airport code, airline name).
|
|
126
|
+
# @param limit [Integer] (optional) Maximum number of results to return (default: 50).
|
|
127
|
+
# @return [Hash] A hash containing search results grouped by type.
|
|
128
|
+
def search(query, limit = 50)
|
|
129
|
+
url = "#{Core::SEARCH_DATA_URL}?query=#{query}&limit=#{limit}"
|
|
130
|
+
request = Request.new(url, Core::JSON_HEADERS)
|
|
131
|
+
request.content
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Retrieves a list of the most tracked flights.
|
|
135
|
+
#
|
|
136
|
+
# @return [Hash] A hash containing information about the most tracked flights.
|
|
137
|
+
def most_tracked
|
|
138
|
+
request = Request.new(Core::MOST_TRACKED_URL, Core::JSON_HEADERS)
|
|
139
|
+
request.content
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Retrieves playback data for a specific flight (alias for flight_details with version parameter).
|
|
143
|
+
#
|
|
144
|
+
# @param flight_id [String] The ID of the flight.
|
|
145
|
+
# @return [Hash] A hash containing detailed playback information including flight path.
|
|
146
|
+
def flight_playback(flight_id)
|
|
147
|
+
flight_details(flight_id)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Retrieves information about a specific aircraft by registration number.
|
|
151
|
+
#
|
|
152
|
+
# @param registration [String] The aircraft registration number (e.g., "N12345").
|
|
153
|
+
# @return [Hash] A hash containing search results for the aircraft.
|
|
154
|
+
def aircraft(registration)
|
|
155
|
+
search(registration)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Retrieves fleet information for a specific airline.
|
|
159
|
+
#
|
|
160
|
+
# @param airline_code [String] The airline code (IATA or ICAO).
|
|
161
|
+
# @return [Hash] A hash containing information about the airline's fleet.
|
|
162
|
+
def airline_fleet(airline_code)
|
|
163
|
+
search(airline_code)
|
|
88
164
|
end
|
|
89
165
|
end
|
metadata
CHANGED
|
@@ -1,82 +1,49 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flight_radar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jakub Polak
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-11-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.21
|
|
20
|
-
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.21.0
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 13.1.0
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
19
|
+
version: '0.21'
|
|
20
|
+
- - "<"
|
|
39
21
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
41
|
-
|
|
42
|
-
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: 3.12.0
|
|
48
|
-
type: :development
|
|
22
|
+
version: '0.24'
|
|
23
|
+
type: :runtime
|
|
49
24
|
prerelease: false
|
|
50
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
26
|
requirements:
|
|
52
|
-
- - "
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: 3.12.0
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rubocop
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
27
|
+
- - ">="
|
|
60
28
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
62
|
-
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
29
|
+
version: '0.21'
|
|
30
|
+
- - "<"
|
|
67
31
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
69
|
-
description: '
|
|
32
|
+
version: '0.24'
|
|
33
|
+
description: 'Unofficial Ruby wrapper for Flightradar24 API. Fetch real-time flight
|
|
34
|
+
data, airport statistics, airline information, and more. For terms see: https://www.flightradar24.com/terms-and-conditions'
|
|
70
35
|
email:
|
|
71
36
|
- jakub.polak.vz@gmail.com
|
|
72
37
|
executables: []
|
|
73
38
|
extensions: []
|
|
74
39
|
extra_rdoc_files: []
|
|
75
40
|
files:
|
|
41
|
+
- ".github/dependabot.yml"
|
|
76
42
|
- ".github/workflows/ruby.yml"
|
|
77
43
|
- ".gitignore"
|
|
78
44
|
- ".rspec"
|
|
79
45
|
- ".rubocop.yml"
|
|
46
|
+
- ".yardopts"
|
|
80
47
|
- CHANGELOG.md
|
|
81
48
|
- CODE_OF_CONDUCT.md
|
|
82
49
|
- Gemfile
|
|
@@ -88,6 +55,7 @@ files:
|
|
|
88
55
|
- lib/flight_radar/core.rb
|
|
89
56
|
- lib/flight_radar/flight.rb
|
|
90
57
|
- lib/flight_radar/request.rb
|
|
58
|
+
- lib/flight_radar/version.rb
|
|
91
59
|
homepage: https://github.com/kupolak/flight_radar
|
|
92
60
|
licenses:
|
|
93
61
|
- MIT
|
|
@@ -95,6 +63,9 @@ metadata:
|
|
|
95
63
|
homepage_uri: https://github.com/kupolak/flight_radar
|
|
96
64
|
source_code_uri: https://github.com/kupolak/flight_radar
|
|
97
65
|
changelog_uri: https://github.com/kupolak/flight_radar/blob/main/CHANGELOG.md
|
|
66
|
+
bug_tracker_uri: https://github.com/kupolak/flight_radar/issues
|
|
67
|
+
documentation_uri: https://kupolak.github.io/flight_radar/
|
|
68
|
+
rubygems_mfa_required: 'true'
|
|
98
69
|
post_install_message:
|
|
99
70
|
rdoc_options: []
|
|
100
71
|
require_paths:
|
|
@@ -103,14 +74,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
103
74
|
requirements:
|
|
104
75
|
- - ">="
|
|
105
76
|
- !ruby/object:Gem::Version
|
|
106
|
-
version: 2.
|
|
77
|
+
version: 3.2.0
|
|
107
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
79
|
requirements:
|
|
109
80
|
- - ">="
|
|
110
81
|
- !ruby/object:Gem::Version
|
|
111
82
|
version: '0'
|
|
112
83
|
requirements: []
|
|
113
|
-
rubygems_version: 3.
|
|
84
|
+
rubygems_version: 3.5.22
|
|
114
85
|
signing_key:
|
|
115
86
|
specification_version: 4
|
|
116
87
|
summary: Ruby gem for fetching aircraft data from Flightradar24
|