Documentation

Server setup

@infoplaza/platform/auth

Providers, timeseries, ensemble, and marine timeseries load data by calling /api/platform/* on your server. That route proxies to the Infoplaza API with your secret key. Mount PlatformAuth once on a catch-all — every platform endpoint is served automatically. The browser never sees the key.

Create an API token on the Infoplaza developer platform first, then mount this handler. Without a token and this route, GET /api/platform/models (and the timeseries / ensemble / marine catalog and point-forecast routes) do not exist, so weather layers and forecast tables will not load. To see API request counts and token credit cost in a host app, open the platform examples.

Create an API token

API keys are created and managed on the Infoplaza developer platform. Copy the token into PLATFORM_API_KEY on your server. Without a token, /api/platform/* cannot proxy weather, timeseries, ensemble, or marine data.

App Router

Create app/api/platform/[...platform]/route.ts:

import PlatformAuth from '@infoplaza/platform/auth'

const apiKey = process.env.PLATFORM_API_KEY
if (!apiKey) {
  throw new Error('PLATFORM_API_KEY environment variable is not set')
}

const handler = PlatformAuth({ apiKey })

export { handler as GET, handler as POST }

Pages Router

Create pages/api/platform/[...platform].ts:

import PlatformAuth from '@infoplaza/platform/auth'

export default PlatformAuth({ apiKey: process.env.PLATFORM_API_KEY! })

Options

Only apiKey is required. Import type PlatformAuthOptions from @infoplaza/platform/auth.

PlatformAuthOptions

OptionTypeDefaultDescription
apiKeystring—Secret key attached to every proxied upstream request. Required.
baseUrlstring'https://api.infoplaza.com'Upstream origin. Each route appends its own path (/v1/weather/maps, /v1/weather/timeseries, /v1/weather/ensemble, /v1/marine/timeseries).
basePathstring'/api/platform'Public path this handler is mounted on. Used to resolve the endpoint segment.
apiKeyQueryParamstring'token'Query param the key is sent as for map /models. Set to '' to use header auth instead.
apiKeyHeaderstring'Authorization'Header used when apiKeyQueryParam is falsy.
apiKeyScheme(apiKey) => string`Bearer ${apiKey}`Formats the header value when using header auth.

Map requests send the key as ?token= by default. Timeseries, ensemble, and marine timeseries handlers send ?api_key= regardless of apiKeyQueryParam.

Proxied endpoints

Unknown first segments return 404. New endpoints added to the package appear on this catch-all without extra route files.

Routes

PathTypeDefaultDescription
GET /modelsmaps—Weather models catalog for the map stack.
GET /timeseries-modelstimeseries—Requires lat and lon. Location-filtered forecast catalog.
GET /timeseries-point-forecasttimeseries—Requires lat, lon, model, elements, and levels. Optional runtime, units, members.
GET /ensemble-modelsensemble—Requires lat and lon together if either is present.
GET /ensemble-point-forecastensemble—Requires lat, lon, model, and elements. Optional levels, runtime, units.
GET /marine-timeseries-modelsmarine—Requires lat and lon together if either is present. Location-filtered marine catalog.
GET /marine-timeseries-point-forecastmarine—Requires lat, lon, model, and elements. Optional levels, runtime, units, members.

Environment

# .env.local
PLATFORM_API_KEY=your-secret-key

your-secret-key is the token from the developer platform. Keep it server-side and never commit it. If you mount the handler under a different base path, pass it through modelsConfig.basePath on Providers / WeatherLayers, and basePath on TimeseriesModelsProvider / EnsembleModelsProvider, so client requests target the right URL. Default is /api/platform.