Numbeo API Example – Retrieve Cost of Living for a City
This repository contains a Python example application that demonstrates how to fetch and display cost of living data from the Numbeo API for any city and country.
- Fetch real-time cost of living data from Numbeo API
- Display prices organized by category
- Show average, minimum, and maximum prices
- Command-line interface with flexible API key configuration
- Clean, formatted terminal output
- Clone this repository:
git clone https://github.com/numbeo/numbeo-api-python.git
cd numbeo-api-python- Install dependencies:
pip install -r requirements.txtpython city_prices_example.py --city "San Francisco, CA" --country "United States" --api-key YOUR_API_KEYSet your API key as an environment variable:
export NUMBEO_API_KEY=your_api_key
python city_prices_example.py --city "San Francisco, CA" --country "United States"# London, UK
python city_prices_example.py --city "London" --country "United Kingdom" --api-key YOUR_KEY
# Tokyo, Japan
python city_prices_example.py --city "Tokyo" --country "Japan" --api-key YOUR_KEY
# Paris, France
python city_prices_example.py --city "Paris" --country "France" --api-key YOUR_KEYFetching price data for San Francisco, CA, United States...
================================================================================
COST OF LIVING DATA: San Francisco, CA, United States
================================================================================
Currency: USD
Restaurants:
--------------------------------------------------------------------------------
Meal, Inexpensive Restaurant
Average: $25.00
Range: $15.00 - $40.00
Data points: 450
Meal for 2 People, Mid-range Restaurant, Three-course
Average: $100.00
Range: $70.00 - $150.00
Data points: 320
...
You need a valid Numbeo API key to use this application. Visit Numbeo API Documentation to obtain your API key.
- Python 3.7+
- requests library (see requirements.txt)
This project is licensed under the MIT License - see the LICENSE file for details.