Wego's Flights Search Service allows clients to search for flight fares and availabilty in real-time across Wego's inventory of partners. The service is available via standard HTTP GET methods and responses are made available in both XML and JSON formats.
Please report any bugs to api@wego.com.
There are 3 main components that you'll most likely care about:
Search
Allows you to start a flight search and retrieve results
Booking a flight with our partners
Taking users to continue the booking process for a flight at one of our partners' sites
API usage
The flights API only allow users to make a certain number of calls per hour. Therefore, you would most likely want to check how many calls you have already made.
The typical use case of a user searching for Flights would involve:
A user, let's call her Yui, is looking for Economy class flights to fly from Singapore to Bangkok on 23 June 2010 and She is thinking of coming back to Singapore on 26 June 2010. She fill in the relevant fields on the search form and submit her search to your application.
You first issue a call to check how many calls you have made within the hour.
GET http://www.wego.com/api/flights/usage.html?format=json&apiKey=testAPIKey
The API responds with:
{"APIUsageData": {
"usageCount": {
"value": 0
},
"maxCount": {
"value": 1000
},
"startTimeBucket": "20100612230038",
"endTimeBucket": "20100613000038"
}}
After checking that you are still within the API limit, you can start using the API. You send a startSearch API /startSearch.html request to start a search for flights meeting her requirement. (If custom ts_code is given, please add the ts_code=VALUE to the parameter.)
GET http://www.wego.com/api/flights/startSearch.html?format=json&fromLocation=SIN&toLocation=BKK&tripType=roundTrip&cabinClass=Economy&inboundDate=2010-06-26&outboundDate=2010-06-23&numAdults=1&apiKey=testApiKey&ts_code=a7557
The API responds with:
{"request":{
"instanceId":"ec08ea02b4946dabbbc800da0835c696f1c5a6ac"
,"usage":"1"
}
}
you can then use the instanceId to fetch search results with the /pull.html API method.
To use the /pull.html method, A rand parameter need to be passed in together with the instanceId parameter to form a unique key that will keep track of number of results returned to Yui.
Important: If you wish to start polling from the very first result then issue a new rand value, otherwise continue using the same rand till you reach the end of result list.
GET http://www.wego.com/api/flights/pull.html?format=json&apiKey=testApiKey&instanceId=c90a013e708e5ffcc526dd81ac42acf5f6040739&rand=1
the API responds with:
{"response":{
"pendingResults":"true",
"itineraries":[
"{"itinerary":{
"originCountryCode": "SG",
"destinationCountryCode": "TH",
"price": {
"amount": "380.0",
"currencyCode": "SGD",
"includesTax": true,
"name": "",
"pricePerPassenger": "380.0",
"totalAmount": "510.3",
"totalPricePerPassenger": "510.3"
},
"outboundInfo": {
"aircraftTypes": ["772"],
"airports": ["SIN", "BKK"],
"arrivalTime": 1287829500000,
"departureTime": 1287820800000,
"durationInMin": 145,
"flightClasses": [{
"fareClass": 1,
"name": "Economy"
}],
"flightNumbers": ["SQ976"],
"layoverInMin": 0,
"localArrivalTimeStr": "2010/10/23 17:25 +0700",
"localDepartureTimeStr": "2010/10/23 16:00 +0800",
"numStops": 0
},
"inboundInfo": {
"aircraftTypes": ["772"],
"airports": ["BKK", "SIN"],
"arrivalTime": 1288101300000,
"departureTime": 1288092600000,
"durationInMin": 145,
"flightClasses": [{
"fareClass": 1,
"name": "Economy"
}],
"flightNumbers": ["SQ979"],
"layoverInMin": 0,
"localArrivalTimeStr": "2010/10/26 21:55 +0800",
"localDepartureTimeStr": "2010/10/26 18:30 +0700",
"numStops": 0
},
"carrier": [{
"code": "SQ",
"name": "Singapore Airlines"
}],
"location": [{
"code": "SIN",
"name": "Singapore Changi"
},
{
"code": "BKK",
"name": "Bangkok"
}],
"id": "SQ976[SIN-BKK]|SQ979[BKK-SIN]",
"generatedDate": 1287063322786,
"providerId": "singaporeair.com",
"bookingCode": "1287063322787172000"
}",...
Yui is shown a page where results from the /pull.html method are displayed
It's best to wait at least 10 seconds after starting the search before making the /pull.html call.
To retrieve all the results, you would have call the /pull.html until the response return a false for the pendingResults field
Yui wants to view more flight details like transit airport. You send a details /details.html request.
GET http://www.wego.com/api/flights/details.html?instanceId=c90a013e708e5ffcc526dd81ac42acf5f6040739&itineraryId=CX712[SIN-BKK]|CX713[BKK-SIN]&format=json&outboundDate=2010-06-23&inboundDate=2010-06-26&apiKey=testApiKey
the API responds with:
{"details": {"outboundSegments": {"list": [
{
"flightNumber": {
"designator": "CX",
"number": "712"
},
"operatingAirlineFlightNumber": {
"designator": "CX",
"number": "712"
},
"departureStation": "SIN",
"passengerSTD": "1355",
"STD": "1355",
"UTCLocalDepartureTimeVariation": "+0800",
"passengerDepartureTerminal": "1",
"arrivalStation": "BKK",
"STA": "1515",
"passengerSTA": "1515",
"UTCLocalArrivalTimeVariation": "+0700",
"aircraftType": "773",
"operatorCode": "CX",
"durationInMin": 140,
"departureDateTime": 1295502900000,
"arrivalDateTime": 1295511300000
}
]}, "inboundSegments": {"list": [
{
"flightNumber": {
"designator": "CX",
"number": "713"
},
"operatingAirlineFlightNumber": {
"designator": "CX",
"number": "713"
},
"departureStation": "BKK",
"passengerSTD": "1245",
"STD": "1245",
"UTCLocalDepartureTimeVariation": "+0700",
"arrivalStation": "SIN",
"STA": "1610",
"passengerSTA": "1610",
"UTCLocalArrivalTimeVariation": "+0800",
"passengerArrivalTerminal": "1",
"aircraftType": "773",
"operatorCode": "CX",
"durationInMin": 145,
"departureDateTime": 1298612700000,
"arrivalDateTime": 1298621400000
}
]} }}
Yui sees a Flight (bookingCode 1276355338783763000, providerId airasia.com ) that she would like to book and clicks to continue to book the flight at the partner site.
You send a book API /redirect.html request to retrieve a handoff page that redirect the user to the booking site of the partner so that she can continue her booking directly with them:
GET http://www.wego.com/api/flights/redirect.html?apiKey=testAPIKey&bookingCode=1276355338783763000&providerId=airasia.com&dlfrom=SIN&dlto=BKK&instanceId=c90a013e708e5ffcc526dd81ac42acf5f6040739&ts_code=a7557
Another approach to presenting the data is to offer users two one-way tickets for the outbound and inbound legs. To do this, you will need to follow the same approach as above, but instead of doing a roundtrip search, you will have to send two one-way searches for the outbound and inbound legs. You will then need to handle the results from the two requests in such a way that you will be able to offer the users the flexibility to create their own itinerary by mixing and matching leg options.
An example of this kind of layout could be seen here.
Please note that you can do this in any city pairs you like if the majority of carriers serving those routes offer one-way pricing.
All API requests require you to authenticate with your API Key(given to you by Wego). Always pass along the apiKey in your API requests, Example
GET http://www.wego.com/api/flights/usage.html?format=json&apiKey=testAPIKey
Your API key is used to track usage and to limit the number of API requests you can make (for all API methods except the usage API /usage.html). The API rate limits have not been decided at this time
The itinerary type represents a single flight search result that matches the user requirement
A sample itinerary response in JSON looks like:
"itinerary":{
"originCountryCode": "SG",
"destinationCountryCode": "TH",
"price": {
"amount": "380.0",
"currencyCode": "SGD",
"includesTax": true,
"name": "",
"pricePerPassenger": "380.0",
"totalAmount": "510.3",
"totalPricePerPassenger": "510.3"
},
"outboundInfo": {
"aircraftTypes": ["772"],
"airports": ["SIN", "BKK"],
"arrivalTime": 1287829500000,
"departureTime": 1287820800000,
"durationInMin": 145,
"flightClasses": [{
"fareClass": 1,
"name": "Economy"
}],
"flightNumbers": ["SQ976"],
"layoverInMin": 0,
"localArrivalTimeStr": "2010/10/23 17:25 +0700",
"localDepartureTimeStr": "2010/10/23 16:00 +0800",
"numStops": 0
},
"inboundInfo": {
"aircraftTypes": ["772"],
"airports": ["BKK", "SIN"],
"arrivalTime": 1288101300000,
"departureTime": 1288092600000,
"durationInMin": 145,
"flightClasses": [{
"fareClass": 1,
"name": "Economy"
}],
"flightNumbers": ["SQ979"],
"layoverInMin": 0,
"localArrivalTimeStr": "2010/10/26 21:55 +0800",
"localDepartureTimeStr": "2010/10/26 18:30 +0700",
"numStops": 0
},
"carrier": [{
"code": "SQ",
"name": "Singapore Airlines"
}],
"location": [{
"code": "SIN",
"name": "Singapore Changi"
},
{
"code": "BKK",
"name": "Bangkok"
}],
"id": "SQ976[SIN-BKK]|SQ979[BKK-SIN]",
"generatedDate": 1287063322786,
"providerId": "singaporeair.com",
"bookingCode": "1287063322787172000"
},
providerId - Id of the flight provider
bookingCode - Booking code of the flight
id -Flight Number of Departure Flight [origin IATA code - destination IATA code] | Flight Number of Origin Flight [destination IATA code - origin IATA code]
generatedDate generated date of the result in millisecond since epoch
price - Price information of Flights
currencyCode - Currency of price
amount - Price of ticket Without Taxes
includesTax - Indicate whether flight result contains tax inclusive price
totalAmount - Total Price of ticket including taxes
pricePerPassenger - Average Price per Passenger without taxes
totalPricePerPassenger - Average Price per Passenger with taxes
name - Fare Name
outboundInfo - Departure Flight Information
originCountryCode Origin Airport IATA Country code
destinationCountryCode Destination Airport IATA Country code
departureTime - Departure time of Flight in millisecond since epoch
localDepartureTimeStr - Local Departure Time
arrivalTime - Arrival time of flight in millisecond since epoch
localArrivalTimeStr - Local Arrival Time of flight
durationInMin - Duration of Flight in mins
numStops - Number of transit stops
layoverInMin - Layover time of Flight in mins
flightClasses - Flight Class Information
name - Name of Flight Class, Economy, Business, First
fareClass - 1 is Economy, 2 is Business and 3 is First
flightNumber - Flight Number Information
aircraftTypes - Aircraft type information
airports -
eg: [SIN, NRT, NRT, LAX]
Odd Indices of an Array are Departure Airports
Even Indices of an Array are Arrival Airports
For the example above: SIN to NRT then NRT to LAX
Airport IataCode in flight path
InboundInfo - Arrival Flight Information for round trip search
originCountryCode Origin Airport IATA Country code
destinationCountryCode Destination Airport IATA Country code
departureTime - Departure time of Flight in millisecond since epoch
localDepartureTimeStr - Local Departure Time
arrivalTime - Arrival time of flight in millisecond since epoch
localArrivalTimeStr - Local Arrival Time of flight
durationInMin - Duration of Flight in mins
numStops - Number of transit stops
layoverInMin - Layover time of Flight in mins
flightClasses - Flight Class Information
name - Name of Flight Class, Economy, Business, First
fareClass - 1 is Economy, 2 is Business and 3 is First
flightNumber - Flight Number Information
aircraftTypes - Aircraft type information
airports -
eg: [SIN, NRT, NRT, LAX]
Odd Indices of an Array are Departure Airports
Even Indices of an Array are Arrival Airports
For the example above: SIN to NRT then NRT to LAX
Airport IataCode in flight path
carrier -Flight Carrier Details
code - Airline Iata Code
name - Airline Name
location - Array of Location Details
code - Iata Airport Code
name - Airport Name
The details type represents the detailed information of a single itinerary
A sample details response in JSON looks like:
{"details": {"outboundSegments": {"list": [
{
"flightNumber": {
"designator": "CX",
"number": "712"
},
"operatingAirlineFlightNumber": {
"designator": "CX",
"number": "712"
},
"departureStation": "SIN",
"passengerSTD": "1355",
"STD": "1355",
"UTCLocalDepartureTimeVariation": "+0800",
"passengerDepartureTerminal": "1",
"arrivalStation": "BKK",
"STA": "1515",
"passengerSTA": "1515",
"UTCLocalArrivalTimeVariation": "+0700",
"aircraftType": "773",
"operatorCode": "CX",
"durationInMin": 140,
"departureDateTime": new Date(1295502900000),
"arrivalDateTime": new Date(1295511300000)
}
]}, "inboundSegments": {"list": [
{
"flightNumber": {
"designator": "CX",
"number": "713"
},
"operatingAirlineFlightNumber": {
"designator": "CX",
"number": "713"
},
"departureStation": "BKK",
"passengerSTD": "1245",
"STD": "1245",
"UTCLocalDepartureTimeVariation": "+0700",
"arrivalStation": "SIN",
"STA": "1610",
"passengerSTA": "1610",
"UTCLocalArrivalTimeVariation": "+0800",
"passengerArrivalTerminal": "1",
"aircraftType": "773",
"operatorCode": "CX",
"durationInMin": 145,
"departureDateTime": new Date(1298612700000),
"arrivalDateTime": new Date(1298621400000)
}
]} }}
outboundSegments - List of Outbound Flight Segments
FlightNumber - Flight Information
designator - Flight Designatornumber - Flight Number operatingAirlineFlightNumber - Operating Airline Flight Number (Might be different from Flight Number because of code sharing)
designator - Flight Designatornumber - Flight Number departureStation - Departure Airport IATA codepassengerSTD - Scheduled Time of Departure STD Scheduled Time of Departure UTCLocalDepartureTimeVariation - Time zone of Departure Airport passengerDepartureTerminal - Departure Airport Terminal arrivalStation Arrival Airport IATA code STA - Scheduled Time of Arrival passengerSTA Scheduled Time of Arrival UTCLocalArrivalTimeVariation - Time zone of Arrival Airport passengerArrivalTerminal - Arrival Airport Terminal aircraftType - Aircraft typeoperatorCode - Operating Airline codedurationInMin - Time of Flight in mins departureDateTime - departureDateTime in millisecond since epoch arrivalDateTime - arrivalDateTime in millisecond since epoch InboundSegments - List of Inbound Flights Segments
FlightNumber - Flight Information
designator - Flight Designatornumber - Flight Number operatingAirlineFlightNumber - Operating Airline Flight Number (Might be different from Flight Number because of code sharing)
designator - Flight Designatornumber - Flight Number departureStation - Departure Airport IATA codepassengerSTD - Scheduled Time of Departure STD Scheduled Time of Departure UTCLocalDepartureTimeVariation - Time zone of Departure Airport passengerDepartureTerminal - Departure Airport Terminal arrivalStation Arrival Airport IATA code STA - Scheduled Time of Arrival passengerSTA Scheduled Time of Arrival UTCLocalArrivalTimeVariation - Time zone of Arrival Airport passengerArrivalTerminal - Arrival Airport Terminal aircraftType - Aircraft typeoperatorCode - Operating Airline codedurationInMin - Time of Flight in mins departureDateTime - departureDateTime in millisecond since epoch arrivalDateTime - arrivalDateTime in millisecond since epoch
The API returns appropriate HTTP status codes. In addition, the API also includes error information in the response body. Error responses have a single error property that is a string describing the error, e.g.:
{"error": {"message": "apiKey:testApiKey does not have a valid session"}}
An additional message property is sometimes available for further diagnostics.
Possible errors are:
apiKey:testApiKey does not have a valid session - Please ensure you have logged in or you are using a correct api key
parameter is invalid - Please ensure that you have not missed out the parameter value or the parameter value is valid
All API methods are HTTP GET requests and require API key-based authentication. The response data format is in either JSON or XML.
Start a new Flight Search
GET http://www.wego.com/api/flights/startSearch.html?format=format&fromLocation=departureAirportCode&toLocation=arrivalAirportCode&tripType=tripType&cabinClass=cabinClass&inboundDate=inboundDate&outboundDate=outboundDate&numAdults=numAdults&numChildren=numChildren&callback=callback&apiKey=APIKey&ts_code=ts_code
Parameters:
format - Format of response. Possible values: json, xml Defaults to json.
formLocation - required - 3-letter IATA airport code (e.g. SIN)
toLocation - required - 3-letter IATA airport code (e.g. BKK)
tripType - required - Possible Values: oneWay, roundTrip
cabinClass - required - Possible Values: Economy, Business, First
inboundDate - yyyy-MM-dd (not required for oneWay flights)
outBoundDate - required - yyyy-MM-dd
numAdults - required - 1- 9
numChildren - required - 0- 9
APIKey - required - Apikey given by Wego
ts_code - optional - This is used by Wego to recognize that the traffic is coming from the public API. Please use the assigned ts_code value given upon subscription.
language - optional - pass in the language preferred. If supported by the provider, users will be redirected to the site with the said lang.
countrySiteCode - optional - pass in the country site preferred. If supported by the provider, users will be redirected to the provider's corresponding country site.
callback - callback - JSON-P callback function name.
Return the instanceId for the flight search
{"request":{
"instanceId":"ec08ea02b4946dabbbc800da0835c696f1c5a6ac"
,"usage":"1"
}
}
Retrieving the result of a flight search
GET http://www.wego.com/api/flights/pull.html?format=format&apiKey=APIKey&instanceId=instanceId&rand=random&callback=callback
Parameters:
format - Format of response. Possible values: json, xml Defaults to json.
instanceId - required - Instance Id returned by the startSearch API request.
random - required - a random alpha-numeric value. The rand parameter used is used in conjunction with the instanceId parameter to form a unique key that will keep track of number of results returned to the client for a given session. Important: If you wish to start polling from the very first result then issue a new rand value, otherwise continue using the same rand till you reach the end of result list.
APIKey - required - Apikey given by Wego
callback - callback - JSON-P callback function name.
monetized_partners - If this field is omitted, all partners results are returned. If true is given, only monetized partners are returned. If false is given, only non monetized partners are returned. Possible values: true, false
currency - optional - currency you want the result to be in. e.g. SGD, INR. If the currency is not supported for the itinerary, it will not be converted. If not specified, the itinerary will have the price in the original currency gotten from the partner.
Return an array of Itinerary Object and the following key-values
pendingResults - Possible values: true (indicate that there are still more results), false (indicate there are no more results).
Notes: Due to current implementation, this value is not accurate. We recommend API consumer to do at least 10 polling with 5 seconds interval.
{"response":{
"pendingResults":"true",
"itineraries":[
{
"originCountryCode": "SG",
"destinationCountryCode": "TH",
"price": {
"amount": "380.0",
"currencyCode": "SGD",
"includesTax": true,
"name": "",
"pricePerPassenger": "380.0",
"totalAmount": "510.3",
"totalPricePerPassenger": "510.3"
},
"outboundInfo": {
"aircraftTypes": ["772"],
"airports": ["SIN", "BKK"],
"arrivalTime": 1287829500000,
"departureTime": 1287820800000,
"durationInMin": 145,
"flightClasses": [{
"fareClass": 1,
"name": "Economy"
}],
"flightNumbers": ["SQ976"],
"layoverInMin": 0,
"localArrivalTimeStr": "2010/10/23 17:25 +0700",
"localDepartureTimeStr": "2010/10/23 16:00 +0800",
"numStops": 0
},
"inboundInfo": {
"aircraftTypes": ["772"],
"airports": ["BKK", "SIN"],
"arrivalTime": 1288101300000,
"departureTime": 1288092600000,
"durationInMin": 145,
"flightClasses": [{
"fareClass": 1,
"name": "Economy"
}],
"flightNumbers": ["SQ979"],
"layoverInMin": 0,
"localArrivalTimeStr": "2010/10/26 21:55 +0800",
"localDepartureTimeStr": "2010/10/26 18:30 +0700",
"numStops": 0
},
"carrier": [{
"code": "SQ",
"name": "Singapore Airlines"
}],
"location": [{
"code": "SIN",
"name": "Singapore Changi"
},
{
"code": "BKK",
"name": "Bangkok"
}],
"id": "SQ976[SIN-BKK]|SQ979[BKK-SIN]",
"generatedDate": 1287063322786,
"providerId": "singaporeair.com",
"bookingCode": "1287063322787172000"
}}}",...
Retrieving the detailed information of a flight itinerary
GET http://www.wego.com/api/flights/details.html?instanceId=instanceId&itineraryId=itineraryId&format=format&outboundDate=outboundDate&inboundDate=inboundDate&apiKey=APIKey&callback=callback
Parameters:
format - Format of response. Possible values: json, xml Defaults to json.instanceId - required Instance Id returned by the startSearch API request. itineraryId - required Itinerary Id in Itinerary response outboundDate - required yyyy-MM-ddinboundDate - yyyy-MM-dd APIKey - Apikey given by Wego callback - JSON-P callback function name. Return Details Object
{"details": {"outboundSegments": {"list": [
{
"flightNumber": {
"designator": "CX",
"number": "712"
},
"operatingAirlineFlightNumber": {
"designator": "CX",
"number": "712"
},
"departureStation": "SIN",
"passengerSTD": "1355",
"STD": "1355",
"UTCLocalDepartureTimeVariation": "+0800",
"passengerDepartureTerminal": "1",
"arrivalStation": "BKK",
"STA": "1515",
"passengerSTA": "1515",
"UTCLocalArrivalTimeVariation": "+0700",
"aircraftType": "773",
"operatorCode": "CX",
"durationInMin": 140,
"departureDateTime": 1295502900000,
"arrivalDateTime": 1295511300000
}
]}, "inboundSegments": {"list": [
{
"flightNumber": {
"designator": "CX",
"number": "713"
},
"operatingAirlineFlightNumber": {
"designator": "CX",
"number": "713"
},
"departureStation": "BKK",
"passengerSTD": "1245",
"STD": "1245",
"UTCLocalDepartureTimeVariation": "+0700",
"arrivalStation": "SIN",
"STA": "1610",
"passengerSTA": "1610",
"UTCLocalArrivalTimeVariation": "+0800",
"passengerArrivalTerminal": "1",
"aircraftType": "773",
"operatorCode": "CX",
"durationInMin": 145,
"departureDateTime": 1298612700000,
"arrivalDateTime": 1298621400000
}
]} }}
Get a page that redirect to one of our partners' site for booking. The result is a HTML page that redirects to one of our partner site, not JSON/XML
GET http://www.wego.com/api/flights/redirect.html?apiKey=APIKey&bookingCode=bookingCode&providerId=providerId&dlfrom=origin&dlto=destination&instanceId=instanceId&ts_code=a7557
Parameters:
instanceId - required - Instance Id returned by the startSearch API request.
bookingCode - required - obtained via /pull method from an Itinerary Object
origin - required - Departure Airport IATA code
destination - required - Destination Airport IATA code
providerId - required - Provider Id obtained from an Itinerary Object
APIKey - required - Apikey given by Wego
ts_code - required - This is used by Wego to recognize that the traffic is coming from the public API. Please use the assigned ts_code value given upon subscription.
language - optional - pass in the language preferred. If supported by the provider, users will be redirected to the site with the said lang.
countrySiteCode - optional - pass in the country site preferred. If supported by the provider, users will be redirected to the provider's corresponding country site.
Allows you to check the usage of the API
GET http://www.wego.com/api/flights/usage.html?format=format&apiKey=APIKey&callback=callbackExample: http://www.wego.com/api/flights/usage.html?format=json&apiKey=testAPIKey
Parameters:
format - Format of response. Possible values: json, xml Defaults to json.
APIKey - required - Apikey given by Wego
callback - callback - JSON-P callback function name.
The response indicate the current API Usage Example:
{"APIUsageData": {
"usageCount": {
"value": 0
},
"maxCount": {
"value": 1000
},
"startTimeBucket": "20100612230038",
"endTimeBucket": "20100613000038"
}}