Air quality data repositories, and the formats that break PHP

The open data dream usually dies the moment you download your first 500MB NetCDF file. If you are building a custom dashboard, or a WooCommerce delivery alert that keys off local environmental conditions, you have probably worked out that Air Quality Data Repositories keep good data behind an awkward wall of tooling. I have watched developers treat a satellite raster like a plain JSON object, time out a PHP worker, and take the site down with it.

Displaying this data is not a wp_remote_get() problem, it is an architecture problem. The data lives in a handful of places, and each of them hands you a format that a standard WordPress setup chokes on.

Air quality data repositories worth using in production

One-off downloads do not survive a real project. You need an API that is documented, stable, and returns the same thing next month that it returns today. These are the Air Quality Data Repositories I trust on client work.

  • OpenAQ harmonizes global ground measurements from government and community sensors. If you want one consistent JSON shape for PM2.5 or O3 across several countries, start here.
  • EPA AQS and AirNow are the reference sources for U.S. projects. AirNow in particular is good for real-time AQI displays and wildfire tracking.
  • Copernicus (CAMS) publishes global reanalyses and forecasts. No tidy CSV is waiting for you here, only GRIB and NetCDF.
  • NASA Earthdata covers satellite-derived measures such as Aerosol Optical Depth. It needs an Earthdata Login, so plan for token handling.

How well any of them integrate comes down to API performance, especially when thousands of visitors each trigger a fetch.

The formats you will actually hit

Scientific data has no interest in being web friendly. You will run into binary formats PHP was never built to parse, and each one has its own way of eating an afternoon.

NetCDF4 and HDF5 hold multi-dimensional arrays. The closest everyday comparison is a spreadsheet with dozens of sheets, one per time slice or altitude. In practice you need a Python microservice or a dedicated library to pull out the slice you want before WordPress ever sees it.

COG, or Cloud-Optimized GeoTIFF, is a raster format built for the web. Rather than pulling down a 2GB image of the planet, you issue HTTP range requests and take only the tiles inside your user’s bounding box.

Parquet and GeoParquet are columnar. With millions of sensor readings, Parquet costs far less in storage and processing time than the same data as CSV, and most of the big data tooling already reads it.

Cache it with transients

The mistake I run into most is code that calls these Air Quality Data Repositories on every page load, which wrecks Core Web Vitals the moment traffic arrives. Cache the response. The Transients API is enough for this, and the version below fetches OpenAQ data and holds it for an hour.

<?php
/**
 * Fetch and cache air quality data from OpenAQ.
 * Prefixing with bbioon_ for safety.
 */
function bbioon_get_cached_air_quality( $location_id ) {
    $transient_key = 'bbioon_aq_data_' . $location_id;
    $cached_data   = get_transient( $transient_key );

    if ( false !== $cached_data ) {
        return $cached_data;
    }

    $api_url = "https://api.openaq.org/v2/latest/" . $location_id;
    $response = wp_remote_get( $api_url, [
        'headers' => [
            'X-API-Key' => 'YOUR_API_KEY_HERE'
        ],
        'timeout' => 15
    ]);

    if ( is_wp_error( $response ) ) {
        return false;
    }

    $body = json_decode( wp_remote_retrieve_body( $response ), true );
    
    // Hack: Ensure we actually have data before caching
    if ( ! empty( $body['results'] ) ) {
        // Cache for 1 hour
        set_transient( $transient_key, $body['results'], HOUR_IN_SECONDS );
        return $body['results'];
    }

    return false;
}

That much keeps your server calm when the external API starts lagging. If the same site is also running heavier AI work, scaling the infrastructure is the next thing to look at.

If wiring up air quality data repositories is eating your dev hours, I have been doing this since the 4.x days and I am happy to take it off your plate.

Ship it, but cache it

Reading from Air Quality Data Repositories is no longer an atmospheric science specialty. OpenAQ and formats like COG put local environmental data within reach of a WordPress site without a research budget. Cache what you fetch, know which format you are holding, and assume the external API will be slow on the day your traffic spikes.

author avatar
Ahmad Wael
I'm a WordPress and WooCommerce developer with 15+ years of experience building custom e-commerce solutions and plugins. I specialize in PHP development, following WordPress coding standards to deliver clean, maintainable code. Currently, I'm exploring AI and e-commerce by building multi-agent systems and SaaS products that integrate technologies like Google Gemini API with WordPress platforms, approaching every project with a commitment to performance, security, and exceptional user experience.