{"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":"python","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"},{"fix":"Update the SDK to its latest version. If the problem persists, ensure your application explicitly targets an API version known to be compatible with your SDK version, and review Meta's Marketing API changelog for updates to object structures.","message":"The SDK encountered an AttributeError `type object 'Field' has no attribute 'status'`, suggesting an incompatibility with the Marketing API's data structures or an SDK bug. This often occurs when the SDK version does not align with the API version being called.","severity":"breaking","affected_versions":"Specific SDK/API version combinations"}],"env_vars":null,"search_vec":"'25.0.1':68 'activ':51 'ad':39,72 'api':18,22,28,64,74 'asset':44 'build':34 'busi':2,6,17,24,43,73 'current':65 'custom':35 'facebook':1,5,69 'frequent':54 'graph':63 'includ':19 'instagram':27 'interfac':11 'librari':49 'maintain':52 'manag':25,38 'market':21,71 'media':76 'meta':13,46,70 'new':58 'page':23,40 'platform':47 'process':32 'provid':8 'python':10 'releas':55 'sdk':3,7 'simplifi':30 'social':75 'solut':36 'suit':15 'tie':56 'under':62 'version':59,67","created_at":"2026-04-09T03:49:40.095516+00:00","updated_at":"2026-04-16T14:54:35.091646+00:00","problems":[{"fix":"Change the import statement to use `facebook_business.adobjects` for specific objects like AdCampaign, AdAccount, etc. For example, `from facebook_business.adobjects.adcampaign import AdCampaign`.","cause":"The Python import statement is attempting to access a module path that no longer exists or is incorrect in the `facebook-business` SDK. The common ad objects are typically found under `facebook_business.adobjects`.","error":"ModuleNotFoundError: No module named 'facebook_business.objects'"},{"fix":"Call `FacebookAdsApi.init(app_id=MY_APP_ID, app_secret=MY_APP_SECRET, access_token=MY_ACCESS_TOKEN)` at the beginning of your script or before making any API calls.","cause":"The FacebookAdsApi object, which handles authentication and API versioning, has not been properly initialized with your app ID, app secret, and access token before attempting to make any API requests.","error":"ValueError: You must initialize FacebookAdsApi before making any calls."},{"fix":"Generate a new, valid user access token or app access token from the Meta Developer Dashboard with the required permissions for your application. Ensure the token is not expired and is correctly included in your API initialization.","cause":"The access token provided to the API is either expired, invalid, malformed, or does not have the necessary permissions for the requested operation.","error":"FacebookRequestError: Invalid access token: The access token could not be decrypted"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"26.0.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://developers.facebook.com","github":"https://github.com/facebook/facebook-python-business-sdk","docs":null,"changelog":null,"pypi":"https://pypi.org/project/facebook-business/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}