Load National Weather Service data to DuckDB
Build a National Weather Service to DuckDB pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the National Weather Service API base URL, auth, endpoints, and incremental loading.
The National Weather Service API provides public access to weather-related data, including forecasts, alerts, and observations. Everything needed to build a working National Weather Service → DuckDB pipeline is on this page: the API's base URL, authentication, endpoints, pagination and incremental field — plus a prompt that hands the whole job to your coding agent.
Build your National Weather Service to DuckDB pipeline
Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.
PromptRunuvx dlthub-init@latestto build a pipeline from National Weather Service to DuckDB and run it on dltHub
That scaffolds a dltHub workspace and installs the dltHub AI harness — the project rules, the secrets-management skill, and the dlt MCP server your agent needs to work safely. From there it reads the National Weather Service API, proposes the endpoints to load, then writes, runs and validates the pipeline while you review rather than type. Credentials are inspected through MCP tools, so your agent never reads secrets.toml itself. How the LLM-native workflow works →
Prefer to write it yourself? Every fact the agent uses is below.
National Weather Service API at a glance
| Base URL | https://api.weather.gov |
| Example endpoint | GET alerts |
| Records found at | features |
| Authentication | all requests require a custom User-Agent header |
| Also required | User-Agent |
| Pagination | Cursor-based next cursor at pagination.next |
| API reference | https://www.weather.gov/documentation/services-web-api |
These values come from the National Weather Service API reference — the authoritative source if anything here looks out of date.
How do I authenticate with the National Weather Service API?
All requests require a User-Agent header for identification, which should follow the format (application_domain.com, contact_email@address.com).
1. Get your credentials
The National Weather Service (NWS) REST API does not use a traditional API key, registration dashboard, or secret token system. Instead, it requires all API requests to include a custom User-Agent header to identify your application for security and rate-limiting purposes. To use the API, simply construct a string in the format 'User-Agent: (your-domain.com, contact@email.com)' and include this as a header in every HTTP request sent to the API.
2. Add them to .dlt/secrets.toml
[sources.national_weather_service_source] user_agent = "(myweatherapp.com, contact@myweatherapp.com)"
dlt reads this file automatically at runtime. With the harness, the setup-secrets skill prompts you for the values and never handles the raw credential in chat. For production, see setting up credentials with dlt.
What National Weather Service data can I load into DuckDB?
These are the National Weather Service endpoints dlt can load into DuckDB:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| alerts | /alerts | GET | features | Retrieve all alerts |
| alerts_active | /alerts/active | GET | features | Retrieve currently active alerts |
| stations | /stations | GET | features | List observation stations |
| zones | /zones | GET | features | List zones |
| radar_servers | /radar/servers | GET | List radar servers |
How do I load only new National Weather Service records?
The National Weather Service API reference does not document a timestamp or sequence field for these endpoints, so there is nothing to advertise here as verified. Pick a field from the endpoints table above that increases with every write, then set it as the cursor_path.
{"name": "alerts", "endpoint": { "path": "alerts", # Replace with a field that increases on every write. "incremental": {"cursor_path": "REPLACE_ME", "initial_value": "2024-01-01T00:00:00Z"}, }}
On the first run dlt loads everything from initial_value; on every run after that it requests only what changed and appends with write_disposition="merge" if you set a primary key. See incremental loading.
What does the generated National Weather Service pipeline look like?
A standard dlt REST API pipeline — the same code you would write by hand, loading points and gridpoints from the National Weather Service API into DuckDB:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def national_weather_service_source(user_agent=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.weather.gov", "auth": {"type": "api_key", "api_key": user_agent, "name": "User-Agent"}, }, "resources": [ {"name": "alerts", "endpoint": {"path": "alerts", "data_selector": "features"}}, {"name": "alerts_active", "endpoint": {"path": "alerts/active", "data_selector": "features"}} ], } yield from rest_api_resources(config) def load_national_weather_service_to_duckdb() -> None: pipeline = dlt.pipeline( pipeline_name="national_weather_service_pipeline", destination="duckdb", dataset_name="national_weather_service_data", ) load_info = pipeline.run(national_weather_service_source()) print(load_info) if __name__ == "__main__": load_national_weather_service_to_duckdb()
Run it with python national_weather_service_pipeline.py. The agent iterates on this until it loads cleanly — you review and approve, rather than write it from scratch.
How do I query National Weather Service data in DuckDB?
dlt creates one table per resource. Query the loaded data with Python or SQL — or ask your agent to, through the MCP server's execute_sql_query tool.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("national_weather_service_pipeline").dataset() df = data.alerts.df() print(df.head())
SQL:
SELECT * FROM national_weather_service_data.alerts LIMIT 10;
See querying your data with dataset and exploring it in marimo notebooks.
How do I deploy the National Weather Service to DuckDB pipeline in production?
The pipeline runs locally, which is ideal for prototyping and one-off analysis. When you need it on a schedule, monitored on every load, and shared with your team, deploy the same dlt code on the dltHub platform — no infrastructure to maintain. The prompt above already ends with "run it on dltHub", so your agent can take it there directly.
- Deploy & schedule — run the pipeline as a managed job with automatic retries.
- Monitor — observable job queues, alerting, and load metrics for every run.
- Transform — promote raw National Weather Service loads into governed, documented models.
- Visualize & share — explore data in notebooks and publish live dashboards instead of static screenshots.
What other destinations can I load National Weather Service data to?
dlt loads into any of these — only the destination argument changes:
| Destination | Example value |
|---|---|
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Set dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. On the dltHub platform the same pipeline runs against a managed Iceberg lakehouse. See the full destinations list.
Next steps
Was this page helpful?
Community Hub
Need more dlt context for National Weather Service to DuckDB?
Request dlt skills, commands, AGENT.md files, and AI-native context.