pyforeca
Async Python client for the Foreca Weather API —
current conditions, hourly and daily forecasts, air quality and location lookup,
with typed models and aiohttp under the hood.
Getting an API key
Create a free account at developer.foreca.com, pick a plan, and copy your key from My API. The Freemium plan is free for non-commercial use (hobbyist, student, and research projects); commercial use, a larger quota, or the rest of Foreca's weather products need a paid plan.
Install
pip install pyforeca
Usage
import asyncio
from pyforeca import ForecaApiClient, format_location
async def main() -> None:
async with ForecaApiClient("YOUR_API_KEY") as client:
location = format_location(lon=24.94, lat=60.17)
current = await client.current(location)
print(current.temperature, current.symbol_phrase)
daily = await client.forecast_daily(location, periods=7)
hourly = await client.forecast_hourly(location, periods=24)
air_quality = await client.air_quality_hourly(location, periods=1)
asyncio.run(main())
Pass an existing aiohttp.ClientSession as session= to share one with your
application; the client then leaves closing it to you.
| Method | Endpoint |
|---|---|
location_info(location) |
/api/v1/location/{location} |
current(location) |
/api/v1/current/{location} |
observation_latest(location, precipitation=None) |
/api/v1/observation/latest/{location} |
forecast_minutely(location) |
/api/v1/forecast/minutely/{location} |
forecast_15minutely(location, periods, dataset) |
/api/v1/forecast/15minutely/{location} |
forecast_hourly(location, periods, dataset) |
/api/v1/forecast/hourly/{location} |
forecast_3hourly(location, periods, dataset) |
/api/v1/forecast/3hourly/{location} |
forecast_daily(location, periods, dataset, ensemble=False) |
/api/v1/forecast/daily/{location} |
air_quality_hourly(location, periods) |
/api/v1/air-quality/forecast/hourly/{location} |
air_quality_daily(location, periods) |
/api/v1/air-quality/forecast/daily/{location} |
location is "longitude,latitude" (longitude first) or a Foreca location id.
The API rounds most values to whole numbers; pass rounding=0 to current,
observation_latest and the forecast calls for decimals. With
precipitation="latest", observation_latest also returns the station's latest
precipitation accumulations; with precipitation="hourly", the past day's
one-hour accumulations, each with its precipitation type. With dataset="full" and ensemble=True,
forecast_daily also returns the ensemble percentiles of each day's maximum and minimum temperature and
precipitation accumulation.
forecast_minutely returns a list whose resolution is 1 (minutes) where the
forecast is a radar nowcast and 60 elsewhere.
Symbol.parse("d421") decodes weather symbol codes; see the
symbol reference.
Errors: ForecaAuthError (key rejected), ForecaProductUnavailableError (the
key is valid but its plan lacks the product), ForecaRateLimitError (HTTP 429),
ForecaConnectionError (network/timeout), all subclasses of ForecaError.
When the per-second limit answers 429 with a Retry-After of up to 5 seconds,
the client waits that long and retries once before raising
ForecaRateLimitError; its error and retry_after attributes carry the
API's error code and wait time.
Attribution
Applications displaying Foreca data must attribute Foreca — see the logo and attribution requirements.
Development
python3 -m venv .venv && .venv/bin/pip install -e . pytest pytest-asyncio
.venv/bin/pytest
Maintained by Foreca in the foreca-dev organization. Released under the MIT License.
Metadata
Release files for pyforeca 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyforeca-0.4.0.tar.gz | 20.9 kB | With provenance | Details for pyforeca-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyforeca-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for pyforeca-0.4.0-py3-none-any.whl |
Total release size: 31.9 kB
Release files / pyforeca-0.4.0.tar.gz
| Download URL | pyforeca-0.4.0.tar.gz |
|---|---|
| Size | 20.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
311578f7bd28a2230154af8781c4a3a0621ca149c00b79854bc832d069db9a5e
|
|
BLAKE2b-256 checksum How to use checksums |
d2179947518fa4ca9fc2f5891b7f1ee5ae567d5c02e2e6c5ca9232da83d6175d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logRelease files / pyforeca-0.4.0-py3-none-any.whl
| Download URL | pyforeca-0.4.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a6fdce3fa447cc7438af50c6603932ae0c6f75c1e882352cae5f4f102249ba5
|
|
BLAKE2b-256 checksum How to use checksums |
ffc21d2c87831ecdd0aba6117d9d13f8cc69febd67a4107520c27668232b463d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logSecurity for pyforeca 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pyforeca-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.