Search code examples
node.jsapollo-serveramadeus

filtering amadeus flightsOffers using carriers code using node js and graphql


I have to filter the flightOffer using origin, destination, departureDate, carrier

but I've got this error message when adding carrier to parametres Some of the parameters were not recognized. Please check your query. How can I filter the result by passing carrier to amadeus query ??

the query

import * as Sentry from '@sentry/node';
import amadeus from './../../../../amadeus';

export default async (parent, args, context, info) => {
  try {
    const { result } = await amadeus.shopping.flightOffers.get({
      origin: args.filter.origin,
      destination: args.filter.destination,
      departureDate: args.filter.departureDate,
      carrier: args.filter.carrier
    });
    context.dictionaries =await result.dictionaries;
    return result.data;
  } catch (error) {
    console.log(error);
    Sentry.captureException(error);
    return [];
  }
};

Solution

  • By looking at your code it is not clear if you use the Flight Low-fare Search API or the Flight Offers Search API.

    In any case, those 2 APIs do not have a carrier parameter. If you want to filter by airlines you can use:

    For Flight Low-fare Search:

    • includeAirlines: List of airline IATA codes to include, comma-separated
    • excludeAirlines: List of airline IATA codes to exclude, comma-separated

    For Flight Offers Search:

    • includedAirlineCodes: List of airline IATA codes to include, comma-separated
    • excludedAirlineCodes: List of airline IATA codes to exclude, comma-separated