The Curious Traveler

An asynchronous Python CLI orchestrating 9 public REST APIs concurrently, reducing aggregate latency from ~2100ms down to ~880ms (58% reduction).

Discover the architecture
View Source Code
Terminal displaying the Curious Traveler Swindle Sheet output

Abstract

The Curious Traveler (also known as CuriousTrip) is a modular command-line application designed for travel data aggregation. The project was originally codenamed "Swindle Sheet" — a humorous reference to the traditional traveler's expense report — because it compiles an all-in-one profile featuring demographic, meteorological, financial, and cultural insights before arriving in a new destination.

Multi-API Orchestration

The core strength of CuriousTrip lies in its ability to synthesize data from diverse public sources into a single, cohesive narrative. Rather than requiring users to manually search multiple websites, the application acts as an asynchronous aggregation engine.

It orchestrates nine distinct external REST services concurrently: 1) REST Countries (demographics & capitals), 2) Open-Meteo (real-time weather & forecasts), 3) ExchangeRate-API (live currency conversion), 4) TheMealDB (culinary traditions), 5) NumbersAPI (trivia & historical facts), 6) Open-Elevation (altitude profiling), 7) TimeZoneDB (local time offsets), 8) Nager.Date (public holidays), and 9) Wikipedia API (cultural summary).

Diagram showing the multi-API orchestration flow

The Async Architecture: v1 vs v2

Chart comparing synchronous vs asynchronous execution times

The transition from v1 to v2 marked an architectural overhaul isolating concurrency benefits from connection reuse. Benchmarked over 20 live interleaved runs querying destination Tokyo: v1 unpooled (individual requests.get calls) had a median execution time of 2103.7ms [min: 1994.2ms, max: 2836.9ms, Q1–Q3: 2039.9–2187.8ms, IQR: 148.0ms] due to repeated TCP/TLS setups and cumulative blocking I/O; v1 pooled (sequential requests.Session with HTTP keep-alive) had a median time of 2075.0ms [min: 1972.3ms, max: 3091.6ms, Q1–Q3: 2045.3–2102.5ms, IQR: 57.3ms]; v2 concurrent (aiohttp.ClientSession and asyncio.gather) drops median total wall-clock time to 882.8ms [min: 857.2ms, max: 931.6ms, Q1–Q3: 873.5–895.8ms, IQR: 22.2ms] — achieving an overall 58.0% reduction vs unpooled and 57.5% (>50%) vs pooled sequential execution by running the 8 independent secondary endpoints in parallel. Residual variance is governed by remote API server response times.

  • Parallel Execution: Leveraging asyncio.gather, multiple independent API calls are fired concurrently, eliminating cumulative round-trip latency.
  • Efficient Connections: Utilizing aiohttp.ClientSession ensures TCP connection reuse and keep-alive across requests.
  • Hybrid Two-Stage Flow: Dependent data (country coordinates and capital city) is resolved first, unlocking the simultaneous parallel fetching of the remaining 8 datasets.

Data Export & Resilience

Robust software must anticipate failure. CuriousTrip implements comprehensive error handling and safe initialization to ensure stability even when external services timeout or return invalid data.

Furthermore, the application features a dedicated saver.py utility. This module dynamically creates necessary directory structures and securely exports the generated profiles as UTF-8 encoded text files, providing persistent, locally stored data for the user.

Directory structure showing saved text files in the data folder

CLI Demo

Execution walkthrough: CuriousTrip orchestrating concurrent network I/O to assemble a structured travel profile in terminal.

Animated GIF showing the CLI terminal executing the Curious Traveler script