Search flights
Name a trip with GET or POST, choose how long to wait, and shape the answer. With a full example and a real response.
A search names one trip and answers with priced itineraries. You choose how long the call waits, and how the answer is filtered, sorted and trimmed.
Make a search
GET /v1/flights/search is the main form: a search changes nothing, so the whole request fits in a URL. This one asks for a round trip for two adults and one result.
curl -sS "https://api.voyagelabs.ai/v1/flights/search?origin=SFO&destination=NRT&depart_date=2027-02-09&return_date=2027-02-16&adults=2&limit=1" \
-H "X-API-Key: $VOYAGE_LABS_API_KEY"By default the call waits for the complete answer, for up to 30 seconds, so give your HTTP client a timeout longer than that. The Python example uses 40 seconds.
This is the answer to that request, made with a test key. The link tokens are shortened here; real ones are much longer.
{
"data": {
"search_id": "srch_17a3c431-779c-4a88-9ebf-5f4b1eee0736",
"status": "complete",
"query": {
"origin": "SFO",
"destination": "NRT",
"depart_date": "2027-02-09",
"return_date": "2027-02-16",
"adults": 2,
"children": 0,
"infants": 0,
"cabin": "economy",
"currency": "USD"
},
"pricing": { "priced_at": "2026-12-06T20:46:06.727Z", "age_s": 0, "refreshing": false },
"counts": { "found": 6, "matched": 6, "returned": 1 },
"next_cursor": "c_eyJvIjoxLCJzIjoiMTdhM2M0MzEtNzc5Yy00YTg4LTllYmYtNWY0YjFlZWUwNzM2IiwidiI6ImJlc3R8fCJ9",
"airlines": [
{ "code": "ZG", "name": "ZIPAIR", "results": 1, "from": 1445.02, "best_link": "itinerary" },
{ "code": "UA", "name": "United", "results": 1, "from": 2792.18, "best_link": "itinerary" },
{ "code": "JL", "name": "JAL", "results": 2, "from": 2808.18, "best_link": "itinerary" },
{ "code": "NH", "name": "ANA", "results": 1, "from": 2823.38, "best_link": "flights_selected" },
{ "code": "AS", "name": "Alaska", "results": 1, "from": 2920.18, "best_link": "itinerary" }
],
"results": [
{
"id": "it_U0ZPLk5SVC4yMDI3MDIwOS4yMDI3MDIxNi4yLjAuMC5ZLlVTRHxaRzI1QDAyMDksWkcyNkAwMjE2",
"airlines": [{ "code": "ZG", "name": "ZIPAIR" }],
"price": { "total": 1445.02, "per_adult": 722.51, "currency": "USD" },
"stops": 0,
"total_duration_min": 1230,
"slices": [
{
"direction": "outbound",
"origin": "SFO",
"destination": "NRT",
"depart": "2027-02-09T15:45:00",
"depart_utc": "2027-02-09T23:45:00Z",
"arrive": "2027-02-10T19:55:00",
"arrive_utc": "2027-02-10T10:55:00Z",
"duration_min": 670,
"stops": 0,
"flights": ["ZG25"]
},
{
"direction": "return",
"origin": "NRT",
"destination": "SFO",
"depart": "2027-02-16T21:25:00",
"depart_utc": "2027-02-16T12:25:00Z",
"arrive": "2027-02-16T13:45:00",
"arrive_utc": "2027-02-16T21:45:00Z",
"duration_min": 560,
"stops": 0,
"flights": ["ZG26"]
}
],
"fare": {
"family": "STANDARD",
"cabins": ["Economy"],
"refundable": true,
"changeable": false,
"carry_on_included": true,
"checked_bag_included": false,
"seats_left": 6
},
"booking_links": {
"supplier": { "url": null, "available": false, "lands_on": null },
"airline": {
"url": "https://api.voyagelabs.ai/r/al_sE0Iy5Op1B…",
"available": true,
"lands_on": "booking_page",
"airline": "ZG"
},
"google_flights": {
"url": "https://api.voyagelabs.ai/r/al_-v1RAtbiIi…",
"available": true,
"lands_on": "itinerary"
}
}
}
]
},
"meta": { "request_id": "req_4252794c71f0", "mode": "test" }
}counts.found is every itinerary in the search, matched is what is left after your filters, and returned is how many are in this response. next_cursor fetches the next page. How flight search works explains each field of a result.
The trip
These fields name the trip. They decide which stored search answers the request.
Prop
Type
A trip is one-way or a round trip. Multi-city trips are not supported: a trip with more than one destination is refused with invalid_parameter. Travellers are counted, not described: the API takes no ages or names.
Shape the answer
These fields filter, sort and trim the answer for this one response.
Prop
Type
data.airlines always lists every airline in the whole search, cheapest first, so you can offer airline filters without guessing codes.
Fields that start a supplier search, and fields that do not
The trip fields decide which stored search answers. The shape fields never cause a supplier search. In detail:
- The same trip fields reach the same stored search. While its answer is fresh, every request for that trip is answered from it, whatever its
sort,max_stops,airlines,limitordetail. AGETand aPOSTfor the same trip reach the same search. - A trip with no fresh stored answer starts a supplier search. A stored answer under 4 minutes old is used as it is. One up to 30 minutes old is used at once and searched again behind the reply, with
pricing.refreshingset totrue. An older one is searched again first. - Shape fields only reshape the stored answer. Changing them filters, sorts and trims the same itineraries again. It never asks the supplier for more.
max_age_scan start a supplier search. It sets the oldest price you accept, in seconds (0 to 86,400). A stored answer older than that is searched again before the reply;max_age_s=0always searches again. If no new search can start just then, the request is refused withsearch_capacityrather than answered with older prices.wait_msandresponse_modechange only when you are answered, never what is searched. See the next section.
Reshape a search without searching again
Every call to GET or POST /v1/flights/search without a cursor counts toward your key's new-trips limit, even when it is answered from a stored search. To sort, filter, page or read one result again, use GET /v1/flights/search/{search_id}, which counts only toward your requests. See Rate limits and usage.
Choose how long to wait
response_mode | What you get |
|---|---|
complete (default) | One JSON answer when the search is complete, or after 30 seconds with what has arrived, whichever comes first. |
partial | One JSON answer when the search is complete, or after wait_ms with what has arrived, whichever comes first. Without a wait_ms, that is 8 seconds. |
stream | Server-sent events, as itineraries arrive. |
wait_ms (0 to 30,000 milliseconds) answers with whatever has arrived by then, even when you leave response_mode out. A search that is still running when you are answered carries on, and the answer has status partial, possibly with no results yet. Read the rest by search_id, as Read a search shows. A trip searched recently answers at once in every mode.
To stream, send response_mode=stream, stream=1 or the header Accept: text/event-stream. Each results event carries the whole answer so far, shaped by your filters, sort and limit, so keep only the latest. The stream ends with one complete event or one error event, and sends a comment line every 15 seconds to keep the connection open. A request refused before the search starts, such as one with a bad field or a bad key, is answered as plain JSON, not as a stream.
Search with a JSON body
POST /v1/flights/search takes the same fields as a JSON object of up to 16 KB. It returns the same answer as the GET form.
{
"origin": "SFO",
"destination": "NRT",
"depart_date": "2027-02-09",
"return_date": "2027-02-16",
"adults": 2
}A body can also name the trip as legs, one entry per direction: one leg for a one-way trip, or two that return to the start for a round trip. A mistake inside a leg is reported with the leg's own name, such as legs[1].date. Traveller counts can also go in a passengers object.
{
"legs": [
{ "origin": "SFO", "destination": "NRT", "date": "2027-02-09" },
{ "origin": "NRT", "destination": "SFO", "date": "2027-02-16" }
],
"passengers": { "adults": 2 }
}curl -sS "https://api.voyagelabs.ai/v1/flights/search" \
-H "X-API-Key: $VOYAGE_LABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"origin":"SFO","destination":"NRT","depart_date":"2027-02-09","return_date":"2027-02-16","adults":2,"limit":1}'A body that is not a JSON object, or is over 16 KB, is refused with invalid_body.
When a search is refused
A field that is missing, malformed or out of range is refused with HTTP 400 and invalid_parameter. param names the field, and message says what is allowed.
{
"error": {
"code": "invalid_parameter",
"message": "origin must be a 3-letter airport code such as SFO.",
"param": "origin",
"retry": "never",
"request_id": "req_b5737a1edf58"
}
}Branch on error.code, never on the wording of message. Errors lists every code and what to do about it.