You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过API下载所需CSV格式的Facebook Analytics数据?

Facebook Analytics CSV数据API下载方案

Hey Eugene, let's work through how to get the exact CSV data you need from Facebook Analytics via API, since the official export tool isn't cutting it for you.

核心方案:用Facebook Graph API定制导出

The official docs' export feature only covers standard datasets, but the Graph API lets you pull exactly the metrics and time ranges you need directly as CSV. Here's how to set it up:

1. 先搞定权限与访问令牌

First, you need a valid access token with the right permissions:

  • For app Analytics: Grab the app_events_read permission
  • For page Analytics: You'll need pages_show_list + pages_read_engagement
  • For ad-related Analytics: Use ads_read
    You can generate a test token quickly in the Graph API Explorer to verify permissions work before building into your workflow.

2. 调用正确的API端点

Use these endpoints to pull your data, with parameters tailored to your needs:

  • App Analytics: GET /{app-id}/analytics
  • Page Analytics: GET /{page-id}/insights

关键参数定制(直接输出CSV)

Add these params to get exactly what you want, formatted as CSV:

  • metric: List the specific metrics you need (e.g., active_users,app_installs,page_view_duration)
  • period: Time interval (options: day, week, month, lifetime)
  • date_preset: Quick time range (e.g., last_7d, last_30d, this_month)
  • format=csv: Forces the response to be a CSV file instead of JSON
  • start_time/end_time: For custom date ranges (use ISO 8601 format like 2024-01-01T00:00:00Z)

示例curl请求

curl -G "https://graph.facebook.com/v18.0/{your-app-or-page-id}/analytics" \
  -d "access_token={your-valid-access-token}" \
  -d "metric=active_users,app_installs" \
  -d "period=day" \
  -d "date_preset=last_30d" \
  -d "format=csv"

3. 为什么Web Console抓包没成功?

If you couldn't get requests working via browser dev tools, here's likely why:

  • Session tokens expire fast: Facebook's internal dashboard requests use short-lived session cookies/tokens that become invalid almost immediately outside the browser session
  • CORS restrictions: Browsers block cross-origin requests initiated directly from the console, so you'll have better luck using tools like Postman or curl to replicate the request with valid auth

4. 批量历史数据导出

If you need large-scale historical datasets, use the /{app-id}/analytics_export endpoint. It supports bulk CSV exports for custom date ranges, which is perfect for pulling months of data at once. Just add start_time and end_time params to define your window.

注意事项

  • Always use the latest stable Graph API version (check Facebook's docs for the current release)
  • Make sure your app has been approved for the required permissions if you're using this in production (test tokens work for development, but production needs app review)

内容的提问来源于stack exchange,提问作者Eugene Kisly

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:26:47