Skip to main content

QPX Service

The QPXService handles communication with the QPX Connect API, transforming requests and responses between the internal domain model and the external API format.

Overview

QPX Connect is the primary flight search provider. The service abstracts the API complexity and provides a clean interface for the orchestrator.

Source Code

ComponentLocation
Servicecore/services/qpx_service.py
Mappercore/services/utils/qpx_mapper.py
Clientinfra/clients/qpx_connect_client.py

Request Format

QPX Connect uses XML for requests:

<?xml version="1.0" encoding="UTF-8"?>
<AirShoppingRQ>
<CoreQuery>
<OriginDestinations>
<OriginDestination>
<Departure>
<AirportCode>YUL</AirportCode>
<Date>2025-03-15</Date>
</Departure>
<Arrival>
<AirportCode>CDG</AirportCode>
</Arrival>
</OriginDestination>
</OriginDestinations>
</CoreQuery>
<Travelers>
<Traveler>
<AnonymousTraveler>
<PTC>ADT</PTC>
</AnonymousTraveler>
</Traveler>
</Travelers>
<Preference>
<CabinPreferences>
<CabinType>
<Code>Y</Code>
</CabinType>
</CabinPreferences>
</Preference>
</AirShoppingRQ>

Response Mapping

The QPXMapper transforms XML responses to domain entities.

Entity Models

See the entity source files for full attribute definitions:

EntityDescriptionSource
FlightComplete flight offermodels/database_entities/flight.py
FlightLegSingle flight segmentmodels/database_entities/flight_leg.py
FareFare details per legmodels/database_entities/fare.py

Error Handling

The service handles common API errors:

  • QPXTimeoutError — Request timed out
  • QPXAuthenticationError — Invalid API credentials
  • QPXRateLimitError — Rate limit exceeded
  • QPXAPIError — General API errors

Configuration

Environment variables:

  • QPX_API_URL — API endpoint
  • QPX_API_KEY — Authentication key
  • QPX_TIMEOUT_SECONDS — Request timeout
  • QPX_MAX_RETRIES — Retry count