const api = 'https://api.verdant-ai.com';
const request = {
variables: ['air_temperature_max'],
region: { bbox: [142.30, -34.45, 142.40, -34.35], crs: 'EPSG:4326' },
period: { start: '2003-01-01', end: '2003-01-01' },
temporal_resolution: 'daily',
spatial_resolution: 'native',
units: { air_temperature_max: 'degC' },
data_class: 'interpolated_observation',
missing_policy: 'preserve',
source_preference: 'silo'
};
async function post(path, body) {
const response = await fetch(api + path, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
});
const result = await response.json();
if (!response.ok) throw new Error(JSON.stringify(result));
return result;
}
const coverage = await post('/api/v1/data/resolve', request);
if (!coverage.available) throw new Error(coverage.reason);
const result = await post('/api/v1/data/query', {
...request,
dataset_version: coverage.selection.datasetVersion
});
console.log(result.data);
console.log(result.manifest);