Adopting Multi-Step Search
Overview
How the flow works?
Outbound search: You pass the origin and destination
slices
andpassengers
and get back a list of partial offers for the outbound slice of your journey by creating a partial offer request. A partial offer is an offer that can’t be booked directly but can be passed to the next endpoint: show partial offer request. A partial offer contains only one slice, even if the search is for multiple slices. At the end of the flow (at fare selection), you pass in the partial offers for each of the slices in your journey to obtain a full offer that you can book.Inbound search: You pass in the offer from the previous outbound search into the endpoint for the inbound search. This will be through the partial offer request show endpoint. You’ll get back partial offers for the next slice of your journey.
Fare selection: You pass in the chosen partial offers obtained from the outbound and inbound search, to obtain a list of full offers. This will be through the fares endpoint.
Create order: Finally you make a booking by passing in the full offer ID obtained at fare selection while creating an order.
Outbound Search
Request
return_offers
option as offers are always returned from this flow.curl -X POST --compressed "https://api.duffel.com/air/partial_offer_requests"-H "Accept-Encoding: gzip"-H "Accept: application/json"-H "Content-Type: application/json"-H "Duffel-Version: v1"-H "Authorization: Bearer $YOUR_ACCESS_TOKEN"-d '{"data": {"slices": [{"origin": "LHR","destination": "JFK","departure_date": "2023-12-24"},{"origin": "JFK","destination": "LHR","departure_date": "2023-12-24"}],"passengers": [{"type": "adult"}]}}'
Response
The ID is an identifier for a partial offer request, not an offer request.
The offers returned are partial offers, not full offers. Each partial offer is the cheapest offer available for that itinerary and airline. You will see the field
partial
set totrue
for these.
{"id": "prq_00009hthhsUZ8W4LxQghdf",// [...]"offers": [{// [...]"id": "off_00009htYpSCXrwaB9DnUm0_0","partial": true,"slices": [/* only one slice outbound */]}]}
Inbound Search
Request
curl -X GET --compressed"https://api.duffel.com/air/partial_offer_requests/$PARTIAL_OFFER_REQUEST_ID_FROM_OUTBOUND_SEARCH?selected_partial_offer[]=$PARTIAL_OFFER_ID_FROM_OUTBOUND_SEARCH"-H "Accept-Encoding: gzip"-H "Accept: application/json"-H "Content-Type: application/json"-H "Duffel-Version: v1"-H "Authorization: Bearer $YOUR_ACCESS_TOKEN"
tip
Response
selected_partial_offer[]
that were passed in.{"id": "prq_00009hthhsUZ8W4LxQghdf",// [...]"offers": [{// [...]"id": "off_00009htYpSCXr3waB9PdIn1_1","partial": true}]}
Fare Selection
Request
selected_partial_offer[]
curl -X GET --compressed"https://api.duffel.com/air/partial_offer_requests/$PARTIAL_OFFER_REQUEST_ID_FROM_OUTBOUND_SEARCH/fares?selected_partial_offer[]=$PARTIAL_OFFER_ID_FROM_OUTBOUND_SEARCH&selected_partial_offer[]=$PARTIAL_OFFER_ID_FROM_INBOUND_SEARCH"-H "Accept-Encoding: gzip"-H "Accept: application/json"-H "Content-Type: application/json"-H "Duffel-Version: v1"-H "Authorization: Bearer $YOUR_ACCESS_TOKEN"
tip
Response
partial
set to false
for these.
You will finally select one of the offer IDs from here as your offer to create an order.{// [...]"offers": [{// [...]"id": "off_00009htYpSCXrwaB9NaDt2","partial": false}]}