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
| Component | Location |
|---|---|
| Service | core/services/qpx_service.py |
| Mapper | core/services/utils/qpx_mapper.py |
| Client | infra/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:
| Entity | Description | Source |
|---|---|---|
Flight | Complete flight offer | models/database_entities/flight.py |
FlightLeg | Single flight segment | models/database_entities/flight_leg.py |
Fare | Fare details per leg | models/database_entities/fare.py |
Error Handling
The service handles common API errors:
QPXTimeoutError— Request timed outQPXAuthenticationError— Invalid API credentialsQPXRateLimitError— Rate limit exceededQPXAPIError— General API errors
Configuration
Environment variables:
QPX_API_URL— API endpointQPX_API_KEY— Authentication keyQPX_TIMEOUT_SECONDS— Request timeoutQPX_MAX_RETRIES— Retry count
Related Documentation
- Orchestrator — How the service is used
- Backend Architecture — Overall architecture