Access custom configured data products for your subscription.
Endpoints¶
| Method | Endpoint | Description |
|---|---|---|
| GET | /custom/file | List custom product files |
| GET | /custom/file/{file_id} | Download a custom product file |
Overview¶
Custom products are tailored data deliveries configured specifically for your organization’s needs. These may include:
Custom geographic regions
Specific variable selections
Custom temporal resolutions
Proprietary data formats
Specialized post-processing
Contact your Spire Weather representative to configure custom products.
List Custom Files¶
GET /custom/fileRetrieve a list of available custom product files.
Example Request¶
curl -X GET \
'https://api.wx.spire.com/custom/file' \
-H 'spire-api-key: YOUR_API_KEY'import requests
response = requests.get(
"https://api.wx.spire.com/custom/file",
headers={"spire-api-key": "YOUR_API_KEY"},
)
data = response.json()const response = await fetch(
"https://api.wx.spire.com/custom/file",
{ headers: { "spire-api-key": "YOUR_API_KEY" } }
);
const data = await response.json();Response¶
{
"meta": {
"count": 6
},
"files": [
"sof.20240115.t00z.0p25.custom-product.f000.grib2",
"sof.20240115.t00z.0p25.custom-product.f006.grib2",
"sof.20240115.t00z.0p25.custom-product.f012.grib2"
]
}Download Custom File¶
GET /custom/file/{file_id}Download a specific custom product file.
Path Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
file_id | string | Yes | Filename to download |
Example Request¶
curl -OJL -X GET \
'https://api.wx.spire.com/custom/file/sof.20240115.t00z.0p25.custom-product.f000.grib2' \
-H 'spire-api-key: YOUR_API_KEY'import requests
response = requests.get(
"https://api.wx.spire.com/custom/file/sof.20240115.t00z.0p25.custom-product.f000.grib2",
headers={"spire-api-key": "YOUR_API_KEY"},
allow_redirects=True,
)
with open("sof.20240115.t00z.0p25.custom-product.f000.grib2", "wb") as f:
f.write(response.content)import { createWriteStream } from "fs";
import { Readable } from "stream";
const response = await fetch(
"https://api.wx.spire.com/custom/file/sof.20240115.t00z.0p25.custom-product.f000.grib2",
{ headers: { "spire-api-key": "YOUR_API_KEY" } }
);
const fileStream = createWriteStream("sof.20240115.t00z.0p25.custom-product.f000.grib2");
Readable.fromWeb(response.body).pipe(fileStream);Python Example¶
Download all custom product files:
import requests
import os
headers = {'spire-api-key': 'YOUR_API_KEY'}
base_url = 'https://api.wx.spire.com/custom/file'
# Get list of available files
response = requests.get(base_url, headers=headers)
files = response.json()['files']
print(f"Found {len(files)} custom files")
# Create output directory
os.makedirs('custom_data', exist_ok=True)
# Download each file
for filename in files:
print(f'Downloading: {filename}')
file_response = requests.get(
f'{base_url}/{filename}',
headers=headers,
allow_redirects=True
)
filepath = os.path.join('custom_data', filename)
with open(filepath, 'wb') as f:
f.write(file_response.content)
print('Download complete!')Automated Download Script¶
Set up scheduled downloads:
import requests
import os
from datetime import datetime
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def download_custom_products(api_key, output_dir):
"""Download all available custom products."""
headers = {'spire-api-key': api_key}
base_url = 'https://api.wx.spire.com/custom/file'
# Get file list
response = requests.get(base_url, headers=headers)
response.raise_for_status()
files = response.json()['files']
logger.info(f"Found {len(files)} files")
downloaded = []
for filename in files:
filepath = os.path.join(output_dir, filename)
# Skip if already exists
if os.path.exists(filepath):
logger.debug(f"Skipping (exists): {filename}")
continue
logger.info(f"Downloading: {filename}")
file_response = requests.get(
f'{base_url}/{filename}',
headers=headers,
allow_redirects=True
)
file_response.raise_for_status()
with open(filepath, 'wb') as f:
f.write(file_response.content)
downloaded.append(filename)
return downloaded
if __name__ == '__main__':
import os
api_key = os.environ.get('SPIRE_API_KEY')
if not api_key:
raise ValueError("Set SPIRE_API_KEY environment variable")
output_dir = 'custom_data'
os.makedirs(output_dir, exist_ok=True)
downloaded = download_custom_products(api_key, output_dir)
print(f"Downloaded {len(downloaded)} new files")Sample Products¶
For evaluation purposes, sample forecast files may be available:
GET /sample/fileThis endpoint provides sample data for testing your integration before purchasing a subscription.
curl -X GET \
'https://api.wx.spire.com/sample/file' \
-H 'spire-api-key: YOUR_API_KEY'import requests
response = requests.get(
"https://api.wx.spire.com/sample/file",
headers={"spire-api-key": "YOUR_API_KEY"},
)
data = response.json()const response = await fetch(
"https://api.wx.spire.com/sample/file",
{ headers: { "spire-api-key": "YOUR_API_KEY" } }
);
const data = await response.json();Support¶
For questions about custom products or to configure new products:
Contact your Spire Weather representative
Email: weather@spire.com