You have a city name from a user, a form field or a config file, and you want the temperature and tomorrow's forecast. That is the whole job. This guide gets you there with the Weather API from QuotaLink in three requests, then goes further: what to do when a call fails, how many requests a real app burns, how to cache so a free plan lasts, and how three other weather listings on API.market compare when your needs differ.
What you will build
By the end you will have a small script that takes a place name such as "Berlin", resolves it to coordinates, fetches current conditions and a three day forecast, and handles the two or three errors you are most likely to hit. The calls use one base URL and one header, so the same pattern works in curl, Python and Node.
A note on what has and has not been run, because it matters when you copy code. The five HTTP calls shown with real responses (geocode, current, forecast and two failing requests) were executed on 23 November 2026 through the API.market MCP gateway on the free plan. The curl, Python and Node snippets use the same URLs and parameters, but they were not run from a sandbox because it had no API key. Treat them as unexecuted until you run them yourself. Anything about the other three listings comes from their public documentation and catalog data, not from calls we made, and is labelled that way.
Before you start
You need an API.market account and a key. The free plan of the Weather API includes 100 API units. It is a hard limit, so requests are rejected once the units are spent rather than billed. Subscribe on the listing page, then copy your key from your account settings.
Every request sends the key in the x-api-market-key header. The base URL is:
https://prod.api.market/api/v1/quotalink/weather-api
Set the key as an environment variable so it never ends up in your source:
export API_MARKET_KEY="your-key-here"
One design detail shapes everything that follows. The four weather endpoints (/current, /forecast, /hourly, /air-quality) take coordinates, not place names. If all you have is "Berlin", you call /geocode first. That is one extra request, and it is the reason caching matters later in this guide.
Step 1: turn a city name into coordinates
curl "https://prod.api.market/api/v1/quotalink/weather-api/geocode?name=Berlin&count=2" \
-H "x-api-market-key: $API_MARKET_KEY"
This is a real response, trimmed to the fields you will use:
{
"status": "success",
"count": 2,
"data": [
{
"name": "Berlin",
"country": "Germany",
"country_code": "DE",
"admin1": "State of Berlin",
"latitude": 52.52437,
"longitude": 13.41053,
"population": 3426354,
"timezone": "Europe/Berlin"
},
{
"name": "Berlin",
"country": "United States",
"country_code": "US",
"admin1": "New Hampshire",
"latitude": 44.46867,
"longitude": -71.18508,
"population": 9367
}
]
}
Notice that "Berlin" matched two places. Ambiguity is the normal case for city names, not an edge case. London, Ontario and London, UK both come back for "London". If your users type free text, do not silently take the first result. Either show the choices, or pick by country_code when you know the user's country, or fall back to the highest population. The first result happened to be the right one here, but that is a property of the ranking, not a promise.
Step 2: current conditions
Pass the coordinates from the match you chose:
curl "https://prod.api.market/api/v1/quotalink/weather-api/current?latitude=52.52437&longitude=13.41053" \
-H "x-api-market-key: $API_MARKET_KEY"
Real response:
{
"status": "success",
"location": { "latitude": 52.528915, "longitude": 13.423877 },
"data": {
"time": "2026-11-23T10:30",
"interval": 900,
"temperature_2m": 1.8,
"apparent_temperature": -2.6,
"relative_humidity_2m": 77,
"wind_speed_10m": 13.6,
"wind_direction_10m": 287,
"weather_code": 2,
"weather_description": "Partly cloudy"
},
"units": { "temperature": "celsius", "wind": "kmh" }
}
Three things to read carefully. First, location is not the point you sent. It is the centre of the nearest grid cell the weather model used, which is why 52.52437 became 52.528915. If you plot it on a map, expect a small offset. Second, interval: 900 means the value updates every 15 minutes, so asking more often than that returns the same reading and costs a unit each time. Third, weather_description arrives next to the numeric weather_code, so you can show "Partly cloudy" without maintaining your own lookup table.
The tool schema in the listing also shows an optional units parameter (metric or imperial). We did not test it, so check the units object in the response before you trust the unit of a value.
Step 3: a three day forecast
curl "https://prod.api.market/api/v1/quotalink/weather-api/forecast?latitude=52.52437&longitude=13.41053&days=3" \
-H "x-api-market-key: $API_MARKET_KEY"
Real response:
{
"status": "success",
"timezone": "Europe/Berlin",
"location": { "latitude": 52.528915, "longitude": 13.423877 },
"data": {
"time": ["2026-11-23", "2026-11-24", "2026-11-25"],
"temperature_2m_max": [3.6, 2.3, 1.6],
"temperature_2m_min": [0.3, 0.5, -1.3],
"precipitation_sum": [0.4, 0, 0],
"precipitation_probability_max": [40, 5, 0],
"wind_speed_10m_max": [17, 13.9, 7.3],
"weather_code": [80, 51, 3],
"weather_descriptions": ["Slight rain showers", "Light drizzle", "Overcast"]
}
}
The data is a set of parallel arrays. Index 0 is today, and temperature_2m_max[1] goes with time[1]. This shape is compact, but it means you usually want to zip the arrays into one object per day before handing them to a UI. The listing documents days up to 16 and a default of 7, and the default matched what we saw. We only ran days=3.
The same flow in Python
This snippet has not been executed. It uses the same URLs and parameters as the calls above.
import os
import requests
BASE = "https://prod.api.market/api/v1/quotalink/weather-api"
HEADERS = {"x-api-market-key": os.environ["API_MARKET_KEY"]}
def get(path, **params):
r = requests.get(f"{BASE}/{path}", params=params, headers=HEADERS, timeout=15)
r.raise_for_status()
body = r.json()
if body.get("status") != "success":
raise RuntimeError(f"{path} returned {body}")
return body
place = get("geocode", name="Berlin", count=1)["data"][0]
now = get("current", latitude=place["latitude"], longitude=place["longitude"])["data"]
print(f"{place['name']}, {place['country']}: {now['temperature_2m']}C, {now['weather_description']}")
The timeout=15 is deliberate. Without a timeout, requests can wait indefinitely, and a hung weather call should never freeze a page render.
The same flow in Node 18 or later
Also unexecuted, same endpoints.
const BASE = "https://prod.api.market/api/v1/quotalink/weather-api";
const headers = { "x-api-market-key": process.env.API_MARKET_KEY };
async function get(path, params) {
const res = await fetch(`${BASE}/${path}?${new URLSearchParams(params)}`, {
headers,
signal: AbortSignal.timeout(15000),
});
if (!res.ok) throw new Error(`${path} failed: ${res.status} ${await res.text()}`);
return res.json();
}
const [place] = (await get("geocode", { name: "Berlin", count: 1 })).data;
const { data } = await get("forecast", {
latitude: place.latitude,
longitude: place.longitude,
days: 3,
});
data.time.forEach((day, i) =>
console.log(day, data.temperature_2m_max[i], data.weather_descriptions[i])
);
Errors you will actually hit
400: latitude and longitude are required
This is the one we confirmed with real calls. We sent a request with only longitude, and another with lat and lon. Both returned HTTP 400 and this body:
{"error":"latitude and longitude are required"}
The fix is to spell out latitude and longitude in full and send both. Abbreviations are not accepted on this API. It is an easy slip, because plenty of other weather APIs use lat and lon, and one of the listings compared below does exactly that.
Notice that this error body has no status field. If your code does body["status"] == "success" after a raise_for_status(), it never gets there, which is fine, but if you parse the body before checking the HTTP code you will hit a missing key. Check the HTTP status first.
400: missing key header
The listing documents a 400 when the x-api-market-key header is absent, with the message "No x-api-market-key or x-magicapi-key defined in headers". We did not trigger this one, so it comes from the docs.
401, 403 and 429
From the listing's status table (documented, not tested by us): 401 means an invalid or expired key, 403 means your subscription does not cover the endpoint, and 429 means the plan quota is exhausted or you went over the rate limit. On the free plan, hitting 100 units is a 429 you cannot retry your way out of. Do not put it in a retry loop.
5xx
The listing describes these as upstream provider errors and recommends exponential backoff. A reasonable policy is three attempts with waits of one, two and four seconds, then give up and show the last cached value. Cap the total time, and never retry a 4xx.
Here is a Python wrapper that follows that policy. It is not executed, so test it against a bad key and a bad URL before relying on it:
import time
import requests
def get_with_backoff(url, headers, params, attempts=3):
delay = 1
for attempt in range(attempts):
try:
r = requests.get(url, headers=headers, params=params, timeout=15)
except requests.RequestException:
if attempt == attempts - 1:
raise
else:
if r.status_code < 500:
r.raise_for_status() # 4xx: fail fast, do not retry
return r.json()
if attempt == attempts - 1:
r.raise_for_status()
time.sleep(delay)
delay *= 2
What a unit costs, and how fast a real app spends them
On the Weather API every endpoint costs one unit per request. The listing gives two plans: FREE with 100 units as a hard limit, and PRO with 10,000 units per month, also a hard limit. We did not check PRO's price, so look at the listing before you plan a budget. Both plans allow up to 10 requests per second.
Also note that we did not confirm whether the two failed 400 calls consumed units. If you are counting a trial down to the last call, check your usage page after testing errors rather than assuming they were free.
Now the arithmetic. Say you show current weather for a list of cities, refreshed on a schedule:
| Strategy | Requests per city per month | Cities PRO (10,000 units) covers |
|---|---|---|
Poll /current every 15 minutes, all day |
96 per day x 30 = 2,880 | about 3 |
Poll /current hourly |
24 x 30 = 720 | about 13 |
Fetch /forecast twice a day |
2 x 30 = 60 | about 166 |
Fetch /forecast once a day |
30 | about 333 |
These are plain multiplication from the documented one unit per request, not measured usage. They also ignore the one-time geocode per city.
The same numbers hurt more without a cache. If a page shows the weather and you call the API on every page view, then 1,000 views a day is 30,000 units a month, three times the PRO allowance, even for a single city. Most of those calls return identical data, because /current only changes every 15 minutes.
So the free plan's 100 units are a testing budget, not a hosting plan. The listing's own trial is a one-time allowance, not something that refills monthly. Spend it on learning the API, then decide on a paid plan based on your table above.
Caching so the numbers work
The listing's guidance and the arithmetic point the same direction. These are the rules we would apply, in order of payoff.
Geocode once per place. A city does not move. Store the coordinates the first time and never geocode that name again. This removes one request from every lookup after the first.
Round coordinates before using them as a cache key. The service snaps to a grid anyway, as the shifted location in the responses shows. Rounding to three decimals lets nearby requests share an entry. We did not test how coarse the grid is, so keep the rounding conservative.
Match the time to live to the data. /current refreshes every 15 minutes (interval: 900), and the listing says /air-quality refreshes hourly. A TTL shorter than that buys nothing. A TTL of 15 minutes on current conditions is the natural choice.
Fetch forecasts rarely and serve your own copy. A daily forecast changes slowly. Once or twice a day per city is enough for most apps, and your own store can answer every page view in between.
Here is a minimal in-memory version in Python. Again, not executed:
import time
_cache = {}
def cached(key, ttl_seconds, fetch):
hit = _cache.get(key)
now = time.time()
if hit and now - hit[0] < ttl_seconds:
return hit[1]
value = fetch()
_cache[key] = (now, value)
return value
def current_for(place):
key = ("current", round(place["latitude"], 3), round(place["longitude"], 3))
return cached(key, 900, lambda: get("current",
latitude=place["latitude"], longitude=place["longitude"]))
In production you would put this in Redis or your database instead of process memory, so that a restart or a second server does not throw the cache away. One caution on rights: caching for a few minutes to avoid repeat calls is ordinary. Storing and redistributing weather data indefinitely is a different question that depends on the provider's terms. Read the terms of the listing before you build a data product on stored responses.
Which weather API on API.market fits your case
The Weather API above is a good default for worldwide coordinates. It is not the only choice, and the right one depends on three questions: do you have coordinates or only city names, do you need the whole world or just the United States, and do you need alerts or air quality?
Here is how four listings differ on paper. We ran calls only against the QuotaLink API. The other three rows come from their listing documentation and catalog metadata on 23 November 2026, and none of their examples were executed by us.
| QuotaLink Weather API | WeatherNow | US Weather API | Go Weather API | |
|---|---|---|---|---|
| Input | Coordinates, plus a geocode endpoint | City name directly | Coordinates or US ZIP | City name in the path |
| Coverage | Worldwide | Worldwide | United States and territories only | Described as worldwide |
| Endpoints | Current, forecast, hourly, air quality, geocode, health | Current, forecast, place search | Forecast, hourly, current, alerts | One: current weather by city |
| Free offer | 100 units, one-time trial | 100 units, one-time trial | 100 calls for 7 days | 100 units, one-time trial |
| Data source | Upstream Open-Meteo per the health check example | MET Norway plus OpenStreetMap | US National Weather Service | Not stated |
WeatherNow: when you only have city names
WeatherNow takes city directly on /current and /forecast, so you skip the geocode step and the two-request flow. Its documented response also includes the resolved location, so you can show the user which "Berlin" you picked. That saves a request per lookup, and for a city-name-only app it removes the ambiguity handling step from your code.
The trade-offs, from its documentation: weather comes from MET Norway under CC BY 4.0 and place lookup from OpenStreetMap under ODbL, and each response carries an attribution field you are expected to display. It has no hourly endpoint and no air quality. Some forecast fields, such as precipitationProbabilityMaxPercent, are documented as null when the source does not provide them, so do not assume every field is filled. Its error table lists a 404 with code CITY_NOT_FOUND when no place matches, which is a clean signal to build on.
A call looks like this in its docs (unexecuted by us):
curl "https://prod.api.market/api/v1/visionwell/weathernow/forecast?city=London&days=3" \
-H "x-api-market-key: $API_MARKET_KEY"
US Weather API: when you only serve the United States
US Weather API is the one to look at for US-only products. Its documentation describes a 7 day forecast in day and night periods, hourly forecasts up to 156 hours, current conditions from the nearest station, and active watches, warnings and advisories, with the National Weather Service as source. You can query by ZIP, which is how many US forms collect location, and the alerts endpoint accepts a two-letter state code.
Two things to check before you build on it. The docs say current conditions come from the nearest station and can be up to an hour old, so a null or stale value is normal, not a bug. And the documented plans are a 100 call free trial lasting 7 days, then Basic at 5,000 calls per month for $6, Pro at 25,000 for $22 and Ultra at 100,000 for $58. Dividing out, that is roughly $1.20, $0.88 and $0.58 per thousand calls. Those are our calculations from the listed prices.
We also noticed that the documentation's example URLs use a base path containing claimcheckai/us-weather while the listing sits under the datum workspace, and the curl examples send lat, lon and zip all at once. We have not tested which path and parameter combination works. Confirm the base URL in the API.market console before you hard-code it, and send either coordinates or a ZIP, not both, until you know how it resolves a conflict.
Go Weather API: the smallest possible call
Go Weather API exposes one endpoint, /weather/{city}, for current conditions by city name. Its listing mentions Celsius and Fahrenheit, but it publishes no response schema, no error table and no rate limits that we could find. That makes it quick to try and hard to build a contract around. If you want a throwaway prototype, it is the shortest path. If you need documented errors, a forecast or a stable schema, pick one of the others.
A short decision guide
- You have coordinates, or you want hourly data or air quality: use the QuotaLink Weather API.
- You only have city names and want one request: WeatherNow.
- Your users are in the United States and you need alerts or ZIP lookup: US Weather API.
- You want a throwaway prototype and nothing else: Go Weather API, knowing its contract is thin.
You can subscribe to more than one free plan. Running the same city through two of them is a cheap way to see how their numbers differ before you commit.
Common mistakes
Treating the first geocode match as certain. City names collide. Choose by country or population, or let the user pick.
Plotting location as the user's position. It is the grid cell centre. Keep the coordinates you resolved for display.
Polling faster than the data changes. Current conditions refresh every 15 minutes. Polling every minute multiplies your bill by 15 for no new information.
Retrying a hard-limit 429. When the plan is exhausted, retrying cannot help. Stop, alert yourself, and serve cached data.
Reading arrays by position without checking lengths. The forecast arrays are parallel. Validate that they share a length before indexing into them.
Mixing units. The units object in the current response tells you what you got. Do not hard-code Celsius into your display strings if a user can switch units.
What we did not test
For honesty about the edges of this guide: we did not call /hourly or /air-quality on the QuotaLink API. We did not try the units=imperial option. We did not run the curl, Python, Node, retry or cache snippets from a machine with a key. We did not confirm PRO pricing or whether failed 400 requests count against the free allowance. And we did not call WeatherNow, the US Weather API or the Go Weather API at all. Where this page describes them, it is quoting their listings.
Next step
Subscribe to the free plan of the QuotaLink Weather API, run the three curl commands above with a city of your own, and watch your usage page after each call so you learn how units are counted. If your app only knows city names, try WeatherNow next to it. For a US-only product, look at the US Weather API and its alerts endpoint. Once the first lookup works, add the cache before you add features, because that is the change that decides whether a free or low-cost plan lasts.


