{"id":5108,"library":"apache-airflow-client","title":"Apache Airflow Client","description":"The `apache-airflow-client` library provides a Pythonic way to interact with the Apache Airflow REST API. It is an auto-generated client based on Airflow's OpenAPI specification, ensuring it remains up-to-date with the latest Airflow API versions. This library allows programmatic control and querying of Airflow DAGs, tasks, and other components. It primarily follows Airflow's release cadence, regenerating with each new Airflow release, currently at version 3.2.0.","status":"active","version":"3.2.0","language":"en","source_language":"en","source_url":"https://github.com/apache/airflow-client-python","tags":["airflow","api-client","orchestration","automation"],"install":[{"cmd":"pip install apache-airflow-client","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The core client class is nested under the 'client' submodule, not directly under the top-level package.","wrong":"from airflow_client import APIClient","symbol":"APIClient","correct":"from airflow_client.client.api_client import APIClient"},{"note":"Configuration settings are located within the 'client' submodule.","wrong":"from airflow_client import Configuration","symbol":"Configuration","correct":"from airflow_client.client.configuration import Configuration"},{"note":"Specific API endpoint classes (like DagApi) are nested under 'client.api', not directly under 'api'.","wrong":"from airflow_client.api.dag_api import DagApi","symbol":"DagApi","correct":"from airflow_client.client.api.dag_api import DagApi"}],"quickstart":{"code":"import os\nfrom airflow_client.client.configuration import Configuration\nfrom airflow_client.client.api_client import APIClient\nfrom airflow_client.client.api.dag_api import DagApi\n\n# Configure API client with Airflow host, username, and password\n# Using environment variables for sensitive data is recommended.\nconfiguration = Configuration(\n    host=os.environ.get(\"AIRFLOW_HOST\", \"http://localhost:8080/api/v1\"),\n    username=os.environ.get(\"AIRFLOW_USERNAME\", \"admin\"),\n    password=os.environ.get(\"AIRFLOW_PASSWORD\", \"admin\")\n)\n\n# Create an instance of the API client\n# The 'with' statement ensures proper connection handling\nwith APIClient(configuration) as api_client:\n    # Create an instance of a specific API endpoint, e.g., DagApi\n    api_instance = DagApi(api_client=api_client)\n    try:\n        # Make an API call, e.g., list DAGs\n        api_response = api_instance.get_dags()\n        print(\"Successfully connected to Airflow API and fetched DAGs:\")\n        if api_response.dags:\n            for dag in api_response.dags:\n                print(f\"- {dag.dag_id}\")\n        else:\n            print(\"No DAGs found.\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Ensure Airflow is running and accessible at the specified host, and credentials are correct.\")","lang":"python","description":"Initializes the Airflow API client with basic authentication using environment variables for host, username, and password. It then attempts to connect to the Airflow instance and list all available DAGs, demonstrating a fundamental API interaction."},"warnings":[{"fix":"Always review the changelog or GitHub releases when upgrading major versions. Update import paths and API calls according to the new client structure and Airflow API specification. Test thoroughly in a staging environment.","message":"Major version updates (e.g., v1.x to v2.x, or v2.x to v3.x) of `apache-airflow-client` may introduce breaking changes due to client regeneration from updated OpenAPI specifications or internal changes in the client generator. This can alter module paths, class structures, or method signatures.","severity":"breaking","affected_versions":"All versions, particularly when upgrading across major client versions."},{"fix":"Ensure your `apache-airflow-client` version is kept up-to-date and aligns with the Apache Airflow API version it was generated against. Refer to the client's GitHub README or release notes for its targeted Airflow API version to avoid compatibility issues.","message":"The `apache-airflow-client` must be compatible with the Airflow API version it's connecting to. Using a client generated for an older Airflow API with a newer Airflow instance (or vice-versa) can lead to unexpected errors, missing endpoints, or incorrect data models.","severity":"gotcha","affected_versions":"All"},{"fix":"For non-Basic Auth setups, you may need to manually manage authentication tokens and pass them via custom headers to the APIClient, or consider using a different method if the client doesn't explicitly support your Airflow's auth backend. Refer to Airflow's documentation on API authentication for details.","message":"The client primarily supports Basic Authentication. If your Airflow instance is configured with a different authentication mechanism (e.g., Google SSO, OAuth, Keycloak), direct usage of the `Configuration(username=..., password=...)` may not work.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}