
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
facebook-ads-reports
Advanced tools
ETL module for Facebook Ads API v23 with lightweight native Python data processing
A Python ETL driver for Facebook Marketing API v23 data extraction and transformation. Simplifies the process of extracting Facebook Ads data and converting it to structured data formats with comprehensive utility functions.
pip install facebook-ads-reports
Option A: Configuration file
Create a secrets/fb_business_config.json
file with your Facebook Ads API credentials:
{
"app_id": "YOUR_APP_ID",
"app_secret": "YOUR_APP_SECRET",
"access_token": "YOUR_ACCESS_TOKEN",
"ad_account_id": "act_1234567890",
"base_url": "https://graph.facebook.com/v23.0"
}
Option B: Environment variable
Set the FACEBOOK_ADS_CONFIG_JSON
environment variable with your credentials as JSON:
export FACEBOOK_ADS_CONFIG_JSON='{"app_id": "YOUR_APP_ID", "app_secret": "YOUR_APP_SECRET", "access_token": "YOUR_ACCESS_TOKEN", "ad_account_id": "act_1234567890", "base_url": "https://graph.facebook.com/v23.0"}'
from datetime import date, timedelta
from facebook_ads_reports import MetaAdsReport, MetaAdsReportModel
from facebook_ads_reports.utils import load_credentials, save_report_to_csv, save_report_to_json
# Load credentials
credentials = load_credentials()
client = MetaAdsReport(credentials_dict=credentials)
# Configure report parameters
ad_account_id = "act_1234567890"
start_date = date.today() - timedelta(days=7)
end_date = date.today() - timedelta(days=1)
# Extract report data
data = client.get_insights_report(
ad_account_id=ad_account_id,
report_model=MetaAdsReportModel.ad_performance_report,
start_date=start_date,
end_date=end_date
)
# Save to CSV using utility function
save_report_to_csv(data, "ad_performance_report.csv")
# Save to JSON using utility function
save_report_to_json(data, "ad_performance_report.json")
MetaAdsReportModel.ad_dimensions_report
- Ad dimensions and metadataMetaAdsReportModel.ad_performance_report
- Ad performance and actions metricsCreate custom report configurations:
from facebook_ads_reports import create_custom_report
custom_report = create_custom_report(
report_name="my_custom_report",
select=["ad_id", "impressions", "spend"],
from_table="ad_insights"
)
# Usage:
# data = client.get_insights_report(ad_account_id, custom_report, start_date, end_date)
Check the examples/
directory for comprehensive usage examples:
basic_usage.py
- Simple report extractionGPL License. See LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
ETL module for Facebook Ads API v23 with lightweight native Python data processing
We found that facebook-ads-reports demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.