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.
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
| Option | Type | Default | Description |
|---|---|---|---|
| apiKey | string | — | Secret key attached to every proxied upstream request. Required. |
| baseUrl | string | 'https://api.infoplaza.com' | Upstream origin. Each route appends its own path (/v1/weather/maps, /v1/weather/timeseries, /v1/weather/ensemble, /v1/marine/timeseries). |
| basePath | string | '/api/platform' | Public path this handler is mounted on. Used to resolve the endpoint segment. |
| apiKeyQueryParam | string | 'token' | Query param the key is sent as for map /models. Set to '' to use header auth instead. |
| apiKeyHeader | string | '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
| Path | Type | Default | Description |
|---|---|---|---|
| GET /models | maps | — | Weather models catalog for the map stack. |
| GET /timeseries-models | timeseries | — | Requires lat and lon. Location-filtered forecast catalog. |
| GET /timeseries-point-forecast | timeseries | — | Requires lat, lon, model, elements, and levels. Optional runtime, units, members. |
| GET /ensemble-models | ensemble | — | Requires lat and lon together if either is present. |
| GET /ensemble-point-forecast | ensemble | — | Requires lat, lon, model, and elements. Optional levels, runtime, units. |
| GET /marine-timeseries-models | marine | — | Requires lat and lon together if either is present. Location-filtered marine catalog. |
| GET /marine-timeseries-point-forecast | marine | — | Requires lat, lon, model, and elements. Optional levels, runtime, units, members. |
Environment
# .env.local
PLATFORM_API_KEY=your-secret-keyyour-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.