SWATGenX Developer API

Generate SWAT+ watershed models programmatically by USGS station or HUC8.

The SWATGenX Model Creation API lets researchers, agencies, and technical teams submit SWAT+ model-generation requests through HTTP using a USGS streamgage ID or HUC8 watershed code. SWATGenX handles watershed delineation, national data preparation, model construction, queueing, and delivery of the completed model package.

Create from code

Submit a USGS station ID or HUC8 watershed code, track the model-generation task, and download the completed SWAT+ workspace when the run finishes.

Create by USGS station

Submit a station ID and generate a station-centered SWAT+ watershed model.

Create by HUC8

Generate whole-basin SWAT+ models for HUC8 watersheds. HUC8 creation requires Pro access.

Track and download

Check order status, monitor task progress, and download completed model ZIP files through secure token links.

Workflow

1Get an API key

Create an account and generate an API key from the Subscription page.

2Submit a model request

Use Python, Jupyter, curl, or any HTTP client.

3Track progress

Poll task status and model-order endpoints while SWATGenX builds the model.

4Download the ZIP

Use the completion email or dashboard token link to download the completed SWAT+ workspace.

Example request

Minimal requests call to queue a station model (see the public repo for polling, HUC8, and downloads).

import os
import requests

API_KEY = os.environ["SWATGENX_API_KEY"]

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "X-SWATGenX-Api-Key": API_KEY,
    "Content-Type": "application/json",
}

payload = {
    "site_no": "05580950",
    "ls_resolution": 250,
    "dem_resolution": 30,
}

r = requests.post(
    "https://www.swatgenx.com/api/model-settings",
    headers=headers,
    json=payload,
    timeout=120,
)

print(r.json())

What the API exposes

Full authentication, tier rules, and request bodies are documented in the GitHub repo — this table is a quick map only.

MethodRoutePurpose
POST/api/model-settingsCreate model by USGS station
POST/api/model-settings-huc8Create model by HUC8
GET/api/model-ordersList recent model orders
GET/api/task_status/<task_id>Check task progress
GET/download_model/<token>Download completed ZIP

Access levels

Basic

Suitable for testing station-based model creation. Includes limited daily model orders and watershed-size limits.

Pro

Designed for repeated technical use, HUC8 model creation, larger quotas, and advanced modeling workflows.

Start with the public examples

Use the Jupyter notebook or Python scripts to submit your first model request, inspect task status, and download the completed SWAT+ package.

Model Creation API examples (Jupyter + Python): GitHub.