{"id":1478,"library":"facebook-business","title":"Facebook Business SDK","description":"The Facebook Business SDK provides a Python interface to Meta's suite of business APIs, including the Marketing API, Pages, Business Manager, and Instagram APIs. It simplifies the process of building custom solutions for managing ads, pages, and other business assets on Meta platforms. The library is actively maintained, with frequent releases tied to new versions of the underlying Graph API, currently at version 25.0.1.","status":"active","version":"25.0.1","language":"en","source_language":"en","source_url":"https://github.com/facebook/facebook-python-business-sdk","tags":["facebook","meta","marketing","ads","business","api","social media"],"install":[{"cmd":"pip install facebook-business","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The 'facebookads' package is an older, deprecated SDK. The correct package is 'facebook_business'.","wrong":"from facebookads.api import FacebookAdsApi","symbol":"FacebookAdsApi","correct":"from facebook_business.api import FacebookAdsApi"},{"symbol":"AdAccount","correct":"from facebook_business.adobjects.adaccount import AdAccount"}],"quickstart":{"code":"import os\nfrom facebook_business.api import FacebookAdsApi\nfrom facebook_business.adobjects.adaccount import AdAccount\n\n# --- Configuration (replace with your actual values or environment variables) ---\n# Get these from your Facebook Developer App settings\nAPP_ID = os.environ.get('FB_APP_ID', 'YOUR_APP_ID')\nAPP_SECRET = os.environ.get('FB_APP_SECRET', 'YOUR_APP_SECRET')\nACCESS_TOKEN = os.environ.get('FB_ACCESS_TOKEN', 'YOUR_ACCESS_TOKEN')\n\n# Get this from your Facebook Ad Account\nAD_ACCOUNT_ID = os.environ.get('FB_AD_ACCOUNT_ID', 'act_YOUR_AD_ACCOUNT_ID') # Prefix with 'act_'\n\n# Initialize the API\nFacebookAdsApi.init(app_id=APP_ID, app_secret=APP_SECRET, access_token=ACCESS_TOKEN)\n\ntry:\n    # Create an AdAccount object\n    account = AdAccount(AD_ACCOUNT_ID)\n\n    # Fetch campaigns for the ad account\n    campaigns = account.get_campaigns(fields=[AdAccount.Field.name, AdAccount.Field.status])\n\n    print(f\"Campaigns for Ad Account {AD_ACCOUNT_ID}:\")\n    for campaign in campaigns:\n        print(f\"  - ID: {campaign['id']}, Name: {campaign['name']}, Status: {campaign['status']}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your APP_ID, APP_SECRET, ACCESS_TOKEN, and AD_ACCOUNT_ID are correct \")\n    print(\"and that your access token has the necessary permissions (e.g., 'ads_read', 'ads_management').\")\n","lang":"python","description":"Initializes the Facebook Business SDK and fetches a list of campaigns from a specified ad account. Requires an App ID, App Secret, Access Token, and Ad Account ID with appropriate permissions."},"warnings":[{"fix":"Migrate to the new Advantage+ campaign structure using Advantage+ audience, campaign budget, and placements. Refer to Meta's Advantage+ Campaigns documentation for migration guidance.","message":"Advantage+ Shopping Campaigns (ASC) and Advantage+ App Campaigns (AAC) can no longer be created or updated via the Marketing API starting v25.0. This change extends to all versions by May 19, 2026, as part of the Automation Unification toward Advantage+ setup.","severity":"breaking","affected_versions":">= 25.0.0, all versions after May 19, 2026"},{"fix":"Developers must explicitly opt out of Dynamic Media if it is not desired for Advantage+ Catalog ads. Review your API integrations to adjust this setting before September 1, 2025, with full enforcement by October 20, 2025.","message":"Dynamic Media is enabled by default for Advantage+ Catalog ads via the Marketing API starting v24.0.","severity":"breaking","affected_versions":">= 24.0.0"},{"fix":"Update ad set configurations to remove the Facebook video feeds placement. The Facebook Reels placement is the recommended replacement.","message":"The Facebook video feeds ad placement is no longer available in Marketing API v24.0. Attempts to use it will result in errors.","severity":"breaking","affected_versions":">= 24.0.0"},{"fix":"Transition to using the new `Media Views` and `Media Viewers` metrics which will replace the deprecated legacy metrics.","message":"Several legacy metrics, including Page Reach, Impressions, and 3-second Viewers, are planned for deprecation in June 2026.","severity":"deprecated","affected_versions":"All versions, effective June 2026"},{"fix":"Ensure your application explicitly targets or is compatible with a currently supported Marketing API version (e.g., v25.0). Meta typically supports older API versions for a 90-day grace period after a new version is released.","message":"The SDK relies on specific API versions. If the API version used in your calls (or the default set by the SDK) becomes deprecated, your requests will fail with a 'deprecated version' error.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Regularly refresh access tokens, particularly long-lived ones. Verify that your app and user access tokens have all necessary permissions/scopes for the API calls being made.","message":"Access tokens have a limited lifespan and require correct permissions. Expired tokens or insufficient permissions (e.g., `ads_read`, `ads_management`) are common causes of API call failures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}