The Curious Traveler is a command-line Python application designed to aggregate and display comprehensive travel data. By integrating multiple free public APIs, the application allows users to input a destination country and instantly receive a curated travel profile. This profile includes demographic information, real-time weather conditions, live currency conversion, culinary suggestions, and daily entertainment trivia.
The project serves as a practical demonstration of handling HTTP REST requests, parsing complex JSON payloads, and orchestrating data from diverse external sources into a unified, highly readable interface.
- Prompt the user to input a country name in English (e.g.,
Italy,Japan,Brazil). - Utilize the REST Countries API to retrieve information regarding the specified country:
https://restcountries.com/v3.1/name/{country_name}
- From the API response, extract and display:
- Official country name
- Capital city
- Population
- Continent
- Spoken languages
- Currency used
Tip: The response is returned as a list. You will need to access the first element (e.g.,
data[0]).
- From the REST Countries response, extract the geographic coordinates of the capital city (locate the
capitalInfo→latlngfield). - Utilize these coordinates to query the Open-Meteo API for current weather data:
https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}¤t_weather=true
- Extract and display:
- Current temperature
- Wind speed
- Weather condition: If the
weathercodefield equals 0, display "☀️ Clear sky"; otherwise, display "☁️ Cloudy/Variable".
- From the REST Countries response, identify the local currency code (e.g.,
JPYfor Japan,BRLfor Brazil). - Use the ExchangeRate API to retrieve the current exchange rate relative to the Euro:
https://open.er-api.com/v6/latest/EUR
- Prompt the user to input a travel budget in Euros (e.g.,
500). - Calculate and display the equivalent value of the budget in the destination's local currency.
- Query TheMealDB to fetch a random recipe:
https://www.themealdb.com/api/json/v1/1/random.php
- Extract and display:
- Dish name
- Category (e.g., Seafood, Dessert)
- The first 5 ingredients (fields are named
strIngredient1,strIngredient2, etc.) - Link to the recipe instructions (using
strSourceorstrYoutube)
Note: TheMealDB returns international recipes, so the dish may not originate from the selected country. Present this simply as a "Chef's Suggestion".
- Use the Cat Facts API to fetch a random cat fact:
https://catfact.ninja/fact
- Use the JokeAPI to fetch a random joke:
https://v2.jokeapi.dev/joke/Any?lang=en&type=single
- Display both items under a "Travel Entertainment" section.
Assemble all the aggregated data into a clean, highly readable command-line interface output. The application should print a structured card similar to the following format:
╔══════════════════════════════════════════╗
║ TRAVEL PROFILE - CURIOUSTRIP ║
╠══════════════════════════════════════════╣
📍 DESTINATION
Country: Japan
Capital: Tokyo
Continent: Asia
Population: 125,836,021
Languages: Japanese
Currency: Japanese yen (JPY)
🌤️ WEATHER IN TOKYO
Temperature: 12°C
Wind: 15 km/h
Conditions: ☀️ Clear sky
💰 BUDGET
500 EUR = 78,500 JPY
🍽️ CHEF'S SUGGESTION
Dish: Sushi
Category: Seafood
Ingredients: Rice, Nori, Salmon, Avocado, Soy Sauce
🐱 TRIVIA
"Cats sleep for 70% of their lives."
😂 TRAVEL JOKE
"Why did the computer go to the doctor? Because it had a virus!"
╚══════════════════════════════════════════╝
Following enhancements to implement:
- 🔁 Application Loop: Upon displaying the card, prompt the user to search for another country or exit the application.
- 📸 Space Imagery: Append the Astronomy Picture of the Day to the card using the NASA APOD API (
https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY). Display the title and the image URL. - 🐶 Random Dog: Replace (or accompany) the cat fact with a link to a random dog image using the Dog API (
https://dog.ceo/api/breeds/image/random). - 🎓 Universities: Query the Hipolabs Universities API to print the top 3 universities located in the chosen country.
- 💾 Data Export: Save the generated travel profile to a
.txtfile named after the country (e.g.,profile_japan.txt).
- Work iteratively: Implement and thoroughly test one phase at a time before proceeding to the next.
- Inspect the payload: Utilize
print(data)orprint(data.keys())to explore the structure of the JSON responses if you are unsure of their contents. - Handle timeouts gracefully: If a specific API is unresponsive, do not stall; proceed with the others and revisit it later.
- Code organization: While creating explicit functions is not strictly necessary for this script (sequential execution is acceptable), you are highly encouraged to organize your code modularly if you feel comfortable doing so.
Safe travels! 🧳