There is the CLI function airflow dags list which lists all DAGs in the current environment. Is there a similar function in the Python API?
There is the CLI function airflow dags list which lists all DAGs in the current environment. Is there a similar function in the Python API?
Yes. Airflow Rest API has List DAGs endpoint.
GET /dags
There is also official Python client for the API so you can use it with Python easily.
You can see example how to set it for get_dags:
with client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = dag_api.DAGApi(api_client)
limit = 100
offset = 0
order_by = "order_by_example"
tags = [
"tags_example",
]
only_active = True
try:
# List DAGs
api_response = api_instance.get_dags(limit=limit, offset=offset, order_by=order_by, tags=tags, only_active=only_active)
pprint(api_response)
except client.ApiException as e:
print("Exception when calling DAGApi->get_dags: %s\n" % e)