Tài liệu API Hop
Tham chiếu Google Flights
Tìm chuyến bay, gợi ý sân bay và ưu đãi trên Google Flights.
Giới hạn đồng thời
AI và Data mỗi loại dùng chung một nhóm lượt đồng thời trên toàn tài khoản: mặc định 5 AI / 2 Data, tùy theo gói đăng ký. Giới hạn riêng của endpoint vẫn chịu giới hạn tổng của loại API. Khi đạt bất kỳ giới hạn nào, API trả về HTTP 429. Tác vụ bất đồng bộ giữ chỗ đến khi thực thi kết thúc.
GET /v1/google-flights/search GET /v1/google-flights/autocomplete GET /v1/google-flights/deals Tìm chuyến bay, gợi ý sân bay và ưu đãi trên Google Flights.
Xác thực và phí
Giá mặc định là $0.0003 (300 credits) cho mỗi yêu cầu thành công. Dùng khóa API API Hop. Quyền truy cập phụ thuộc cổng đang bật và quyền khóa. Xem danh mục và tài khoản để biết giá mỗi yêu cầu thành công; ưu tiên giá tài khoản. Kết quả rỗng thành công vẫn tính phí. Lỗi giải phóng khoản giữ trước. Hết hạn sau 60 giây, không tự thử lại hay phân trang. Lỗi quyết toán không gọi lại nhà cung cấp.
Authorization: Bearer YOUR_API_KEYGoogle Flights: Tìm chuyến bay
GET https://api.apihop.ai/v1/google-flights/search
Tham số
| Trường | Kiểu | Giới hạn | Ví dụ |
|---|---|---|---|
departure_id | string | Mã sân bay hoặc thành phố khởi hành (departure_id); departure_id: optional; ^(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+)(?:,(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+))*$ | JFK |
arrival_id | string | Mã sân bay, thành phố hoặc vùng đến (arrival_id); arrival_id: optional; ^(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+)(?:,(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+))*$ | LAX |
outbound_date | string | Ngày đi (YYYY-MM-DD) hoặc khoảng ngày được hỗ trợ (outbound_date); outbound_date: optional; ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ | 2026-12-12 |
return_date | string | Ngày đi (YYYY-MM-DD) hoặc khoảng ngày được hỗ trợ (return_date); return_date: optional; ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ | - |
adults | integer | Số người lớn (adults); adults: optional; min: 1; max: 9 | 1 |
children | integer | Số trẻ em (children); children: optional; min: 0; max: 8 | 0 |
infants_in_seat | integer | Số trẻ sơ sinh (infants_in_seat); infants_in_seat: optional; min: 0; max: 8 | 0 |
infants_on_lap | integer | Trẻ sơ sinh ngồi trên đùi (infants_on_lap); infants_on_lap: optional; min: 0; max: 8 | 0 |
travel_class | string | Hạng ghế (travel_class); travel_class: optional; economy, premium_economy, business, first | economy |
sort_by | string | Sắp xếp; sort_by: optional; top_flights, price, departure_time, arrival_time, duration, emissions | top_flights |
stops | integer | Bộ lọc chuyến bay hoặc điểm đến (stops); stops: optional; min: 0; max: 3 | 0 |
include_airlines | string | Bộ lọc hãng bay hoặc liên minh (include_airlines); include_airlines: optional; UTF-8 bytes: 1000; ^(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD)(?:,(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD))*$ | - |
exclude_airlines | string | Bộ lọc hãng bay hoặc liên minh (exclude_airlines); exclude_airlines: optional; UTF-8 bytes: 1000; ^(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD)(?:,(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD))*$ | - |
bags | integer | Bộ lọc chuyến bay hoặc điểm đến (bags); bags: optional; min: 0; max: 9 | 0 |
max_price | integer | Giá tối đa (max_price); max_price: optional; min: 1; max: 2147483647 | 1 |
outbound_times | string | Bộ lọc chuyến bay hoặc điểm đến (outbound_times); outbound_times: optional; UTF-8 bytes: 11; ^(?:[0-9]|1[0-9]|2[0-3])(?:,(?:[0-9]|1[0-9]|2[0-3])){1,3}$ | - |
return_times | string | Bộ lọc chuyến bay hoặc điểm đến (return_times); return_times: optional; UTF-8 bytes: 11; ^(?:[0-9]|1[0-9]|2[0-3])(?:,(?:[0-9]|1[0-9]|2[0-3])){1,3}$ | - |
emissions | integer | Bộ lọc chuyến bay hoặc điểm đến (emissions); emissions: optional; 1 | 1 |
exclude_conns | string | Bộ lọc chuyến bay hoặc điểm đến (exclude_conns); exclude_conns: optional; UTF-8 bytes: 1000; ^[A-Z]{3}(?:,[A-Z]{3})*$ | - |
max_duration | integer | Bộ lọc thời lượng chuyến đi (max_duration); max_duration: optional; min: 1; max: 2147483647 | 1 |
show_hidden | boolean | Bộ lọc chuyến bay hoặc điểm đến (show_hidden); show_hidden: optional | true |
exclude_basic | boolean | Bộ lọc chuyến bay hoặc điểm đến (exclude_basic); exclude_basic: optional | true |
type | integer | Bộ lọc chuyến bay hoặc điểm đến (type); type: optional; 1, 2, 3 | 1 |
multi_city_json | string | Hành trình JSON (multi_city_json); multi_city_json: optional; UTF-8 bytes: 16384 | - |
layover_duration | string | Bộ lọc thời lượng chuyến đi (layover_duration); layover_duration: optional; UTF-8 bytes: 21; ^[0-9]{1,10},[0-9]{1,10}$ | - |
selected_flights_json | string | Hành trình JSON (selected_flights_json); selected_flights_json: optional; UTF-8 bytes: 16384 | - |
departure_token | string | Mã lựa chọn từ phản hồi mới nhất (departure_token); departure_token: optional; UTF-8 bytes: 32768 | - |
booking_token | string | Mã lựa chọn từ phản hồi mới nhất (booking_token); booking_token: optional; UTF-8 bytes: 32768 | - |
deep_search | boolean | Bộ lọc chuyến bay hoặc điểm đến (deep_search); deep_search: optional | true |
currency | string | Mã tiền tệ (currency); currency: optional; ALL, DZD, ARS, AMD, AWG, AUD, AZN, BSD, BHD, BYN, BMD, BAM, BRL, GBP, BGN, XPF, CAD, CLP, CNY, COP, CRC, CUP, CZK, DKK, DOP, EGP, EUR, GEL, HKD, HUF, ISK, INR, IDR, IRR, ILS, JMD, JPY, JOD, KZT, KWD, LBP, MKD, MYR, MXN, MDL, MAD, TWD, NZD, NOK, OMR, PKR, PAB, PEN, PHP, PLN, QAR, RON, RUB, SAR, RSD, SGD, ZAR, KRW, SEK, CHF, THB, TRY, USD, UAH, AED, VND; ^[A-Z]{3}$ | USD |
country | string | Mã quốc gia hoặc cửa hàng (country); country: optional; ^[A-Za-z]{2}$ | - |
language | string | Ngôn ngữ; language: optional | - |
limit | integer | Giới hạn kết quả; limit: optional; min: 1; max: 100 | 1 |
device | string | Thiết bị; device: optional; desktop, mobile, tablet | desktop |
zero_trace | boolean | Không lưu trữ phản hồi; zero_trace: optional | true |
Kiểm tra
Chỉ nhận tham số truy vấn, không có phần thân. Từ chối giá trị lạ, trùng lặp, trống hoặc không hợp lệ. Chỉ hỗ trợ JSON; không tự phân trang hay thử lại. Quy tắc: AND = cả hai, OR = hoặc, XOR = đúng một, NOT = loại trừ, => = yêu cầu.
GET query only; body = null; response = JSON; html, output, json_restrictor, no_cache: NOT supportedstring: UTF-8 bytes <= maxLength (default 8192); boolean = true OR false; integer: safe integerlanguage: /^[A-Za-z]{2,3}(?:[-_][A-Za-z]{2,4})?$/adults (default 1) + children + infants_in_seat + infants_on_lap <= 9; infants_on_lap <= adultsbags <= adults + children + infants_in_seatdeparture_id AND arrival_id AND outbound_date: required unless selected_flights_json OR multi_city_json supplies the itineraryDates: valid YYYY-MM-DD; return_date >= outbound_date; type = 1 requires return_date; type = 2 excludes return_date; type = 3 requires multi_city_jsonmulti_city_json: JSON array of 2..5 ordered legs with departure_id, arrival_id, date and optional timesselected_flights_json: native JSON object of outbound flight segments and optional return segments; each segment has flight_number, departure_id, arrival_id, date; the data service validates the segment structureNOT (departure_token AND booking_token); tokens require original itinerary parametersoutbound_times, return_times: 2 OR 4 hours (0..23); layover_duration: ordered min,max minutesexclude_basic = true => country = us (default) AND travel_class = economy (default)Tokens: copy the exact token from a fresh response; do not invent or reuse expired tokens; each page or token lookup is a separate billable successful request
Ví dụ
curl --get "https://api.apihop.ai/v1/google-flights/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "arrival_id=LAX" \
--data-urlencode "currency=USD" \
--data-urlencode "departure_id=JFK" \
--data-urlencode "outbound_date=2026-12-12"Google Flights: Lấy gợi ý sân bay
GET https://api.apihop.ai/v1/google-flights/autocomplete
Tham số
| Trường | Kiểu | Giới hạn | Ví dụ |
|---|---|---|---|
query | string | Từ khóa tìm kiếm; query: REQUIRED | New York |
country | string | Mã quốc gia hoặc cửa hàng (country); country: optional; ^[A-Za-z]{2}$ | - |
language | string | Ngôn ngữ; language: optional | - |
limit | integer | Giới hạn kết quả; limit: optional; min: 1; max: 100 | 1 |
device | string | Thiết bị; device: optional; desktop, mobile, tablet | desktop |
zero_trace | boolean | Không lưu trữ phản hồi; zero_trace: optional | true |
exclude_regions | boolean | Bộ lọc chuyến bay hoặc điểm đến (exclude_regions); exclude_regions: optional | true |
Kiểm tra
Chỉ nhận tham số truy vấn, không có phần thân. Từ chối giá trị lạ, trùng lặp, trống hoặc không hợp lệ. Chỉ hỗ trợ JSON; không tự phân trang hay thử lại. Quy tắc: AND = cả hai, OR = hoặc, XOR = đúng một, NOT = loại trừ, => = yêu cầu.
GET query only; body = null; response = JSON; html, output, json_restrictor, no_cache: NOT supportedstring: UTF-8 bytes <= maxLength (default 8192); boolean = true OR false; integer: safe integerlanguage: /^[A-Za-z]{2,3}(?:[-_][A-Za-z]{2,4})?$/
Ví dụ
curl --get "https://api.apihop.ai/v1/google-flights/autocomplete" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "query=New York"Google Flights: Tìm ưu đãi chuyến bay
GET https://api.apihop.ai/v1/google-flights/deals
Tham số
| Trường | Kiểu | Giới hạn | Ví dụ |
|---|---|---|---|
query | string | Từ khóa tìm kiếm; query: optional | Week long trip to a city with great food |
departure_id | string | Mã sân bay hoặc thành phố khởi hành (departure_id); departure_id: REQUIRED; ^(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+)(?:,(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+))*$ | JFK |
adults | integer | Số người lớn (adults); adults: optional; min: 1; max: 9 | 1 |
outbound_date | string | Ngày đi (YYYY-MM-DD) hoặc khoảng ngày được hỗ trợ (outbound_date); outbound_date: optional; UTF-8 bytes: 21 | - |
return_date | string | Ngày đi (YYYY-MM-DD) hoặc khoảng ngày được hỗ trợ (return_date); return_date: optional; UTF-8 bytes: 21 | - |
travel_duration | integer | Bộ lọc thời lượng chuyến đi (travel_duration); travel_duration: optional; min: 1; max: 3 | 1 |
trip_length | string | Bộ lọc thời lượng chuyến đi (trip_length); trip_length: optional; UTF-8 bytes: 21; ^[0-9]{1,10}(?:,[0-9]{1,10})?$ | - |
children | integer | Số trẻ em (children); children: optional; min: 0; max: 8 | 0 |
infants_in_seat | integer | Số trẻ sơ sinh (infants_in_seat); infants_in_seat: optional; min: 0; max: 8 | 0 |
infants_on_lap | integer | Trẻ sơ sinh ngồi trên đùi (infants_on_lap); infants_on_lap: optional; min: 0; max: 8 | 0 |
travel_class | string | Hạng ghế (travel_class); travel_class: optional; economy, premium_economy, business, first | economy |
type | integer | Bộ lọc chuyến bay hoặc điểm đến (type); type: optional; 1, 2 | 1 |
stops | integer | Bộ lọc chuyến bay hoặc điểm đến (stops); stops: optional; min: 0; max: 3 | 0 |
include_airlines | string | Bộ lọc hãng bay hoặc liên minh (include_airlines); include_airlines: optional; UTF-8 bytes: 1000; ^(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD)(?:,(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD))*$ | - |
exclude_airlines | string | Bộ lọc hãng bay hoặc liên minh (exclude_airlines); exclude_airlines: optional; UTF-8 bytes: 1000; ^(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD)(?:,(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD))*$ | - |
max_price | integer | Giá tối đa (max_price); max_price: optional; min: 1; max: 2147483647 | 1 |
max_duration | integer | Bộ lọc thời lượng chuyến đi (max_duration); max_duration: optional; min: 1; max: 2147483647 | 1 |
currency | string | Mã tiền tệ (currency); currency: optional; ALL, DZD, ARS, AMD, AWG, AUD, AZN, BSD, BHD, BYN, BMD, BAM, BRL, GBP, BGN, XPF, CAD, CLP, CNY, COP, CRC, CUP, CZK, DKK, DOP, EGP, EUR, GEL, HKD, HUF, ISK, INR, IDR, IRR, ILS, JMD, JPY, JOD, KZT, KWD, LBP, MKD, MYR, MXN, MDL, MAD, TWD, NZD, NOK, OMR, PKR, PAB, PEN, PHP, PLN, QAR, RON, RUB, SAR, RSD, SGD, ZAR, KRW, SEK, CHF, THB, TRY, USD, UAH, AED, VND; ^[A-Z]{3}$ | ALL |
country | string | Mã quốc gia hoặc cửa hàng (country); country: optional; ^[A-Za-z]{2}$ | - |
language | string | Ngôn ngữ; language: optional | - |
limit | integer | Giới hạn kết quả; limit: optional; min: 1; max: 100 | 10 |
device | string | Thiết bị; device: optional; desktop, mobile, tablet | desktop |
zero_trace | boolean | Không lưu trữ phản hồi; zero_trace: optional | true |
Kiểm tra
Chỉ nhận tham số truy vấn, không có phần thân. Từ chối giá trị lạ, trùng lặp, trống hoặc không hợp lệ. Chỉ hỗ trợ JSON; không tự phân trang hay thử lại. Quy tắc: AND = cả hai, OR = hoặc, XOR = đúng một, NOT = loại trừ, => = yêu cầu.
GET query only; body = null; response = JSON; html, output, json_restrictor, no_cache: NOT supportedstring: UTF-8 bytes <= maxLength (default 8192); boolean = true OR false; integer: safe integerlanguage: /^[A-Za-z]{2,3}(?:[-_][A-Za-z]{2,4})?$/adults (default 1) + children + infants_in_seat + infants_on_lap <= 9; infants_on_lap <= adultsoutbound_date, return_date: valid YYYY-MM-DD or ordered YYYY-MM-DD,YYYY-MM-DD window; return dates cannot precede departure datestype = 2 => NOT return_date; flexible return windows require flexible departure windowstravel_duration: flexible round-trip duration; cannot combine with exact datestrip_length: positive days or ordered min,max; requires flexible departure dates; query => NOT travel_duration
Ví dụ
curl --get "https://api.apihop.ai/v1/google-flights/deals" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "departure_id=JFK" \
--data-urlencode "limit=10" \
--data-urlencode "query=Week long trip to a city with great food"Phản hồi và lỗi
Giữ JSON gốc và độ chính xác. Ví dụ kết quả rỗng thành công. HTTP 400: đầu vào; 401: xác thực; 402: số dư; 403: quyền; 405: phương thức; 429: giới hạn; 5xx: dịch vụ. Giữ X-Request-Id.
{
"success": true,
"request_id": "example-request",
"data": {
"format": "json",
"content": {
"results": []
}
}
}