Skip to content

omnilab/open-meteo API reference

Floor
Provider · Omnilab
Version
1.x
Conformance suite
not wired
Verified for real
Its README does not say
Licence
MIT
composer require omnilab/open-meteo:1.x-dev

Read from the package's own PHP files at the commit 9dbd0d6b683d: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.

Omnilab\OpenMeteo

  • OpenMeteoSource class

    Open-Meteo (open-meteo.com): weather series at a point - hourly, every 15 minutes or daily, any variable Open-Meteo names ("temperature_2m", "precipitation", "wind_speed_10m", "cloud_cover"...), with the unit it answers in. Or, configured with the air-quality API ($api = AIR_QUALITY), air-quality series at a point: hourly, or daily as the mean, maximum, minimum or sum of the hours ("pm2_5", "pm10", "nitrogen_dioxide", "ozone", "european_aqi", "us_aqi", the pollens...), from the CAMS models, 2013 to five days ahead.

    4 methods · 10 constants

  • OpenMeteoSourceFactory class

    Open-Meteo: weather series, forecast and archive; or air-quality series (api: air_quality) - no key needed for non-commercial use.

    8 options

Omnilab\OpenMeteo

OpenMeteoSource class

final class OpenMeteoSource extends HttpSource OpenMeteoSource.php:35

Open-Meteo (open-meteo.com): weather series at a point - hourly, every 15 minutes or daily, any variable Open-Meteo names ("temperature_2m", "precipitation", "wind_speed_10m", "cloud_cover"...), with the unit it answers in. Or, configured with the air-quality API ($api = AIR_QUALITY), air-quality series at a point: hourly, or daily as the mean, maximum, minimum or sum of the hours ("pm2_5", "pm10", "nitrogen_dioxide", "ozone", "european_aqi", "us_aqi", the pollens...), from the CAMS models, 2013 to five days ahead.

Two APIs, chosen by the period: the forecast API (api.open-meteo.com) from 92 days ago to 16 days ahead, the historical archive (archive-api.open-meteo.com: ERA5 and its successors, from 1940) for what ended more than $archiveDelay days ago; a period that starts in the archive and ends in the forecast's window is asked of both and joined.

Free without a key for non-commercial use (open-meteo.com/en/terms: fewer than 10 000 calls a day, 5 000 an hour, 600 a minute, and credit given to Open-Meteo). With a key (api_key), the calls go to the customer-api hosts; a self-hosted instance is a base_uri away.

const BASE_URI = 'https://api.open-meteo.com/v1/'
const ARCHIVE_URI = 'https://archive-api.open-meteo.com/v1/'
const CUSTOMER_URI = 'https://customer-api.open-meteo.com/v1/'
const CUSTOMER_ARCHIVE_URI = 'https://customer-archive-api.open-meteo.com/v1/'
const AIR_QUALITY_URI = 'https://air-quality-api.open-meteo.com/v1/'
const CUSTOMER_AIR_QUALITY_URI = 'https://customer-air-quality-api.open-meteo.com/v1/'
const WEATHER = 'weather'

The API a source asks: the weather (forecast and archive), or the air quality.

const AIR_QUALITY = 'air_quality'
const AIR_QUALITY_FIRST_DAY = '2013-01-01'

The first day the air-quality API answers (CAMS European and global, as Open-Meteo serves them).

const FORECAST_PAST_DAYS = 92

How far back the forecast API answers, in days.

OpenMeteoSource::__construct()

public function __construct(HttpClientInterface $http, string $baseUri = self::BASE_URI, readonly string $archiveUri = self::ARCHIVE_URI, readonly ?string $apiKey = null, readonly string $timezone = 'auto', readonly int $archiveDelay = 5, readonly ?string $models = null, readonly ?string $today = null, array $headers = [], float $throttle = 0.0, readonly string $api = self::WEATHER)
$timezone

what times and days are given in when the query does not say: "auto" (the point's own), "GMT", "Europe/Paris"...

$archiveDelay

how many days the archive lags behind today

$models

the weather models to ask for ("best_match" when null)

$today

the day taken for today (a test's), the real one when null

$api

WEATHER, or AIR_QUALITY: then $baseUri is the air-quality API's, $archiveUri and $models are not used

OpenMeteoSource::getName()

public function getName(): string

OpenMeteoSource::capabilities()

public function capabilities(): array

OpenMeteoSource::series()

public function series(SeriesQuery $query): array

OpenMeteoSourceFactory class

final class OpenMeteoSourceFactory extends SourceFactory OpenMeteoSourceFactory.php:24

Open-Meteo: weather series, forecast and archive; or air-quality series (api: air_quality) - no key needed for non-commercial use.

options: api: weather # or air_quality: PM2.5, PM10, NO2, O3, the European and US indices, pollens... (a source of its own) api_key: ~ # a commercial key: the calls go to customer-api.open-meteo.com timezone: auto # the times' and the days' zone when a query does not say: auto (the point's), GMT, Europe/Paris... models: ~ # "best_match" when not set; "icon_seamless", "ecmwf_ifs025"... archive_delay: 5 # days the archive lags behind today base_uri: 'https://api.open-meteo.com/v1/' # or a self-hosted instance; https://air-quality-api.open-meteo.com/v1/ for air_quality archive_uri: 'https://archive-api.open-meteo.com/v1/' today: ~ # the day taken for today (tests): the real one when not set

Options

OptionDefault
apiOpenMeteoSource::WEATHER
api_keynull
timezone'auto'
modelsnull
archive_delay5
todaynull
base_urimatch (true) { $airQuality => $key ? OpenMeteoSource::CUSTOMER_AIR_QUALITY_URI : OpenMeteoSource::AIR_QUALITY_URI, default => $key ? OpenMeteoSource:…
archive_uri$key ? OpenMeteoSource::CUSTOMER_ARCHIVE_URI : OpenMeteoSource::ARCHIVE_URI