03. DBT Artifacts and API
️ DBT Artifacts and API
dbt generates artifacts during runs that contain metadata about models, tests, sources, and lineage.
The dbt API allows programmatic access to these artifacts, enabling automation, monitoring, and integration with other tools.
Key DBT Artifacts
- manifest.json → Contains information about all models, sources, tests, macros, and relationships
- run_results.json → Records execution results for models, tests, and snapshots
- catalog.json → Stores schema information for sources and models
- sources.json → Contains source metadata
Use Cases:
- Track model execution status
- Generate custom dashboards for monitoring
- Automate impact analysis before deploying changes
️ Using the DBT API
- dbt Cloud provides a REST API to interact with projects, jobs, and runs
- Common operations:
- Trigger jobs
- Retrieve run results
- Access artifacts programmatically
Example: Triggering a Job via API (Python)
import requests
api_token = "<YOUR_API_TOKEN>"
job_id = "<DBT_JOB_ID>"
response = requests.post(
f"https://cloud.getdbt.com/api/v2/accounts/<ACCOUNT_ID>/jobs/{job_id}/run/",
headers={"Authorization": f"Token {api_token}"}
)
print(response.json())
Best Practices
Use artifacts to monitor pipeline health
Automate impact analysis using manifest.json
Integrate with internal tools or dashboards for visibility
Use the API for programmatic control of dbt runs
Combine artifacts and CI/CD pipelines for full automation