{"id":9472,"library":"apache-airflow-providers-facebook","title":"Apache Airflow Facebook Provider","description":"This provider package integrates Apache Airflow with Facebook APIs, offering operators and hooks to interact with various Facebook services like Marketing and Prophet. It allows data engineers to programmatically manage and automate data workflows involving Facebook platforms. Current version is 3.9.4, with releases tied to the Apache Airflow release cycle.","status":"active","version":"3.9.4","language":"en","source_language":"en","source_url":"https://github.com/apache/airflow/tree/main/airflow/providers/facebook","tags":["airflow","facebook","marketing","prophet","etl","provider","social media"],"install":[{"cmd":"pip install apache-airflow-providers-facebook","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This is an Airflow provider, requiring Apache Airflow core to function.","package":"apache-airflow"},{"reason":"The provider uses the Facebook Business SDK to interact with Facebook APIs.","package":"facebook-business","optional":false}],"imports":[{"symbol":"FacebookMarketingOperator","correct":"from airflow.providers.facebook.marketing.operators.marketing import FacebookMarketingOperator"},{"symbol":"FacebookMarketingHook","correct":"from airflow.providers.facebook.marketing.hooks.marketing import FacebookMarketingHook"},{"symbol":"FacebookProphetOperator","correct":"from airflow.providers.facebook.prophet.operators.prophet import ProphetOperator"}],"quickstart":{"code":"from __future__ import annotations\n\nimport pendulum\nimport os\n\nfrom airflow.models.dag import DAG\nfrom airflow.providers.facebook.marketing.operators.marketing import FacebookMarketingOperator\n\n# NOTE: Ensure you have an Airflow Connection named 'facebook_marketing_default'\n# with your Facebook Access Token (e.g., in the 'Password' field or 'Extra' JSON).\n# Example Extra: {\"access_token\": \"YOUR_ACCESS_TOKEN\", \"api_version\": \"v19.0\"}\n\nwith DAG(\n    dag_id=\"facebook_marketing_example\",\n    start_date=pendulum.datetime(2023, 1, 1, tz=\"UTC\"),\n    schedule=None,\n    catchup=False,\n    tags=[\"facebook\", \"marketing\", \"example\"],\n    doc_md=\"\"\"\n    ### Facebook Marketing Example DAG\n    A simple DAG demonstrating how to use the FacebookMarketingOperator to fetch ad accounts.\n    Requires a 'facebook_marketing_default' Airflow connection with an access token.\n    \"\"\"\n) as dag:\n    get_ad_accounts = FacebookMarketingOperator(\n        task_id=\"get_ad_accounts\",\n        facebook_conn_id=\"facebook_marketing_default\",\n        api_method=\"GET\",\n        api_path=\"/me/adaccounts\",\n        fields=[\"id\", \"name\", \"account_status\"],\n        result_processor=lambda result: print(f\"Fetched Ad Accounts: {result}\")\n    )\n","lang":"python","description":"This example DAG uses the `FacebookMarketingOperator` to fetch a list of ad accounts associated with the configured Facebook connection. It requires an Airflow connection named `facebook_marketing_default` with a valid Facebook Access Token. The access token can be stored in the 'Password' field or as part of the 'Extra' JSON for the connection."},"warnings":[{"fix":"Regularly check Facebook Marketing API documentation for updates. Update `api_version` in your Airflow connection's 'Extra' field (e.g., `{\"api_version\": \"v19.0\"}`) or directly in the operator parameters if issues arise after Facebook API updates.","message":"Facebook API versions frequently introduce breaking changes or deprecate endpoints. The provider's functionality is tightly coupled to the underlying Facebook Marketing API version. Ensure your `api_version` in the Airflow connection or operator parameters matches a supported and active Facebook API version to avoid unexpected errors.","severity":"breaking","affected_versions":"All versions, depends on Facebook API changes"},{"fix":"Refer to the `apache-airflow-providers-facebook` PyPI page or GitHub for specific `facebook-business` dependency ranges. Consider using a virtual environment and pinning dependency versions to ensure stability.","message":"The provider relies on the `facebook-business` Python SDK. Incompatibilities can arise if your `facebook-business` package version is not aligned with the provider's expectations or if there are conflicts with other libraries. This can lead to unexpected runtime errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your Airflow connection (`facebook_conn_id`) uses a current and valid Facebook Access Token. Regularly check the token's validity in Facebook's developer tools and refresh if necessary. Consider using environment variables or a secrets backend for sensitive tokens instead of directly in the connection UI.","message":"Authentication failures are common due to expired or invalid Facebook Access Tokens. Airflow connections for Facebook Marketing typically require a long-lived access token, which can still expire or be invalidated by Facebook security policies.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement retry mechanisms with exponential backoff in your DAGs for tasks interacting with Facebook APIs. Design your DAGs to minimize concurrent requests and distribute load. Refer to Facebook's API rate limiting documentation.","message":"Facebook APIs have strict rate limits. Making too many requests in a short period can lead to throttling errors (e.g., HTTP 429). The provider itself does not inherently handle complex rate-limit backoff strategies for user-defined tasks.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the provider using pip: `pip install apache-airflow-providers-facebook`","cause":"The `apache-airflow-providers-facebook` package has not been installed in your Airflow environment.","error":"ModuleNotFoundError: No module named 'airflow.providers.facebook'"},{"fix":"Carefully review the operator's parameters against the official Facebook Marketing API documentation for the specific endpoint and API version you are targeting. Also, verify that the Facebook user/app associated with your access token has the necessary permissions.","cause":"One or more parameters passed to the operator are incorrect, malformed, or missing required values according to the Facebook API specification for the chosen method and path. This can also indicate insufficient permissions for the connected user/app.","error":"airflow.exceptions.AirflowException: Facebook Marketing API Error #100 Invalid parameter: message"},{"fix":"Generate a new long-lived access token from your Facebook Developer App and update the `facebook_marketing_default` (or your chosen) Airflow connection with the new token. Ensure the token has the required permissions.","cause":"The access token provided in the Airflow connection (`facebook_conn_id`) has expired, been revoked, or is otherwise invalid.","error":"airflow.exceptions.AirflowException: Facebook Marketing API Error #190 Error validating access token: Session has expired or is not valid for this access token."}]}