A country selector for a cost-of-living application needs the locations the API actually supports, not a separately maintained list. By the end of this guide, you will know how to retrieve those names with Get Countries V2, use a country in a cost-of-living request, and handle the returned price strings.
The Cities Cost of Living and Average Prices API provides a country list and cost-of-living data for specific countries and cities. It is useful for relocation tools, budgeting applications and location-selection workflows that need both supported locations and price information.
Getting started on Zyla API Hub
Open the API’s marketplace page on Zyla API Hub, create a free account if you do not already have one, and click Subscribe or Start Free Trial when available. Get your API key from your account and use it in the Authorization: Bearer YOUR_API_KEY header.
Zyla uses subscriptions with quotas rather than pay-per-call billing. For a first API, the access option is a 7-day trial or 50 requests; check the API page for current access options and pricing. Keep the key on your server rather than embedding it in a browser-delivered application.
Get the available countries
Get Countries V2 returns the available countries as a JSON array of names. Use this endpoint to populate a selector or validate a user’s choice against the API’s available locations. The documented response starts with names such as Afghanistan, Aland Islands and Albania.
The request is a GET to:
https://zylalabs.com/api/226/cities-cost-of-living-and-average-prices-api/6144/get-countries-v2
No request parameters are documented for this endpoint. Send the bearer authorization header; the Python example below calls it and reads the returned array.
Keep the returned name as the value associated with each selection, even if your interface displays a differently formatted label. That gives your application a clear distinction between the API’s location names and presentation text. Refresh your stored list when appropriate for your application, rather than assuming a hard-coded list will always match available locations.
Request a country’s cost of living
Once you have a country, the country endpoint returns cost-of-living information for that location. The following official request uses the required country string with the documented value united states:
curl -s -X GET "https://zylalabs.com/api/226/cities-cost-of-living-and-average-prices-api/3774/cost-of-living-by-country-v2?country=united+states" \
-H "Authorization: Bearer YOUR_API_KEY"
Replace YOUR_API_KEY with your key before running the command. The plus sign in the query represents the space in the country name. The endpoint’s data is described as updated frequently, so treat the values below as an example rather than fixed current prices.
The official response excerpt is shown verbatim below. It is truncated at the end, so it is not a complete JSON document and should not be used as a test file without obtaining a complete response.
{"Version":1,"Status":200,"Success":true,"Country Name":"United States","Meal, Inexpensive Restaurant":"20.00\u00a0$","Meal for 2 People, Mid-range Restaurant, Three-course":"78.00\u00a0$","McMeal at McDonalds (or Equivalent Combo Meal)":"12.00\u00a0$","Domestic Beer (1 pint draught)":"6.00\u00a0$","Imported Beer (12 oz small bottle)":"3.61\u00a0$","Cappuccino (regular)":"5.30\u00a0$","Coke\/Pepsi (12 oz small bottle)":"2.59\u00a0$","Water (12 oz small bottle)":"2.10\u00a0$","Milk (regular), (1 gallon)":"4.03\u00a0$","Loaf of Fresh White Bread (1 lb)":"3.32\u00a0$","Rice (white), (1 lb)":"2.08\u00a0$","Eggs (regular) (12)":"4.41\u00a0$","Local Cheese (1 lb)":"5.91\u00a0$","Chicken Fillets (1 lb)":"5.56\u00a0$","Beef Round (1 lb) (or Equivalent Back Leg Red Meat)":"7.48\u00a0$","Apples (1 lb)":"2.38\u00a0$","Banana (1 lb)":"0.76\u00a0$","Oranges (1 lb)":"2.03\u00a0$","Tomato (1 lb)":"2.22\u00a0$","Potato (1 lb)":"1.32\u00a0$","Onion (1 lb)":"1.39\u00a0$","Lettuce (1 head)":"2.21\u00a0$","Water (1.5 liter bottle)":"2.25\u00a0$","Bottle of Wine (Mid-Range)":"15.00\u00a0$","Domestic Beer (0.5 liter bottle)":"2.01\u00a0$","Cigarettes 20 Pack (Marlboro)":"10.00\u00a0$","One-way Ticket (Local Transport)":"2.50\u00a0$","Monthly Pass (Regular Price)":"65.00\u00a0$","Taxi Start (Normal Tariff)":"3.55\u00a0$","Taxi 1 mile (Normal Tariff)":"2.80\u00a0$","Taxi 1hour Waiting (Normal Tariff)":"30.00\u00a0$","Gasoline (1 gallon)":"3.39\u00a0$","Volkswagen Golf 1.4 90 KW Trendline (Or Equivalent New Car)":"34,501.73\u00a0$","Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)":"26,061.57\u00a0$","Basic (Electricity, Heating, Cooling, Water, Garbage) for 915 sq ft Apartment":"210.13\u00a0$","Mobile Phone Monthly Plan with Calls and 10GB+ Data":"60.54\u00a0$","Internet (60 Mbps or More, Unlimited Data, Cable\/ADSL)":"72.33\u00a0$","Fitness Club, Monthly Fee for 1 Adult":"45.73\u00a0$","Tennis Court Rent (1 Hour on Weekend)":"21.89\u00a0$","Cinema, International Release, 1 Seat":"15.00\u00a0$","Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child":"1,366.88\u00a0$","International Primary School, Yearly for 1 Child":"23,152.86\u00a0$","1 Pair of Jeans (Levis 501 Or Similar)":"52.37\u00a0$","1 Summer Dress in a Chain Store (Zara, H&M, ...)":"42.80\u00a0$","1 Pair of Nike Running Shoes (Mid-Range)":"90.64\u00a0$","1 Pair of Men Leather Business Shoes":"113.57\u00a0$","Apartment (1 bedroom) in City Centre":"1,729.16\u00a0$","Apartment (1 bedroom) Outside…
The fields Version, Status and Success describe the response, while Country Name identifies the location. The remaining shown fields associate descriptive item names with price strings. For example, the sample has 20.00\u00a0$ for an inexpensive restaurant meal and 65.00\u00a0$ for a monthly transport pass.
Those prices are strings, not JSON numbers: the example includes a currency symbol, a non-breaking space and, for larger amounts, thousands separators. Preserve the original value for display. If you need arithmetic, explicitly parse and validate the format before converting it to a decimal; do not pass the raw string directly to a numeric calculation.
Call both endpoints from Python
This standard-library example first reads the country array, then calls the same country-cost endpoint as the curl request. It prints the documented country name and restaurant-price field without assuming that every possible field is present.
import json
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
API_KEY = "YOUR_API_KEY"
countries_url = (
"https://zylalabs.com/api/226/cities-cost-of-living-and-average-prices-api/6144/get-countries-v2"
)
cost_url = (
"https://zylalabs.com/api/226/cities-cost-of-living-and-average-prices-api/3774/cost-of-living-by-country-v2?country=united+states"
)
def get_json(url):
request = Request(
url,
headers={"Authorization": "Bearer " + API_KEY},
method="GET",
)
with urlopen(request, timeout=30) as response:
return json.load(response)
try:
countries = get_json(countries_url)
if not isinstance(countries, list):
raise ValueError("Expected a country array")
print("Available countries:")
for country in countries:
print(country)
costs = get_json(cost_url)
if not isinstance(costs, dict):
raise ValueError("Expected a country cost object")
print("Country:", costs.get("Country Name"))
print("Success:", costs.get("Success"))
print("Inexpensive restaurant meal:",
costs.get("Meal, Inexpensive Restaurant"))
except HTTPError as error:
print("HTTP request failed:", error.code)
except (URLError, TimeoutError, json.JSONDecodeError, ValueError) as error:
print("Could not read API response:", error)
Replace the key before running the script. The two calls serve different purposes: the first supplies choices for a user interface; the second retrieves prices for the documented United States example. In an application, make the country request after the user selects a location, and URL-encode the selected value when building the query.
Handle transport errors separately from the response’s Success field. A received JSON object is not by itself a reason to display a price as valid; check the response and handle missing fields before rendering a result. The sample uses get so that a missing price does not raise a key error.
Other endpoint and integration uses
Cost of Living by City v2 is a GET endpoint for a specific city. Its request URL is:
https://zylalabs.com/api/226/cities-cost-of-living-and-average-prices-api/3775/cost-of-living-by-city-v2
It requires two string parameters: country and city. The documented values are United States and Seattle, WA, respectively. Like the country data, city data is described as updated frequently.
Do not treat similarly named city and country fields as interchangeable without checking their units. The documented country example describes milk per gallon and apples per pound, while the city example describes milk per liter and apples per kilogram. Their price strings also place the dollar symbol differently. A comparison screen should retain the unit alongside each price and normalize values only when it can do so explicitly.
For a relocation application, use Get Countries V2 to build the initial country selector, then request country-level prices after a selection. A budgeting tool can display individual categories such as meals and transport without claiming they are a complete personal budget. A city-level view can use the city endpoint when the user supplies both required location values.
You can also call the API from an AI agent through MCP. Configure an MCP-compatible client, such as Claude Code, Cursor or Windsurf, with https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY. Ask the agent to retrieve available countries or the documented country cost data, and verify the returned fields and units before using them in a calculation.
FAQ
Does Get Countries V2 require a country parameter?
No request parameters are documented for it. Send a GET request with your bearer API key to receive the available country names.
Does the countries endpoint return prices?
It returns the available country names. To retrieve cost-of-living information for a country, use Cost Of Living by Country v2 with its required country parameter.
Can I calculate directly with the returned prices?
Not without parsing them. The country example returns price values as strings containing formatting and a currency symbol. Preserve the original strings for display and validate any conversion used for arithmetic.
How should I keep the country list current?
Retrieve it from Get Countries V2 instead of maintaining a separate fixed list. If you cache it, choose a refresh policy suited to your application and make sure users can recover if a previously stored selection is no longer available.
Create a free Zyla account, get an API key, and Start 7-day trial on Cities Cost of Living and Average Prices API. Check the listing for current access options and pricing before integrating it into your application.