SWATGenXSWATGenX

Automated U.S. watershed modeling

Programmatic SWAT+ Model Generation

Generate SWAT+ watershed model packages programmatically for USGS gages, HUC12 outlets, and HUC8 basins using the same NHDPlus-HR and national-dataset pipeline behind the web app.

  • REST jobs for SWAT+ packages
  • HUC12, USGS gage, or HUC8
  • Same pipeline as the web app
  • Copy-paste Python snippets
Developer API overview: request model generation, poll job status, and download SWAT+ packages from code.

What the API does

The SWATGenX API lets you submit watershed model-generation jobs from code instead of the map interface. You can request SWAT+ packages for USGS gages, HUC12 outlet watersheds, or full HUC8 basins, then track the job and download the completed model package.

The API is designed for repeatable watershed modeling workflows: batch requests, research pipelines, evaluation studies, and integration with external notebooks or decision-support tools.

Model-generation entry points

USGS gage

Generate a SWAT+ model for a gage-centered watershed using site_no.

HUC12 outlet

Generate a SWAT+ model from a selected WBD HUC12 outlet watershed.

HUC8 basin

Generate a whole-basin SWAT+ model for an eight-digit HUC8 watershed. Available on Pro.

Why this API matters

Every request uses the same SWATGenX model-generation pipeline: NHDPlus-HR hydrography, national weather, land cover, soils, crop, terrain, and optional water-use inputs assembled into a downloadable SWAT+ project structure.

Start with a minimal Python request

Choose the watershed type, copy the request, and replace the identifier with your USGS gage, HUC12 outlet, or HUC8 code. Full polling and download examples are available on GitHub.

Sample requests.post body
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",
}

# 12-digit WBD outlet HUC12 — catalog watershed from Watershed Explorer
payload = {
    "outlet_huc12": "070500020602",
    "ls_resolution": 250,
    "dem_resolution": 30,
}

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

print(r.json())

Workflow

Request → build → track → download. Same model-generation engine as the web app — error handling and advanced options are covered in the GitHub examples.

1Get an API key

Create an account and generate an API key from your access page.

2Submit a model request

Send a USGS gage, HUC12 outlet, or HUC8 basin request to the model-generation endpoint.

3Track the build

Poll task and order endpoints while SWATGenX delineates the watershed, assembles model inputs, and builds the SWAT+ package.

4Download the model package

When the job completes, download the ZIP package and continue in SWAT+ Editor or your calibration workflow.

Core API routes

These are the main routes for creating, tracking, and downloading SWAT+ model packages. Full request bodies and examples are maintained in the GitHub repository.

MethodRoutePurpose
POST/api/model-settingsCreate model by USGS station (JSON: site_no)
POST/api/model-settings/explorer-watershedCreate model by outlet HUC12 catalog watershed (JSON: outlet_huc12)
POST/api/model-settings-huc8Create model by whole HUC8 (Pro; JSON: huc8_code)
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

Programmatic SWAT+ model generation for supported USGS gage and HUC12 outlet workflows within starter limits.

Pro

Adds HUC8 whole-basin model generation, higher-volume workflows, and optional cloud calibration support.

GitHub examples & support

Notebooks and scripts show polling, downloads, and tier-aware requests. Review completed SWAT+ examples before submitting jobs. For keys and access updates, use your access page.

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